diff --git a/AllBase/AllBase.csproj b/AllBase/AllBase.csproj
index 82d9a8d..5c37c50 100644
--- a/AllBase/AllBase.csproj
+++ b/AllBase/AllBase.csproj
@@ -197,6 +197,7 @@
+
@@ -213,6 +214,7 @@
+
diff --git a/AllBase/BaseClass.cs b/AllBase/BaseClass.cs
index 11cf140..987065b 100644
--- a/AllBase/BaseClass.cs
+++ b/AllBase/BaseClass.cs
@@ -27,7 +27,7 @@ namespace AllBase
///
/// 版本ID
///
- public static int VersionCount = 979;
+ public static int VersionCount = 989;
//public static int VersionCount = 613;
///
diff --git a/AllBase/BaseRegex.cs b/AllBase/BaseRegex.cs
index fe2c7a6..d0ff0cf 100644
--- a/AllBase/BaseRegex.cs
+++ b/AllBase/BaseRegex.cs
@@ -681,6 +681,8 @@ namespace AllBase
public static System.Collections.Generic.List GetJsonObjStrJson(ref string html, string reg, int level = 0)
{
+ var startTime = DateTime.Now;
+
System.Collections.Generic.List rstLst = new System.Collections.Generic.List();
if (html == null)
return rstLst;
@@ -716,6 +718,10 @@ namespace AllBase
//htmlTmp = htmlTmp.Substring(1);
if (braceNum == 0)
{
+ var endTime1 = DateTime.Now;
+ if ((endTime1 - startTime).TotalSeconds > 1)
+ {
+ }
rstLst.Add(htmlTmp.Substring(0, i + 1).Replace("\\这里是正花括号占位符", "\\{").Replace("\\这里是反花括号占位符", "\\}"));
htmlTmp = htmlTmp.Substring(i + 1);
//rstLst.Add(rst.Replace("\\这里是正花括号占位符", "\\{").Replace("\\这里是反花括号占位符", "\\}"));
@@ -729,11 +735,16 @@ namespace AllBase
if (htmlTmp.Length > 0)
goto retry;
+ var endTime2 = DateTime.Now;
+ if ((endTime2 - startTime).TotalSeconds > 1)
+ {
+ }
return rstLst;
}
public static System.Collections.Generic.List GetJsonArrStrJson(ref string html, string reg)
{
+ var startTime = DateTime.Now;
System.Collections.Generic.List rstLst = new System.Collections.Generic.List();
if (html == null)
return rstLst;
@@ -766,6 +777,10 @@ namespace AllBase
if (htmlTmp.Length > 0)
goto retry;
+ var endTime = DateTime.Now;
+ if ((endTime - startTime).TotalSeconds > 1)
+ {
+ }
return rstLst;
}
diff --git a/AllBase/Helper/GlobalConfig.cs b/AllBase/Helper/GlobalConfig.cs
index 69ed406..d177146 100644
--- a/AllBase/Helper/GlobalConfig.cs
+++ b/AllBase/Helper/GlobalConfig.cs
@@ -3,6 +3,7 @@ using AllBase.Model.Param.ProductManage;
using AllBase.Model.Param.ShopManage;
using AllBase.Model.Param.TemuProductManage;
using AllBase.Model.Result;
+using AllBase.Model.Result.PDDResult;
using AllBase.Model.Result.WXResult;
using LittleCow.Model.Param.WeiDianManage;
using NaiBa.Util;
@@ -53,6 +54,11 @@ namespace AllBase.Helper
/// 微店上货参数
///
public static WeiDianSettingParam WeiDianUploadParam { get; set; }
+
+ ///
+ /// 拼多多api列表
+ ///
+ public static ConcurrentList PddClentInfoList = new ConcurrentList();
}
public enum ShopPlatform
diff --git a/AllBase/LogSave.cs b/AllBase/LogSave.cs
index f8a5b3f..22c70d4 100644
--- a/AllBase/LogSave.cs
+++ b/AllBase/LogSave.cs
@@ -154,7 +154,7 @@ namespace AllBase
BaseClass.ViewCode += message + "\r\n";
if (Logs.Count > 5000)
{
- BaseClass.ViewCode += "日志队列超长,请检查日志处理\r\n";
+ //BaseClass.ViewCode += "日志队列超长,请检查日志处理\r\n";
Logs.Clear();
return;
}
diff --git a/AllBase/Model/Param/PDDProdParam/PddRelationParam.cs b/AllBase/Model/Param/PDDProdParam/PddRelationParam.cs
new file mode 100644
index 0000000..5889202
--- /dev/null
+++ b/AllBase/Model/Param/PDDProdParam/PddRelationParam.cs
@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AllBase.Model.Param.PDDProdParam
+{
+ public class PddRelationParam
+ {
+ public string up_spu_id { get; set; } // "88C9F35912594F76A21CDD5F36DAE972",
+ public string up_goods_name { get; set; } // "婴儿衣服POLO衫短袖T恤0-3岁男童夏装宝宝女小童上衣儿童幼儿外出",
+ public string from_site { get; set; } // "vd",
+ public string goods_id { get; set; } // "7735389957",
+ public string shop_id { get; set; } // "1668907464",
+ public string price_min { get; set; } // 8941,
+ public string price_max { get; set; } // 8941,
+ }
+}
diff --git a/AllBase/Model/Result/PDDResult/PddBuyerOrderInfoLite.cs b/AllBase/Model/Result/PDDResult/PddBuyerOrderInfoLite.cs
index 3e89925..40d1d80 100644
--- a/AllBase/Model/Result/PDDResult/PddBuyerOrderInfoLite.cs
+++ b/AllBase/Model/Result/PDDResult/PddBuyerOrderInfoLite.cs
@@ -24,6 +24,7 @@ namespace AllBase.Model.Result.PDDResult
{
if (outExpressCompanyMsg == null) return "";
if (outExpressCompanyMsg.Contains("邮政快递包裹")) return "EMS";
+ if (outExpressCompanyMsg.Contains("邮政电商标快")) return "EMS";
if (outExpressCompanyMsg.Contains("极兔速递")) return "JTSD";
if (outExpressCompanyMsg.Contains("申通快递")) return "STO";
if (outExpressCompanyMsg.Contains("韵达快递")) return "YD";
@@ -39,6 +40,7 @@ namespace AllBase.Model.Result.PDDResult
{
if (outExpressCompanyMsg == null) return "";
if (outExpressCompanyMsg.Contains("邮政快递包裹")) return "邮政快递包裹";
+ if (outExpressCompanyMsg.Contains("邮政电商标快")) return "邮政电商标快";
if (outExpressCompanyMsg.Contains("极兔速递")) return "极兔速递";
if (outExpressCompanyMsg.Contains("申通快递")) return "申通快递";
if (outExpressCompanyMsg.Contains("韵达快递")) return "韵达快递";
diff --git a/AllBase/Model/Result/PDDResult/PddClientInfo.cs b/AllBase/Model/Result/PDDResult/PddClientInfo.cs
new file mode 100644
index 0000000..7e29728
--- /dev/null
+++ b/AllBase/Model/Result/PDDResult/PddClientInfo.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AllBase.Model.Result.PDDResult
+{
+ public class PddClientInfo
+ {
+ public string describe { get; set; } // "小红椒商品管理"
+ public string client_id { get; set; } // "48ccccaaaa33335555ccccbbbb6666b5"
+ public string client_secret { get; set; } // "b2aaaaeeee6666222233332222ffff5555aaaa97"
+ public int? market_id { get; set; } // 84691
+ public string redirect_uri { get; set; } // "http%3A%2F%2Fxtjpd.aabbccddeeff.vip%2Fpdd_token.html"
+ public bool? is_current { get; set; } // "true"
+ }
+}
diff --git a/AllBase/Model/Result/ShopLoginInfo.cs b/AllBase/Model/Result/ShopLoginInfo.cs
index 9b0bf5b..1eb157a 100644
--- a/AllBase/Model/Result/ShopLoginInfo.cs
+++ b/AllBase/Model/Result/ShopLoginInfo.cs
@@ -103,7 +103,7 @@ namespace AllBase.Model.Result
public string RefreshToken { get { return (CurrentAuthInfo?.RefreshToken).ParseToString(); } }
public string AppKey { get { return (CurrentAuthInfo?.AppKey).ParseToString(); } }
public string AppSecret { get { return (CurrentAuthInfo?.AppSecret).ParseToString(); } }
- public DateTime AuthAddTime { get { return CurrentAuthInfo?.AddTime == null ? new DateTime() : CurrentAuthInfo.AddTime; } }
+ public DateTime AuthUpdateTime { get { return CurrentAuthInfo?.UpdateTime == null ? new DateTime() : CurrentAuthInfo.UpdateTime; } }
public DateTime AuthExpiresTime { get { return CurrentAuthInfo?.ExpiresTime == null ? new DateTime() : CurrentAuthInfo.ExpiresTime; } }
///
/// 店铺运费模板
@@ -209,7 +209,7 @@ namespace AllBase.Model.Result
public string AppKey { get; set; } = "";
public string AppSecret { get; set; } = "";
public DateTime ExpiresTime { get; set; }
- public DateTime AddTime { get; set; } = DateTime.MinValue;
+ public DateTime UpdateTime { get; set; } = DateTime.MinValue;
public string ApiAuthStatus { get; set; } = "未授权";
}
diff --git a/AllBase/Model/Result/VDianShopLoginInfo.cs b/AllBase/Model/Result/VDianShopLoginInfo.cs
index c86d497..6263fe8 100644
--- a/AllBase/Model/Result/VDianShopLoginInfo.cs
+++ b/AllBase/Model/Result/VDianShopLoginInfo.cs
@@ -8,6 +8,7 @@ namespace AllBase.Model.Result
{
public class VDianShopLoginInfo
{
+ public int DbId { get; set; }
public string user_name { get; set; }
public string ShopName { get; set; }
diff --git a/KJDService/KJD_WebService/BLL/BXX/BXXProductManage.cs b/KJDService/KJD_WebService/BLL/BXX/BXXProductManage.cs
index 07ebd15..5190f36 100644
--- a/KJDService/KJD_WebService/BLL/BXX/BXXProductManage.cs
+++ b/KJDService/KJD_WebService/BLL/BXX/BXXProductManage.cs
@@ -149,6 +149,7 @@ namespace KJD_Web.BLL.BXX
string sku_secret_json = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sku_secret_json"))?.Replace("'", "\\'");
string wx_img_map_json = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "wx_img_map_json"))?.Replace("'", "\\'");
string problem_prod_data = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "problem_prod_data"))?.Replace("'", "\\'");
+ string is_relation = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "is_relation"))?.Replace("'", "\\'");
if (string.IsNullOrEmpty(user_name))
{
@@ -226,6 +227,8 @@ namespace KJD_Web.BLL.BXX
sql += " p.wx_img_map_json=@wx_img_map_json,";
if (!problem_prod_data.IsNullOrEmpty())
sql += " p.problem_prod_data=" + problem_prod_data + ",";
+ if (!is_relation.IsNullOrEmpty())
+ sql += " p.is_relation=" + is_relation + ",";
sql += " p.mdy_time='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',";
sql = sql.TrimEnd(',');
sql += " where spu_id='" + spu_id + "';";
@@ -471,6 +474,7 @@ namespace KJD_Web.BLL.BXX
var real_coid = RegexUtils.GetStringQuery(ref inputData, "real_coid")?.Replace("'", "\\'");
var has_wx_format = RegexUtils.GetStringQuery(ref inputData, "has_wx_format")?.Replace("'", "\\'");
var problem_prod_data = RegexUtils.GetStringQuery(ref inputData, "problem_prod_data")?.Replace("'", "\\'");
+ var is_relation = RegexUtils.GetStringQuery(ref inputData, "is_relation")?.Replace("'", "\\'");
var start_time = RegexUtils.GetStringQuery(ref inputData, "start_time")?.Replace("'", "\\'");
var end_time = RegexUtils.GetStringQuery(ref inputData, "end_time")?.Replace("'", "\\'");
@@ -517,7 +521,8 @@ namespace KJD_Web.BLL.BXX
where += " and p.special_prod_type ='" + special_prod_type + "'";
if (!string.IsNullOrWhiteSpace(search_spu))
- where += " and p.spu_id like '%" + search_spu + "%'";
+ //where += " and p.spu_id like '%" + search_spu + "%'";
+ where += " and p.spu_id like '" + search_spu + "%'";
if (!string.IsNullOrWhiteSpace(search_skc))
where += " and p.skc_id like '%" + search_skc + "%'";
if (!string.IsNullOrWhiteSpace(search_cat))
@@ -599,6 +604,10 @@ namespace KJD_Web.BLL.BXX
else
where += " and p.problem_prod_data='" + problem_prod_data + "'";
}
+ if (!string.IsNullOrEmpty(is_relation))
+ {
+ where += " and p.is_relation=" + is_relation;
+ }
if (start_time != null && end_time != null)
{
where += " and p.mdy_time between '" + start_time + "' and '" + end_time + "'";
@@ -627,7 +636,7 @@ namespace KJD_Web.BLL.BXX
sql = "select p.id,p.from_shop_id,p.spu_id,p.skc_id,p.main_cat_id,p.main_cat_name,p.cat_id,p.cat_name,p.price_text,p.ext_code,p.product_name," +
" p.main_img,p.notes,p.add_time,p.mdy_time,p.select_total_count,p.fission_words,p.head_words,p.end_words,p.sku_img_replace_id,p.group," +
" p.product_get_type,p.wx_safe_status,p.sale_count,p.sale_count_text,p.special_prod_type,p.from_shop_name,p.wx_cat_1,p.wx_cat_2,p.wx_cat_3," +
- " p.wx_cat_leaf,p.send_to_out_server,p.secret_spu_id,p.real_coid,p.real_spu_id," +
+ " p.wx_cat_leaf,p.send_to_out_server,p.secret_spu_id,p.real_coid,p.real_spu_id,p.is_relation," +
" s.img_url,e.ext_code_price" +
" FROM bxx.product p " +
" left join bxx.sku_img_replace s ON p.sku_img_replace_id=s.id" +
@@ -637,7 +646,7 @@ namespace KJD_Web.BLL.BXX
sql = "SELECT p.id,p.from_shop_id,p.spu_id,p.skc_id,p.main_cat_id,p.main_cat_name,p.cat_id,p.cat_name,p.price_text,p.ext_code,p.product_name," +
" p.main_img,p.notes,p.add_time,p.mdy_time,p.select_total_count,p.fission_words,p.head_words,p.end_words,p.sku_img_replace_id,p.group," +
" p.product_get_type,p.wx_safe_status,p.sale_count,p.sale_count_text,p.special_prod_type,p.from_shop_name,p.wx_cat_1,p.wx_cat_2,p.wx_cat_3," +
- " p.wx_cat_leaf,p.send_to_out_server,p.secret_spu_id,p.real_coid,p.real_spu_id," +
+ " p.wx_cat_leaf,p.send_to_out_server,p.secret_spu_id,p.real_coid,p.real_spu_id,p.is_relation," +
" s.img_url,COUNT(se.id) AS select_count,e.ext_code_price" +
" FROM bxx.product p left join bxx.sku_img_replace s ON p.sku_img_replace_id=s.id LEFT JOIN bxx.product_select se ON p.id=se.out_product_id AND se.shop_id='" + select_shop_id + "' " +
" LEFT JOIN bxx.ext_code_price e ON p.ext_code=e.ext_code" +
@@ -707,6 +716,7 @@ namespace KJD_Web.BLL.BXX
secret_spu_id = row["secret_spu_id"].IsNullOrEmpty() ? null : row["secret_spu_id"].ParseToString(),
real_coid = row["real_coid"].IsNullOrEmpty() ? null : row["real_coid"].ParseToString(),
real_spu_id = row["real_spu_id"].IsNullOrEmpty() ? null : row["real_spu_id"].ParseToString(),
+ is_relation = row["is_relation"].ParseToInt(),
};
if (isDetail)
{
@@ -1362,10 +1372,11 @@ namespace KJD_Web.BLL.BXX
var wx_safe_status = RegexUtils.GetStringQuery(ref inputData, "wx_safe_status")?.Replace("'", "\\'");
var special_prod_type = RegexUtils.GetStringQuery(ref inputData, "special_prod_type")?.Replace("'", "\\'");
var is_supplier_prod_ok = RegexUtils.GetStringQuery(ref inputData, "is_supplier_prod_ok")?.Replace("'", "\\'");
- var is_not_count = (RegexUtils.GetStringQuery(ref inputData, "is_not_count")?.Replace("'", "\\'")).ParseToBool();
- var prod_count = (RegexUtils.GetStringQuery(ref inputData, "prod_count")?.Replace("'", "\\'")).ParseToInt();
- var add_days_less = RegexUtils.GetStringQuery(ref inputData, "add_days_less")?.Replace("'", "\\'").ParseToNullableInt();
- var has_wx_format = RegexUtils.GetStringQuery(ref inputData, "has_wx_format")?.Replace("'", "\\'").ParseToString();
+ var is_not_count = RegexUtils.GetStringQuery(ref inputData, "is_not_count").ParseToBool(); // 不计数
+ var prod_count = RegexUtils.GetStringQuery(ref inputData, "prod_count").ParseToInt();
+ var add_days_less = RegexUtils.GetStringQuery(ref inputData, "add_days_less").ParseToNullableInt();
+ var has_wx_format = RegexUtils.GetStringQuery(ref inputData, "has_wx_format")?.Replace("'", "\\'");
+ var is_relation = RegexUtils.GetStringQuery(ref inputData, "is_relation").ParseToNullableInt();
int page = RegexUtils.GetStringQuery(ref inputData, "page").ParseToInt();
int page_size = RegexUtils.GetStringQuery(ref inputData, "page_size").ParseToInt(50);
@@ -1439,6 +1450,10 @@ namespace KJD_Web.BLL.BXX
{
where += " and has_wx_format = '" + has_wx_format + "'";
}
+ if (is_relation != null)
+ {
+ where += " and is_relation = " + is_relation;
+ }
sql += where;
int count = prod_count;
@@ -1480,7 +1495,7 @@ namespace KJD_Web.BLL.BXX
sql = "select p.id,p.from_shop_id,p.spu_id,p.skc_id,p.main_cat_id,p.main_cat_name,p.cat_id,p.cat_name,p.price_text,p.ext_code," +
" p.product_name,p.main_img,p.group,p.notes,p.add_time,p.mdy_time,p.product_get_type," +
" p.wx_safe_status,p.special_prod_type,p.wx_cat_1,p.wx_cat_2,p.wx_cat_3,p.send_to_out_server," +
- " p.wx_cat_leaf" +
+ " p.wx_cat_leaf,p.is_relation" +
" from bxx.product p where p.is_del=0";
//where子句
//sql += where;
@@ -1528,6 +1543,7 @@ namespace KJD_Web.BLL.BXX
wx_safe_status = row["wx_safe_status"].ToString(),
special_prod_type = row["special_prod_type"].ToString(),
send_to_out_server = row["send_to_out_server"].ParseToInt(),
+ is_relation = row["is_relation"].ParseToInt(),
};
productLst.Add(prod);
}
@@ -2996,6 +3012,11 @@ namespace KJD_Web.BLL.BXX
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
+ ///
+ /// 随机工厂商品
+ ///
+ ///
+ ///
public string GetRandomCompanyProductConfig(string inputData)
{
var timeCalc = DateTime.Now;
@@ -3043,6 +3064,131 @@ namespace KJD_Web.BLL.BXX
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
+
+ public string AddRelation(string inputData)
+ {
+ if (!string.IsNullOrEmpty(inputData))
+ {
+ var time = RegexUtils.GetStringQuery(ref inputData, "time").ParseToInt();
+ string time1 = RegexUtils.GetStringQuery(ref inputData, "code");
+ if (time1 != EncrypUtil.Encryption(time))
+ return "{\"code\":50000,\"msg\":\"校验失败\"}";
+
+ var up_spu_id = RegexUtils.GetStringQuery(ref inputData, "up_spu_id")?.Replace("'", "\\'");
+ if (string.IsNullOrEmpty(up_spu_id))
+ {
+ return "{\"code\":500,\"msg\":\"缺少上家编号\"}";
+ }
+ var index = RegexUtils.GetStringQuery(ref inputData, "index").ParseToNullableLong();
+ if (index == null)
+ index = Math.Abs(up_spu_id.GetHashCode()) % 128;
+ var up_goods_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "up_goods_name"));
+ if (string.IsNullOrEmpty(up_goods_name))
+ {
+ return "{\"code\":500,\"msg\":\"缺少上家商品名称\"}";
+ }
+ var from_site = RegexUtils.GetStringQuery(ref inputData, "from_site")?.Replace("'", "\\'");
+ if (string.IsNullOrEmpty(from_site))
+ {
+ return "{\"code\":500,\"msg\":\"缺少关联商品平台\"}";
+ }
+ var goods_id = RegexUtils.GetStringQuery(ref inputData, "goods_id")?.Replace("'", "\\'");
+ if (string.IsNullOrEmpty(goods_id))
+ {
+ return "{\"code\":500,\"msg\":\"缺少关联商品编号\"}";
+ }
+ var shop_id = RegexUtils.GetStringQuery(ref inputData, "shop_id")?.Replace("'", "\\'");
+ if (string.IsNullOrEmpty(shop_id))
+ {
+ return "{\"code\":500,\"msg\":\"缺少关联店铺编号\"}";
+ }
+ var price_max = RegexUtils.GetStringQuery(ref inputData, "price_max")?.Replace("'", "\\'");
+ if (string.IsNullOrEmpty(price_max))
+ {
+ return "{\"code\":500,\"msg\":\"缺少关联最高价格\"}";
+ }
+ var price_min = RegexUtils.GetStringQuery(ref inputData, "price_min")?.Replace("'", "\\'");
+ if (string.IsNullOrEmpty(price_min))
+ {
+ return "{\"code\":500,\"msg\":\"缺少关联最低价格\"}";
+ }
+
+ string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
+ MysqlUtils mySql = new MysqlUtils(conn);
+
+ string sql = "insert into bxx_relation.out_prod_relation_" + index.ParseToString().PadLeft(4, '0') +
+ " (up_spu_id,up_goods_name,from_site,goods_id,shop_id,price_min,price_max) " +
+ " values ('" + up_spu_id + "',@up_goods_name,'" + from_site + "','" +
+ goods_id + "'," + shop_id + "," + price_min + "," + price_max + ");";
+ List paramLst = new List();
+ paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@up_goods_name", Value = up_goods_name, });
+ mySql.ExecuteNonQuery(sql, paramLst.ToArray());
+ mySql.Close();
+ if (mySql.Message.IsNullOrEmpty())
+ {
+ return "{\"code\":200,\"msg\":\"成功\"}";
+ }
+ else
+ {
+ return "{\"code\":500,\"msg\":\"失败:" + mySql.Message + "\"}";
+ }
+ }
+ return "{\"code\":19999,\"msg\":\"输入为空\"}";
+ }
+
+ public string GetRelation(string inputData)
+ {
+ if (!string.IsNullOrEmpty(inputData))
+ {
+ var time = RegexUtils.GetStringQuery(ref inputData, "time").ParseToInt();
+ string time1 = RegexUtils.GetStringQuery(ref inputData, "code");
+ if (time1 != EncrypUtil.Encryption(time))
+ return "{\"code\":50000,\"msg\":\"校验失败\"}";
+
+ var up_spu_id = RegexUtils.GetStringQuery(ref inputData, "up_spu_id")?.Replace("'", "\\'");
+ if (string.IsNullOrEmpty(up_spu_id))
+ {
+ return "{\"code\":500,\"msg\":\"缺少来源商品编号\"}";
+ }
+ var index = RegexUtils.GetStringQuery(ref inputData, "index").ParseToNullableLong();
+ if (index == null)
+ index = Math.Abs(up_spu_id.GetHashCode()) % 128;
+
+ string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
+ MysqlUtils mySql = new MysqlUtils(conn);
+
+ string sql = "select * from bxx_relation.out_prod_relation_" + index.ParseToString().PadLeft(4, '0') +
+ " where up_spu_id='" + up_spu_id + "' limit 20;";
+ var dt = mySql.ExecuteDataTable(sql);
+ mySql.Close();
+ if (mySql.Message.IsNullOrEmpty())
+ {
+ JArray jArr = new JArray();
+ foreach (DataRow row in dt.Rows)
+ {
+ JObject jObj = new JObject();
+ jObj["id"] = row["id"].ParseToInt();
+ jObj["up_spu_id"] = row["up_spu_id"].ToString();
+ jObj["up_goods_name"] = row["up_goods_name"].ToString();
+ jObj["from_site"] = row["from_site"].ToString();
+ jObj["goods_id"] = row["goods_id"].ToString();
+ jObj["shop_id"] = row["shop_id"].ToString();
+ jObj["price_min"] = row["price_min"].ParseToInt();
+ jObj["price_max"] = row["price_max"].ParseToInt();
+ jObj["add_time"] = row["add_time"].ParseToString().ParseToDateTime();
+ jArr.Add(jObj);
+ }
+ JsonSerializerSettings jsonSetting = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore };
+ var data = JsonUtils.SerializeObjectToString(jArr, jsonSetting);
+ return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"count\":" + jArr.Count + "}";
+ }
+ else
+ {
+ return "{\"code\":500,\"msg\":\"失败:" + mySql.Message + "\"}";
+ }
+ }
+ return "{\"code\":19999,\"msg\":\"输入为空\"}";
+ }
}
}
diff --git a/KJDService/KJD_WebService/BLL/BXX/BXXShopManage.cs b/KJDService/KJD_WebService/BLL/BXX/BXXShopManage.cs
index f23a4d1..0f04388 100644
--- a/KJDService/KJD_WebService/BLL/BXX/BXXShopManage.cs
+++ b/KJDService/KJD_WebService/BLL/BXX/BXXShopManage.cs
@@ -1,8 +1,10 @@
using KJD_Web.Model;
using KJD_Web.Model.ShopModel;
using KJD_Web.Utils;
+using MySql.Data.MySqlClient;
using MySqlX.XDevAPI;
using NaiBa.Util.Extension;
+using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Data;
@@ -10,11 +12,242 @@ using System.Drawing;
using System.Linq;
using System.Web;
using System.Web.Security;
+using System.Web.UI.WebControls;
namespace KJD_Web.BLL.BXX
{
public class BXXShopManage
{
+ public string GetPddClientInfo(string inputData)
+ {
+ if (!string.IsNullOrEmpty(inputData))
+ {
+ var mobile = RegexUtils.GetStringQuery(ref inputData, "mobile")?.Replace("'", "\\'");
+ var password = RegexUtils.GetStringQuery(ref inputData, "password")?.Replace("'", "\\'");
+ int r2 = 0;
+ int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
+
+ string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
+ MysqlUtils mySql = new MysqlUtils(conn);
+ string sql = "select * from bxx.user where user_name='"
+ + mobile + "' and password='" + password + "'";
+
+ var dt = mySql.ExecuteDataTable(sql);
+ mySql.Close();
+ if (dt == null)
+ {
+ return "{\"code\":500,\"msg\":\"用户不存在\"}";
+ }
+
+ JArray jArr = new JArray();
+
+ JObject obj1 = new JObject();
+ obj1["describe"] = "貔貅管家";
+ obj1["client_id"] = "ad502ec19e0c49ab9df14f83494e153c";
+ obj1["client_secret"] = "bd52aba51737d03fc073711d386b3b0779d010ad";
+ obj1["market_id"] = 84862;
+ obj1["redirect_uri"] = "http%3A%2F%2Fpo.e57.cn%2Flogin%3Fsource%3Dpdd_code";
+ obj1["is_current"] = false;
+ jArr.Add(obj1);
+
+ JObject obj2 = new JObject();
+ obj2["describe"] = "小红椒商品管理";
+ obj2["client_id"] = "48e76c60853d47d8a4e2e631b6db26b5";
+ obj2["client_secret"] = "b2a5f9eeb36d192ed035f023eaf9ce5280aac397";
+ obj2["market_id"] = 84690;
+ obj2["redirect_uri"] = "http%3A%2F%2Fxtjpd.jiaotian.vip%2Fpdd_token.html";
+ obj2["is_current"] = true;
+ jArr.Add(obj2);
+
+ return "{\"code\":200,\"msg\":\"success\",\"data\":" + JsonUtils.SerializeObject(jArr) + "}";
+ }
+ return "{\"code\":19999,\"msg\":\"输入为空\"}";
+ }
+
+ public string GetShopClientInfo(string inputData, bool isAdmin = false)
+ {
+ if (!string.IsNullOrEmpty(inputData))
+ {
+ var time = 0;
+ int.TryParse(RegexUtils.GetStringQuery(ref inputData, "time"), out time);
+ string time1 = RegexUtils.GetStringQuery(ref inputData, "code");
+ if (time1 != EncrypUtil.Encryption(time))
+ return "{\"code\":50000,\"msg\":\"校验失败\"}";
+
+ var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
+ var password = RegexUtils.GetStringQuery(ref inputData, "password");
+ if (string.IsNullOrEmpty(user_name))
+ {
+ return "{\"code\":50001,\"msg\":\"没有用户名\"}";
+ }
+
+ var shop_ids = RegexUtils.GetStringQuery(ref inputData, "shop_ids")?.Replace("'", "");
+ if (!string.IsNullOrWhiteSpace(shop_ids))
+ {
+ List shopIdLst = shop_ids.Split(',').ToList();
+ shop_ids = "'" + string.Join("','", shopIdLst) + "'";
+ }
+
+ var page = RegexUtils.GetStringQuery(ref inputData, "page").ParseToInt();
+ var page_size = RegexUtils.GetStringQuery(ref inputData, "page_size").ParseToInt();
+
+ if (page_size == 0)
+ page_size = 500;
+
+
+ string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
+ MysqlUtils mySql = new MysqlUtils(conn);
+
+ string sql = "SELECT COUNT(s.id) FROM bxx.shop_api_auth s WHERE 1=1";
+
+ //where子句
+ string where = "";
+ if (!string.IsNullOrWhiteSpace(shop_ids))
+ where += " and s.ShopId in (" + shop_ids + ")";
+ sql += where;
+
+ var count = mySql.ExecuteRowCount(sql);
+
+ DataTable dt;
+ if (count == 0)
+ {
+ dt = new DataTable();
+ }
+ else
+ {
+ sql = "SELECT * FROM bxx.shop_api_auth s WHERE 1=1";
+
+ sql += where; // where 子句
+
+ sql += " ORDER BY s.id DESC";
+ sql += " LIMIT " + Math.Max(page - 1, 0) * page_size + "," + page_size;
+ dt = mySql.ExecuteDataTable(sql);
+ }
+
+ mySql.Close();
+
+ if (!string.IsNullOrEmpty(mySql.Message))
+ {
+ return "{\"code\":50001,\"msg\":\"查询失败:" + mySql.Message + "\"}";
+ }
+
+ if (dt != null)
+ {
+ List shopAuthList = new List();
+ foreach (DataRow row in dt.Rows)
+ {
+ AuthInfo auth = new AuthInfo
+ {
+ id = Convert.ToInt32(row["id"]),
+ AccessToken = row["AccessToken"].ToString(),
+ ApiAuthStatus = row["ApiAuthStatus"].ToString(),
+ AppKey = row["AppKey"].ToString(),
+ AppSecret = row["AppSecret"].ToString(),
+ ExpiresTime = row["ExpiresTime"].ParseToString().ParseToDateTime(),
+ RefreshToken = row["RefreshToken"].ToString(),
+ ShopId = row["ShopId"].ToString(),
+ UpdateTime = row["UpdateTime"].ParseToString().ParseToDateTime(),
+ };
+ shopAuthList.Add(auth);
+ }
+ var data = JsonUtils.SerializeObjectToString(shopAuthList);
+ return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"count\":" + count + "}";
+ }
+ }
+ return "{\"code\":19999,\"msg\":\"未知错误\"}";
+ }
+
+ public string AddMdyShopClientInfo(string inputData)
+ {
+ if (!string.IsNullOrEmpty(inputData))
+ {
+ var time = RegexUtils.GetStringQuery(ref inputData, "time").ParseToInt();
+ string time1 = RegexUtils.GetStringQuery(ref inputData, "code");
+ if (time1 != EncrypUtil.Encryption(time))
+ return "{\"code\":50000,\"msg\":\"校验失败\"}";
+
+ var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name")?.Replace("'", "\\'");
+ if (string.IsNullOrEmpty(user_name))
+ {
+ return "{\"code\":50001,\"msg\":\"没有用户名\"}";
+ }
+
+ string ShopId = RegexUtils.GetStringQuery(ref inputData, "ShopId")?.Replace("'", "\\'");
+ string AppKey = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "AppKey"))?.Replace("'", "\\'");
+ string AccessToken = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "AccessToken"))?.Replace("'", "\\'");
+ string RefreshToken = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "RefreshToken"))?.Replace("'", "\\'");
+ string AppSecret = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "AppSecret"))?.Replace("'", "\\'");
+ string ExpiresTime = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "ExpiresTime"))?.Replace("'", "\\'");
+ string ApiAuthStatus = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "ApiAuthStatus"))?.Replace("'", "\\'");
+ if (string.IsNullOrEmpty("ShopId"))
+ return "{\"code\":50001,\"msg\":\"没有店铺编号\"}";
+ if (string.IsNullOrEmpty("AppKey"))
+ return "{\"code\":50001,\"msg\":\"没有Api编号\"}";
+ if (string.IsNullOrEmpty("AccessToken"))
+ return "{\"code\":50001,\"msg\":\"没有令牌信息\"}";
+
+ string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
+ MysqlUtils mySql = new MysqlUtils(conn);
+
+ string sql = "SELECT ShopId,AppKey FROM `bxx`.`shop_api_auth` where ShopId='" + ShopId + "' and AppKey='" + AppKey + "'";
+
+ string where = "";
+ sql += where;
+
+ var dt = mySql.ExecuteDataTable(sql);
+ mySql.Close();
+
+ if (dt != null)
+ {
+ conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
+ mySql = new MysqlUtils(conn);
+ if (dt.Rows.Count == 0)
+ {
+ sql = "INSERT INTO `bxx`.`shop_api_auth` (ShopId,AppKey,AccessToken,RefreshToken,AppSecret,ExpiresTime,ApiAuthStatus)" +
+ " VALUES (@ShopId,@AppKey,@AccessToken,@RefreshToken,@AppSecret,@ExpiresTime,@ApiAuthStatus);";
+ }
+ else
+ {
+ sql = "UPDATE `bxx`.`shop_api_auth` SET AccessToken=@AccessToken";
+ if (RefreshToken != null)
+ sql += ", RefreshToken=@RefreshToken ";
+ if (AppSecret != null)
+ sql += ", AppSecret=@AppSecret ";
+ if (ExpiresTime != null)
+ sql += ", ExpiresTime=@ExpiresTime ";
+ if (ApiAuthStatus != null)
+ sql += ", ApiAuthStatus=@ApiAuthStatus ";
+ sql += " WHERE ShopId=@ShopId and AppKey=@AppKey;";
+ }
+
+ List paramLst = new List();
+ paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "ShopId", Value = ShopId, });
+ paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "AppKey", Value = AppKey, });
+ paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "AccessToken", Value = AccessToken.ParseToString(), });
+ paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "RefreshToken", Value = RefreshToken.ParseToString(), });
+ paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "AppSecret", Value = AppSecret.ParseToString(), });
+ paramLst.Add(new MySqlParameter() { DbType = DbType.DateTime, ParameterName = "ExpiresTime", Value = ExpiresTime.ParseToDateTime(), });
+ paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "ApiAuthStatus", Value = ApiAuthStatus, });
+
+ mySql.ExecuteNonQuery(sql, paramLst.ToArray());
+ mySql.Close();
+ if (string.IsNullOrEmpty(mySql.Message))
+ {
+ return "{\"code\":200,\"msg\":\"success\",\"data\":\"\"}";
+ }
+ else
+ {
+ return "{\"code\":50003,\"msg\":\"" + mySql.Message + "\",\"data\":\"\"}";
+ }
+ }
+ else
+ {
+ return "{\"code\":50003,\"msg\":\"" + mySql.Message + "\",\"data\":\"\"}";
+ }
+ }
+ return "{\"code\":19999,\"msg\":\"输入为空\"}";
+ }
+
public string GetShop(string inputData, bool isAdmin = false)
{
if (!string.IsNullOrEmpty(inputData))
@@ -919,10 +1152,10 @@ namespace KJD_Web.BLL.BXX
}
else
{
- sql = "SELECT s.id,s.login_name,s.login_pass,s.cookie,s.cookie2,s.anti_contents,s.pddid,s.mall_id,s.shop_id,s.shop_account,s.sub_user_name," +
- "s.user_name,s.company_name,s.notes,s.login_status,s.login_status2,c.add_product_remaining,c.add_product_month," +
+ sql = "SELECT s.id,s.login_name,s.login_pass,s.cookie,s.cookie2,s.wd_token,s.mall_id,s.shop_id,s.shop_account,s.sub_user_name," +
+ "s.user_name,s.company_name,s.notes,s.login_status,s.login_status2," +
"s.add_time,s.mdy_time,s.add_sub_sa_time,s.operate_sub_sa_name";
- sql += " FROM weidian.shop s LEFT JOIN weidian.shop_add_prod_count c ON s.shop_id=c.shop_id WHERE 1=1";
+ sql += " FROM weidian.shop s WHERE 1=1";
sql += where; // where 子句
@@ -932,6 +1165,10 @@ namespace KJD_Web.BLL.BXX
}
mySql.Close();
+ if (!string.IsNullOrEmpty(mySql.Message))
+ {
+ return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}";
+ }
if (dt != null)
{
List shopList = new List();
@@ -944,7 +1181,7 @@ namespace KJD_Web.BLL.BXX
login_pass = row["login_pass"].ToString(),
cookie = row["cookie"].ToString(),
cookie2 = row["cookie2"].ToString(),
- anti_contents = row["anti_contents"].ToString(),
+ wd_token = row["wd_token"].ToString(),
shop_id = row["shop_id"].ToString(),
shop_account = row["shop_account"].ToString(),
sub_user_name = row["sub_user_name"].ToString(),
@@ -953,10 +1190,7 @@ namespace KJD_Web.BLL.BXX
notes = row["notes"].ToString(),
login_status = row["login_status"].ToString(),
login_status2 = row["login_status2"].ToString(),
- add_product_remaining = row["add_product_remaining"].ParseToInt(),
- add_product_month = row["add_product_month"].ParseToInt(),
operate_sub_sa_name = row["operate_sub_sa_name"].ParseToString(),
- pddid = row["pddid"].ParseToString(),
mall_id = row["mall_id"].ParseToString(),
};
shopList.Add(shop);
@@ -981,7 +1215,7 @@ namespace KJD_Web.BLL.BXX
string sub_user_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sub_user_name"));
string cookie = RegexUtils.GetStringQuery(ref inputData, "cookie");
string cookie2 = RegexUtils.GetStringQuery(ref inputData, "cookie2");
- string anti_contents = RegexUtils.GetStringQuery(ref inputData, "anti_contents");
+ string wd_token = RegexUtils.GetStringQuery(ref inputData, "wd_token");
string shop_id = RegexUtils.GetStringQuery(ref inputData, "shop_id");
string mall_id = RegexUtils.GetStringQuery(ref inputData, "mall_id");
string shop_account = RegexUtils.GetStringQuery(ref inputData, "shop_account");
@@ -1011,12 +1245,13 @@ namespace KJD_Web.BLL.BXX
if (exist > 0)
{
mySql.Close();
- return "{\"code\":500,\"msg\":\"店铺" + login_name + " " + shop_account + "已存在\"}";
+ //return "{\"code\":500,\"msg\":\"店铺" + login_name + " " + shop_account + "已存在\"}";
+ return MdyWeiDianShop(inputData, isAdmin);
}
- sql = "insert into weidian.shop (login_name,login_pass,cookie,cookie2,anti_contents,shop_account,shop_id," +
+ sql = "insert into weidian.shop (login_name,login_pass,cookie,cookie2,wd_token,shop_account,shop_id," +
"mall_id,sub_user_name,user_name,group_name,notes,add_time,mdy_time) " +
- "values ('" + login_name + "','" + login_pass + "','" + cookie + "','" + cookie2 + "','" + anti_contents + "','" + shop_account + "','" + shop_id +
+ "values ('" + login_name + "','" + login_pass + "','" + cookie + "','" + cookie2 + "','" + wd_token + "','" + shop_account + "','" + shop_id +
"','" + mall_id + "','" + sub_user_name + "','" + user_name + "','" + group_name + "','" + notes + "','" +
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','" +
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "');";
@@ -1026,6 +1261,8 @@ namespace KJD_Web.BLL.BXX
{
return "{\"code\":200,\"msg\":\"success\"}";
}
+ else
+ return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}";
}
return "{\"code\":19999,\"msg\":\"未知错误\"}";
}
@@ -1042,7 +1279,7 @@ namespace KJD_Web.BLL.BXX
string sub_user_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sub_user_name"));
string cookie = RegexUtils.GetStringQuery(ref inputData, "cookie");
string cookie2 = RegexUtils.GetStringQuery(ref inputData, "cookie2");
- string anti_contents = RegexUtils.GetStringQuery(ref inputData, "anti_contents");
+ string wd_token = RegexUtils.GetStringQuery(ref inputData, "wd_token");
string new_shop_id = RegexUtils.GetStringQuery(ref inputData, "new_shop_id");
string old_shop_id = RegexUtils.GetStringQuery(ref inputData, "shop_id");
string mall_id = RegexUtils.GetStringQuery(ref inputData, "mall_id");
@@ -1072,8 +1309,8 @@ namespace KJD_Web.BLL.BXX
sql += " cookie='" + cookie + "',";
if (cookie2 != null)
sql += " cookie2='" + cookie2 + "',";
- if (anti_contents != null)
- sql += " anti_contents='" + anti_contents + "',";
+ if (wd_token != null)
+ sql += " wd_token='" + wd_token + "',";
if (new_shop_id != null)
sql += " shop_id='" + new_shop_id + "',";
if (mall_id != null)
@@ -1093,6 +1330,95 @@ namespace KJD_Web.BLL.BXX
if (!string.IsNullOrEmpty(old_shop_id))
sql += " and shop_id='" + old_shop_id + "'";
+ var rst = mySql.ExecuteNonQuery(sql);
+ mySql.Close();
+ if (rst)
+ {
+ return "{\"code\":200,\"msg\":\"success\"}";
+ }
+ else
+ {
+ return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}";
+ }
+ }
+ return "{\"code\":19999,\"msg\":\"未知错误\"}";
+ }
+
+ public string MdyWeiDianShopCookie(string inputData, bool isAdmin = false)
+ {
+ if (!string.IsNullOrEmpty(inputData))
+ {
+ string user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
+ if (isAdmin)
+ user_name = RegexUtils.GetStringQuery(ref inputData, "shop_user_name");
+ string shop_id = RegexUtils.GetStringQuery(ref inputData, "shop_id");
+ string wd_token = RegexUtils.GetStringQuery(ref inputData, "wd_token");
+ string cookie = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "cookie"));
+ string login_status = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "login_status"));
+
+ int r2 = 0;
+ int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
+
+ if (string.IsNullOrEmpty(user_name))
+ {
+ return "{\"code\":500,\"msg\":\"没有用户名\"}";
+ }
+ if (string.IsNullOrEmpty(shop_id))
+ {
+ return "{\"code\":501,\"msg\":\"没有店铺信息\"}";
+ }
+ if (string.IsNullOrEmpty(cookie) && string.IsNullOrEmpty(login_status))
+ {
+ return "{\"code\":501,\"msg\":\"cookie和登录状态不能全为空\"}";
+ }
+
+ string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
+ MysqlUtils mySql = new MysqlUtils(conn);
+ string sql = "update weidian.shop set";
+ if (cookie != null)
+ sql += " cookie='" + cookie + "',";
+ if (wd_token != null)
+ sql += " wd_token='" + wd_token + "',";
+ if (login_status != null)
+ sql += " login_status='" + login_status + "',";
+ sql = sql.TrimEnd(',');
+ sql += " where shop_id='" + shop_id + "'";
+
+ var rst = mySql.ExecuteNonQuery(sql);
+ mySql.Close();
+ if (rst)
+ {
+ return "{\"code\":200,\"msg\":\"success\"}";
+ }
+ }
+ return "{\"code\":19999,\"msg\":\"未知错误\"}";
+ }
+
+ public string DelWeiDianShop(string inputData, bool isAdmin = false)
+ {
+ if (!string.IsNullOrEmpty(inputData))
+ {
+ string user_name = RegexUtils.GetStringQuery(ref inputData, "user_name")?.Replace("'", "\\'");
+ if (isAdmin)
+ user_name = RegexUtils.GetStringQuery(ref inputData, "shop_user_name")?.Replace("'", "\\'");
+ string shop_id = RegexUtils.GetStringQuery(ref inputData, "shop_id")?.Replace("'", "\\'");
+
+ int r2 = 0;
+ int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
+
+ if (string.IsNullOrEmpty(user_name))
+ {
+ return "{\"code\":500,\"msg\":\"没有用户名\"}";
+ }
+ if (string.IsNullOrEmpty(shop_id))
+ {
+ return "{\"code\":501,\"msg\":\"没有指定要删除的店铺\"}";
+ }
+
+ string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
+ MysqlUtils mySql = new MysqlUtils(conn);
+ string sql = "delete from weidian.shop where user_name='" + user_name + "' and shop_id='" + shop_id + "'";
+
var rst = mySql.ExecuteNonQuery(sql);
mySql.Close();
if (rst)
diff --git a/KJDService/KJD_WebService/BLL/KJD/ToolManage.cs b/KJDService/KJD_WebService/BLL/KJD/ToolManage.cs
index e52e79f..8954bf5 100644
--- a/KJDService/KJD_WebService/BLL/KJD/ToolManage.cs
+++ b/KJDService/KJD_WebService/BLL/KJD/ToolManage.cs
@@ -33,6 +33,33 @@ namespace KJD_Web.BLL
public void CreateTable()
{
+ //string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
+ //MysqlUtils mySql = new MysqlUtils(conn);
+ //string sql = "";
+ //for (int i = 0; i < 128; i++)
+ //{
+ // sql = @"drop table if exists bxx_relation.out_prod_relation_" + i.ParseToString().PadLeft(4, '0') + ";\r\n";
+ // sql += @"CREATE TABLE bxx_relation.out_prod_relation_" + i.ParseToString().PadLeft(4, '0') + @" (
+ // `id` int NOT NULL AUTO_INCREMENT,
+ // `up_spu_id` varchar(50) NOT NULL COMMENT '源商品id信息,此字段为分表依据',
+ // `up_goods_name` varchar(255) NOT NULL COMMENT '源商品标题',
+ // `from_site` varchar(10) NOT NULL COMMENT '商品来源平台如pdd,tb,1688,vd(微店)等',
+ // `goods_id` varchar(50) NOT NULL COMMENT '映射商品id信息',
+ // `shop_id` varchar(50) NOT NULL COMMENT '上传到的店铺id',
+ // `price_min` int NOT NULL COMMENT '最低价,单位分',
+ // `price_max` int NOT NULL COMMENT '最高价,单位分',
+ // `add_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ // PRIMARY KEY(`id`),
+ // KEY `index_add_time` (`add_time`) USING BTREE,
+ // KEY `index_up_spu_id` (`up_spu_id`) USING BTREE,
+ // KEY `index_shop_id` (`shop_id`) USING BTREE,
+ // KEY `index_price_min` (`price_min`) USING BTREE,
+ // KEY `index_price_max` (`price_max`) USING BTREE
+ // ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '记录拼多多关联数据信息'";
+ // var rst = mySql.ExecuteNonQuery(sql);
+ //}
+ //mySql.Close();
+
//string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
//MysqlUtils mySql = new MysqlUtils(conn);
diff --git a/KJDService/KJD_WebService/BLL/WXXD/WXProductManage.cs b/KJDService/KJD_WebService/BLL/WXXD/WXProductManage.cs
index 933e5f9..3634a53 100644
--- a/KJDService/KJD_WebService/BLL/WXXD/WXProductManage.cs
+++ b/KJDService/KJD_WebService/BLL/WXXD/WXProductManage.cs
@@ -374,6 +374,7 @@ namespace KJD_Web.BLL.WXXD
public string WXAddSecretSpuIdShopIdMap(string inputData)
{
+ return "{\"code\":500,\"msg\":\"接口已作废\"}";
if (!string.IsNullOrEmpty(inputData))
{
var time = RegexUtils.GetStringQuery(ref inputData, "time").ParseToInt();
diff --git a/KJDService/KJD_WebService/BXXProductService.asmx.cs b/KJDService/KJD_WebService/BXXProductService.asmx.cs
index 4a2121f..f948978 100644
--- a/KJDService/KJD_WebService/BXXProductService.asmx.cs
+++ b/KJDService/KJD_WebService/BXXProductService.asmx.cs
@@ -539,5 +539,34 @@ namespace KJD_Web
Context.Response.Write(result);
Context.Response.End();
}
+
+ ///
+ /// 拼多多关联新增
+ ///
+ [WebMethod]
+ public void add_relation()
+ {
+ string jsontext = GetRequestJsonString();
+
+ var result = jsontext;
+ result = new BXXProductManage().AddRelation(jsontext);
+
+ Context.Response.Write(result);
+ Context.Response.End();
+ }
+ ///
+ /// 拼多多关联获取
+ ///
+ [WebMethod]
+ public void get_relation()
+ {
+ string jsontext = GetRequestJsonString();
+
+ var result = jsontext;
+ result = new BXXProductManage().GetRelation(jsontext);
+
+ Context.Response.Write(result);
+ Context.Response.End();
+ }
}
}
diff --git a/KJDService/KJD_WebService/BXXShopService.asmx.cs b/KJDService/KJD_WebService/BXXShopService.asmx.cs
index 9c97ddb..3473b16 100644
--- a/KJDService/KJD_WebService/BXXShopService.asmx.cs
+++ b/KJDService/KJD_WebService/BXXShopService.asmx.cs
@@ -49,6 +49,41 @@ namespace KJD_Web
}
}
+ [WebMethod]
+ public void get_pdd_client_info()
+ {
+ string jsontext = GetRequestJsonString();
+
+ var result = jsontext;
+ result = new BXXShopManage().GetPddClientInfo(jsontext);
+
+ Context.Response.Write(result);
+ Context.Response.End();
+ }
+ [WebMethod]
+ public void get_shop_client_info()
+ {
+ string jsontext = GetRequestJsonString();
+
+ var result = jsontext;
+ result = new BXXShopManage().GetShopClientInfo(jsontext);
+
+ Context.Response.Write(result);
+ Context.Response.End();
+ }
+ //WXAddMdyShopClientInfo
+ [WebMethod]
+ public void add_mdy_shop_client_info()
+ {
+ string jsontext = GetRequestJsonString();
+
+ var result = jsontext;
+ result = new BXXShopManage().AddMdyShopClientInfo(jsontext);
+
+ Context.Response.Write(result);
+ Context.Response.End();
+ }
+
[WebMethod]
public void get_shop_list()
{
@@ -240,5 +275,61 @@ namespace KJD_Web
Context.Response.Write(result);
Context.Response.End();
}
+
+ [WebMethod]
+ public void add_weidian_shop()
+ {
+ string jsontext = GetRequestJsonString();
+
+ var result = jsontext;
+ result = new BXXShopManage().AddWeiDianShop(jsontext);
+
+ Context.Response.Write(result);
+ Context.Response.End();
+ }
+ [WebMethod]
+ public void mdy_weidian_shop()
+ {
+ string jsontext = GetRequestJsonString();
+
+ var result = jsontext;
+ result = new BXXShopManage().MdyWeiDianShop(jsontext);
+
+ Context.Response.Write(result);
+ Context.Response.End();
+ }
+ [WebMethod]
+ public void mdy_weidian_shop_cookie()
+ {
+ string jsontext = GetRequestJsonString();
+
+ var result = jsontext;
+ result = new BXXShopManage().MdyWeiDianShopCookie(jsontext);
+
+ Context.Response.Write(result);
+ Context.Response.End();
+ }
+ [WebMethod]
+ public void get_weidian_shop()
+ {
+ string jsontext = GetRequestJsonString();
+
+ var result = jsontext;
+ result = new BXXShopManage().GetWeiDianShop(jsontext);
+
+ Context.Response.Write(result);
+ Context.Response.End();
+ }
+ [WebMethod]
+ public void del_weidian_shop()
+ {
+ string jsontext = GetRequestJsonString();
+
+ var result = jsontext;
+ result = new BXXShopManage().DelWeiDianShop(jsontext);
+
+ Context.Response.Write(result);
+ Context.Response.End();
+ }
}
}
diff --git a/KJDService/KJD_WebService/Model/DBProductResultParam.cs b/KJDService/KJD_WebService/Model/DBProductResultParam.cs
index 46df094..6561805 100644
--- a/KJDService/KJD_WebService/Model/DBProductResultParam.cs
+++ b/KJDService/KJD_WebService/Model/DBProductResultParam.cs
@@ -102,6 +102,7 @@ namespace KJD_Web.Model
public string real_spu_id { get; set; }
public string has_wx_format { get; set; }
public string problem_prod_data { get; set; }
+ public int is_relation { get; set; }
}
public class KJDDBProduct : DBProductResultParam
diff --git a/KJDService/KJD_WebService/Model/ShopModel/ShopParam.cs b/KJDService/KJD_WebService/Model/ShopModel/ShopParam.cs
index 300959b..ae9586f 100644
--- a/KJDService/KJD_WebService/Model/ShopModel/ShopParam.cs
+++ b/KJDService/KJD_WebService/Model/ShopModel/ShopParam.cs
@@ -25,6 +25,10 @@ namespace KJD_Web.Model.ShopModel
///
public string mall_id { get; set; }
///
+ /// 微店网页token
+ ///
+ public string wd_token { get; set; }
+ ///
/// 微信openId
///
public string openid { get; set; }
@@ -65,4 +69,17 @@ namespace KJD_Web.Model.ShopModel
public DateTime? jit_expire_time { get; set; }
public DateTime? add_time { get; set; }
}
+
+ public class AuthInfo
+ {
+ public int id { get; set; }
+ public string ShopId { get; set; } = "";
+ public string AccessToken { get; set; } = "";
+ public string RefreshToken { get; set; } = "";
+ public string AppKey { get; set; } = "";
+ public string AppSecret { get; set; } = "";
+ public DateTime ExpiresTime { get; set; }
+ public DateTime UpdateTime { get; set; } = DateTime.MinValue;
+ public string ApiAuthStatus { get; set; } = "未授权";
+ }
}
\ No newline at end of file
diff --git a/KJDService/KJD_WebService/Upload/Prod/WXProd.aspx.cs b/KJDService/KJD_WebService/Upload/Prod/WXProd.aspx.cs
index e5ebc2e..0b49270 100644
--- a/KJDService/KJD_WebService/Upload/Prod/WXProd.aspx.cs
+++ b/KJDService/KJD_WebService/Upload/Prod/WXProd.aspx.cs
@@ -83,6 +83,10 @@ namespace KJD_Web.Upload.Prod
{
string prodStr = Encoding.UTF8.GetString(this.FileUpload1.FileBytes);
prodStr = TextBox2.Text.Trim();
+ var reducePer = 0m;
+ var realPricePer = 1m - reducePer * 0.01m;
+ if (realPricePer < 0.1m)
+ realPricePer = 0.1m;
WXClientProductInfoLite wxClientProd = new WXClientProductInfoLite();
@@ -92,11 +96,11 @@ namespace KJD_Web.Upload.Prod
var regex_str = str_lst.OrderByDescending(s => s.Length).FirstOrDefault();
wxClientProd.product_key = JsonUtils.DeserializeJsonToObject(regex_str);
if (wxClientProd.product_key == null)
- return "解析失败";
+ return "解析失败product_key";
}
catch
{
- return "解析失败";
+ return "解析失败product_key";
}
//商品详情格式
@@ -105,7 +109,7 @@ namespace KJD_Web.Upload.Prod
//主标题
wxClientProd.info.title = RegexUtils.GetStringJson(ref prodStr, "title");
if (wxClientProd.info.title.IsNullOrEmpty())
- return "解析失败";
+ return "解析失败title";
//副标题
wxClientProd.info.sub_title = RegexUtils.GetStringJson(ref prodStr, "sub_title");
@@ -116,11 +120,11 @@ namespace KJD_Web.Upload.Prod
var regex_str = str_lst.OrderByDescending(s => s.Length).FirstOrDefault();
wxClientProd.info.head_img = JsonUtils.DeserializeJsonToListNullable(regex_str);
if (wxClientProd.info.head_img == null)
- return "解析失败";
+ return "解析失败head_img";
}
catch
{
- return "解析失败";
+ return "解析失败head_img";
}
var nodeCatId = RegexUtils.GetStringJson(ref prodStr, "nodeCatId");
@@ -139,7 +143,7 @@ namespace KJD_Web.Upload.Prod
}
catch
{
- return "解析失败";
+ return "解析失败category";
}
str_lst = RegexUtils.GetJsonObjStrJson(ref prodStr, "detail");
@@ -158,7 +162,7 @@ namespace KJD_Web.Upload.Prod
}
catch
{
- return "解析失败";
+ return "解析失败detail";
}
str_lst = RegexUtils.GetJsonArrStrJson(ref prodStr, "param");
@@ -173,7 +177,7 @@ namespace KJD_Web.Upload.Prod
}
catch
{
- return "解析失败";
+ return "解析失败param";
}
//品牌id
@@ -191,7 +195,7 @@ namespace KJD_Web.Upload.Prod
}
catch
{
- return "";
+ return "解析失败sku_id_list";
}
str_lst = RegexUtils.GetJsonObjStrJson(ref prodStr, "sku_list");
@@ -204,7 +208,7 @@ namespace KJD_Web.Upload.Prod
}
catch
{
- return "解析失败";
+ return "解析失败sku_list";
}
if (wxClientProd.info.sku_list == null)
@@ -222,7 +226,16 @@ namespace KJD_Web.Upload.Prod
}
catch
{
- return "解析失败";
+ return "解析失败sku_info";
+ }
+ }
+
+ // 佣金商品 根据折扣价格和佣金比例减去佣金
+ if (wxClientProd.info.sku_list != null)
+ {
+ foreach (var sku in wxClientProd.info.sku_list.sku_info)
+ {
+ sku.price = (sku.price - (sku.price - sku.discounted_price) * (1m - realPricePer)).ParseToInt();
}
}
@@ -236,7 +249,7 @@ namespace KJD_Web.Upload.Prod
}
catch
{
- return "解析失败";
+ return "解析失败product_sale_attrs";
}
@@ -255,7 +268,7 @@ namespace KJD_Web.Upload.Prod
}
catch
{
- return "解析失败";
+ return "解析失败service_desc";
}
str_lst = RegexUtils.GetJsonObjStrJson(ref prodStr, "express_info");
@@ -268,7 +281,7 @@ namespace KJD_Web.Upload.Prod
}
catch
{
- return "解析失败";
+ return "解析失败express_info";
}
str_lst = RegexUtils.GetJsonArrStrJson(ref prodStr, "headVideoInfo");
@@ -281,7 +294,7 @@ namespace KJD_Web.Upload.Prod
}
catch
{
- return "解析失败";
+ return "解析失败headVideoInfo";
}
str_lst = RegexUtils.GetJsonObjStrJson(ref prodStr, "afterSaleInfo");
@@ -294,7 +307,7 @@ namespace KJD_Web.Upload.Prod
}
catch
{
- return "解析失败";
+ return "解析失败afterSaleInfo";
}
str_lst = RegexUtils.GetJsonArrStrJson(ref prodStr, "deliveryExpressFee");
@@ -307,7 +320,7 @@ namespace KJD_Web.Upload.Prod
}
catch
{
- return "解析失败";
+ return "解析失败deliveryExpressFee";
}
str_lst = RegexUtils.GetJsonArrStrJson(ref prodStr, "templateInfo");
@@ -320,7 +333,7 @@ namespace KJD_Web.Upload.Prod
}
catch
{
- return "解析失败";
+ return "解析失败templateInfo";
}
wxClientProd.info.spuCode = RegexUtils.GetStringJson(ref prodStr, "spuCode");
@@ -331,11 +344,26 @@ namespace KJD_Web.Upload.Prod
var regex_str = str_lst.OrderByDescending(s => s.Length).FirstOrDefault();
wxClientProd.productSkus = JsonUtils.DeserializeJsonToList(regex_str);
if (wxClientProd.productSkus == null)
- return "解析失败";
+ return "解析失败productSkus";
}
catch
{
- return "解析失败";
+ return "解析失败productSkus";
+ }
+
+ // 佣金商品 根据价格给售卖价格赋值,如果价格丢失,直接在售卖价上计算
+ foreach (var sku in wxClientProd.productSkus)
+ {
+ var wxDisSku = wxClientProd.info.sku_list?.sku_info?.FirstOrDefault(s => s.sku_id == sku.skuKey.skuId);
+ if (wxDisSku != null)
+ sku.productSkuInfo.salePrice = wxDisSku.price;
+ else
+ sku.productSkuInfo.salePrice = (sku.productSkuInfo.salePrice - sku.productSkuInfo.salePrice * realPricePer).ParseToInt();
+ }
+
+ if (wxClientProd.productSkus.Min(s => s.productSkuInfo.salePrice * 0.01m) == 0)
+ {
+ return "解析失败Sku价格为0";
}
return SaveWxProd(wxClientProd.product_key.product_id, wxClientProd, prodStr);
diff --git a/TEMUKJD/BLL/Pdd/PddApi.cs b/TEMUKJD/BLL/Pdd/PddApi.cs
index 3e81431..afbce20 100644
--- a/TEMUKJD/BLL/Pdd/PddApi.cs
+++ b/TEMUKJD/BLL/Pdd/PddApi.cs
@@ -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;
}
+ ///
+ /// 貔貅管家
+ ///
+ public static string clientId_pi_xiu_guan_jia { get; set; } = "ad502ec19e0c49ab9df14f83494e153c";
+ /////
+ ///// 小红椒商品管理
+ /////
+ //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
///
/// 关联
///
- ///
+ ///
///
/// 最低价 分
/// 最高价 分
@@ -114,12 +125,11 @@ namespace TemuKJD.BLL.PddApi
/// 15-折800,16-当当,17-青创网,18-开山网,19-新款网
///
///
- 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();
- 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";
-
///
///
///
@@ -283,18 +289,24 @@ namespace TemuKJD.BLL.PddApi
/// 拼多多接口入参
///
static string PddApiRequest(string type, Dictionary 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";
diff --git a/TEMUKJD/BLL/Pdd/PddApiHelper.cs b/TEMUKJD/BLL/Pdd/PddApiHelper.cs
index 7210d4d..5f5875c 100644
--- a/TEMUKJD/BLL/Pdd/PddApiHelper.cs
+++ b/TEMUKJD/BLL/Pdd/PddApiHelper.cs
@@ -1,6 +1,8 @@
using AllBase;
using AllBase.Helper;
using AllBase.Model.Result;
+using AllBase.Model.Result.PDDResult;
+using NaiBa.Util;
using NaiBa.Util.Extension;
using System;
using System.Collections.Generic;
@@ -15,15 +17,18 @@ namespace TemuKJD.BLL.PddApi
{
public static void RefreshApi(ShopLoginInfo shop, bool isForceRefresh = false)
{
- if (isForceRefresh || (shop.AuthAddTime <= DateTime.Now.AddDays(-1) && shop.AuthExpiresTime <= DateTime.Now))
+ if (isForceRefresh || (shop.AuthUpdateTime <= DateTime.Now.AddDays(-1) && shop.AuthExpiresTime <= DateTime.Now))
{
string errStr = "";
var authInfo = PddApiHelper.GetE57ShopPddToken(shop, out errStr);
- if (errStr.IsNullOrEmpty() || (shop.AuthAddTime <= DateTime.Now.AddDays(-1) && shop.AuthExpiresTime <= DateTime.Now))
+ if (errStr.IsNullOrEmpty() || (shop.AuthUpdateTime <= DateTime.Now.AddDays(-1) && shop.AuthExpiresTime <= DateTime.Now))
{
- shop.ApiAuthInfoList.RemoveAll(a => a.AppKey.IsNullOrEmpty() || a.AppKey == PddApi.clientId);
+ shop.ApiAuthInfoList.RemoveAll(a => a.AppKey.IsNullOrEmpty() || a.AppKey == authInfo.AppKey);
shop.ApiAuthInfoList.Add(authInfo);
}
+
+ if (authInfo != null && !string.IsNullOrEmpty(authInfo.AccessToken))
+ PddApiHelper.SaveShopClientInfo(authInfo);
}
}
@@ -38,7 +43,8 @@ namespace TemuKJD.BLL.PddApi
public static AuthInfo GetE57ShopPddToken(ShopLoginInfo shop, out string errorStr)
{
errorStr = "";
- var url = BaseClass.BuildObjString("shop/e57_get_pdd_shop_token");
+
+ var url = BaseClass.BuildPDDObjString("shop/e57_get_pdd_shop_token");
var data = UserLogin.GetSignaturex();
data += "&mall_id=" + shop.MallId;
var html = GetHtml.PostUtf8(url, data);
@@ -53,30 +59,133 @@ namespace TemuKJD.BLL.PddApi
var token = new AuthInfo()
{
ShopId = shop.ShopId,
- AddTime = DateTime.Now,
- AppKey = PddApi.clientId, // BaseRegex.GetStringJson(ref html, "appKey").ParseToString(),
+ UpdateTime = DateTime.Now,
+ AppKey = PddApi.clientId_pi_xiu_guan_jia,
AccessToken = BaseRegex.GetStringJson(ref html, "accessToken"),
ExpiresTime = BaseClass.StampToDateTime(BaseRegex.GetIntJson(ref html, "tokenExpiresTime")),
ApiAuthStatus = "授权成功",
};
return token;
}
- return new AuthInfo() { ShopId = shop.ShopId, AddTime = DateTime.Now, ExpiresTime = DateTime.Now };
+ return new AuthInfo()
+ {
+ ShopId = shop.ShopId,
+ UpdateTime = DateTime.Now,
+ AppKey = PddApi.clientId_pi_xiu_guan_jia,
+ AccessToken = "",
+ ExpiresTime = DateTime.Now,
+ ApiAuthStatus = "未授权",
+ };
}
- public static List> LstAuthInfos;
- public static void PddGetLocalTokens()
+ //public static List> LstAuthInfos { get; set; }
+ //public static void GetPddLocalTokens()
+ //{
+ // if (BaseClass.MainPath == "binxixi")
+ // {
+ // LstAuthInfos = NaiBa.Util.Helper.ConfigHelper.LoadConfig>>("pdd_shop_api_auth_info_lists");
+ // if (LstAuthInfos == null)
+ // LstAuthInfos = new List>();
+ // foreach (var shop in GlobalConfig.ShopLoginList)
+ // {
+ // shop.ApiAuthInfoList = LstAuthInfos.FirstOrDefault(l => l.FirstOrDefault()?.ShopId == shop.ShopId);
+ // if (shop.ApiAuthInfoList == null)
+ // shop.ApiAuthInfoList = new List();
+ // }
+ // }
+ //}
+
+ public static void GetShopClientInfo(List shops = null)
{
if (BaseClass.MainPath == "binxixi")
{
- LstAuthInfos = NaiBa.Util.Helper.ConfigHelper.LoadConfig>>("pdd_shop_api_auth_info_lists");
- if (LstAuthInfos == null)
- LstAuthInfos = new List>();
- foreach (var shop in GlobalConfig.ShopLoginList)
+ ConcurrentList shopList = new ConcurrentList();
+ if (shops == null)
+ shopList.AddRange(GlobalConfig.ShopLoginList);
+ else
+ shopList.AddRange(shops);
+ while (shopList.Count > 0)
{
- shop.ApiAuthInfoList = LstAuthInfos.FirstOrDefault(l => l.FirstOrDefault()?.ShopId == shop.ShopId);
- if (shop.ApiAuthInfoList == null)
- shop.ApiAuthInfoList = new List();
+ var shopTemp = shopList.Take(50).ToList();
+
+ var url = BaseClass.BuildPDDObjString("shop/get_shop_client_info");
+ var data = UserLogin.GetSignaturex();
+ data += "&shop_ids=" + string.Join(",", shopTemp.Select(s => s.ShopId).Distinct());
+ var html = GetHtml.PostUtf8(url, data);
+ if (!html.Contains("\"code\":200"))
+ html = GetHtml.PostUtf8(url, data);
+
+ if (html.Contains("\"code\":200"))
+ {
+ try
+ {
+ var dataStr = JsonHelper.SerializeObject(JsonHelper.JObjectParse(html)["data"]);
+ var serverApiAuthList = JsonHelper.DeserializeJsonToList(dataStr);
+ foreach (var serverAuth in serverApiAuthList)
+ {
+ var shop = shopList.FirstOrDefault(s => s.ShopId == serverAuth.ShopId);
+ var auth = shop.ApiAuthInfoList.FirstOrDefault(a => a.AppKey == serverAuth.AppKey);
+ if (auth == null)
+ {
+ auth = new AuthInfo();
+ shop.ApiAuthInfoList.Add(auth);
+ }
+ auth.ShopId = serverAuth.ShopId;
+ auth.AccessToken = serverAuth.AccessToken;
+ auth.RefreshToken = serverAuth.RefreshToken;
+ auth.AppKey = serverAuth.AppKey;
+ auth.ExpiresTime = serverAuth.ExpiresTime;
+ auth.UpdateTime = serverAuth.UpdateTime;
+ auth.ApiAuthStatus = serverAuth.ApiAuthStatus;
+ auth.AppSecret = serverAuth.AppSecret;
+ }
+ }
+ catch
+ {
+ }
+ }
+
+ shopList.RemoveAll(s => shopTemp.Contains(s));
+ }
+ }
+ }
+
+ public static string SaveShopClientInfo(AuthInfo auth)
+ {
+ var clientUrl = BaseClass.BuildObjString("shop/add_mdy_shop_client_info");
+ var data = UserLogin.GetSignaturex()
+ + "&ShopId=" + auth.ShopId
+ + "&AccessToken=" + auth.AccessToken
+ + "&RefreshToken=" + auth.RefreshToken
+ + "&AppKey=" + auth.AppKey
+ + "&ExpiresTime=" + auth.ExpiresTime.ToString("yyyy-MM-dd HH:mm:ss")
+ + "&UpdateTime=" + auth.UpdateTime.ToString("yyyy-MM-dd HH:mm:ss")
+ + "&ApiAuthStatus=" + auth.ApiAuthStatus
+ + "&AppSecret=" + auth.AppSecret;
+ var result = GetHtml.PostUtf8(clientUrl, data);
+ return result;
+ }
+
+ public static void GetPddClientInfo()
+ {
+ if (BaseClass.MainPath == "binxixi")
+ {
+ var url = BaseClass.BuildPDDObjString("shop/get_pdd_client_info");
+ var data = UserLogin.GetSignaturex();
+ data += "&password=" + BaseClass.PassWord;
+ var html = GetHtml.PostUtf8(url, data);
+ if (!html.Contains("\"code\":200"))
+ html = GetHtml.PostUtf8(url, data);
+
+ if (html.Contains("\"code\":200"))
+ {
+ try
+ {
+ var clientDataStr = JsonHelper.SerializeObject(JsonHelper.JObjectParse(html)["data"]);
+ GlobalConfig.PddClentInfoList.Clear();
+ GlobalConfig.PddClentInfoList.AddRange(JsonHelper.DeserializeJsonToList(clientDataStr));
+ }
+ catch { }
}
}
}
diff --git a/TEMUKJD/BLL/VDian/VDianUpProdMappingBLL.cs b/TEMUKJD/BLL/VDian/VDianUpProdMappingBLL.cs
index 91deb9a..26a55f1 100644
--- a/TEMUKJD/BLL/VDian/VDianUpProdMappingBLL.cs
+++ b/TEMUKJD/BLL/VDian/VDianUpProdMappingBLL.cs
@@ -274,6 +274,11 @@ namespace TemuKJD.BLL.VDian
{
vDToken = vDianShop.Wdtoken;
vDCookie = vDianShop.Cookies;
+ if (vDToken.IsNullOrEmpty())
+ {
+ vDToken = "" + BaseRegex.GetMatchRegexString(ref vDCookie, "wdtoken=([^;]+?);");
+ vDianShop.Wdtoken = vDToken;
+ }
spider_token = BaseClass.GetMd5(DateTime.Now.ToString()).Substring(0, 4).ToLower();
bool useCache = false;
@@ -289,54 +294,54 @@ namespace TemuKJD.BLL.VDian
// 商品标题赋值
vDianProduct.itemName = prod.ProductTitle;
- var allAttrResult = "";
- for (int i = 0; !allAttrResult.Contains("\"message\":\"OK\"") && i < 20; i++)
- {
- allAttrResult = request_vdian_all_attr_com();
- Thread.Sleep(Randomx.GetId(300, 500));
- }
- if (allAttrResult.Contains("\"message\":\"OK\""))
- {
- var AttrMatches = BaseRegex.GetMatchRegex(ref allAttrResult, "\"attr_id\":([\\s\\S]*?),");
- List lst = new List();
- foreach (Match match in AttrMatches)
- {
- var attr = BaseRegex.GetMatchRegexString(match.ToString(), "\"attr_id\":([\\s\\S]*?),");
- lst.Add(attr);
- if (lst.Count >= 100)
- {
- var hideAttrResult = request_vdian_hideAttr_com(lst);
- if (!hideAttrResult.Contains("\"message\":\"OK\""))
- {
- prod.MappingResult = BaseRegex.GetMatchRegexString(hideAttrResult, "\"message\":\"([\\s\\S]+?)\"");
- if (string.IsNullOrEmpty(prod.MappingResult))
- prod.MappingResult = hideAttrResult;
- if (hideAttrResult.Contains("LOGIN ERROR"))
- {
- vDianShop.LoginStatus = 2;
- vDianShop.UpGoodAuth = "请先登录";
- prod.MappingResult = "店铺 " + vDianShop.ShopName + " 未登录";
- }
- prod.MappingResult = "转换失败,删除attribute出错" + prod.MappingResult;
- LogSave.Add("[微店批量删除店铺attribute出错]" + " pid-" + prod.ProductId + " ptitle-" + prod.ProductTitle + " psid-" + vDianShop.ShopId
- + " psname-" + vDianShop.ShopName + " pfrom-" + prod.From + " pmsg-" + prod.MappingResult);
- return null;
- }
- Thread.Sleep(500);
- lst.Clear();
- }
- }
- }
- else
- {
- prod.MappingResult = BaseRegex.GetMatchRegexString(allAttrResult, "\"message\":\"([\\s\\S]+?)\"");
- if (string.IsNullOrEmpty(prod.MappingResult))
- prod.MappingResult = allAttrResult;
- prod.MappingResult = "转换失败,获取attribute出错" + prod.MappingResult;
- LogSave.Add("[微店获取店铺attribute出错]" + " pid-" + prod.ProductId + " ptitle-" + prod.ProductTitle + " psid-" + vDianShop.ShopId
- + " psname-" + vDianShop.ShopName + " pfrom-" + prod.From + " pmsg-" + prod.MappingResult);
- return null;
- }
+ //var allAttrResult = "";
+ //for (int i = 0; !allAttrResult.Contains("\"message\":\"OK\"") && i < 20; i++)
+ //{
+ // allAttrResult = request_vdian_all_attr_com();
+ // Thread.Sleep(Randomx.GetId(300, 500));
+ //}
+ //if (allAttrResult.Contains("\"message\":\"OK\""))
+ //{
+ // var AttrMatches = BaseRegex.GetMatchRegex(ref allAttrResult, "\"attr_id\":([\\s\\S]*?),");
+ // List lst = new List();
+ // foreach (Match match in AttrMatches)
+ // {
+ // var attr = BaseRegex.GetMatchRegexString(match.ToString(), "\"attr_id\":([\\s\\S]*?),");
+ // lst.Add(attr);
+ // if (lst.Count >= 100)
+ // {
+ // var hideAttrResult = request_vdian_hideAttr_com(lst);
+ // if (!hideAttrResult.Contains("\"message\":\"OK\""))
+ // {
+ // prod.MappingResult = BaseRegex.GetMatchRegexString(hideAttrResult, "\"message\":\"([\\s\\S]+?)\"");
+ // if (string.IsNullOrEmpty(prod.MappingResult))
+ // prod.MappingResult = hideAttrResult;
+ // if (hideAttrResult.Contains("LOGIN ERROR"))
+ // {
+ // vDianShop.LoginStatus = 2;
+ // vDianShop.UpGoodAuth = "请先登录";
+ // prod.MappingResult = "店铺 " + vDianShop.ShopName + " 未登录";
+ // }
+ // prod.MappingResult = "转换失败,删除attribute出错" + prod.MappingResult;
+ // LogSave.Add("[微店批量删除店铺attribute出错]" + " pid-" + prod.ProductId + " ptitle-" + prod.ProductTitle + " psid-" + vDianShop.ShopId
+ // + " psname-" + vDianShop.ShopName + " pfrom-" + prod.From + " pmsg-" + prod.MappingResult);
+ // return null;
+ // }
+ // Thread.Sleep(500);
+ // lst.Clear();
+ // }
+ // }
+ //}
+ //else
+ //{
+ // prod.MappingResult = BaseRegex.GetMatchRegexString(allAttrResult, "\"message\":\"([\\s\\S]+?)\"");
+ // if (string.IsNullOrEmpty(prod.MappingResult))
+ // prod.MappingResult = allAttrResult;
+ // prod.MappingResult = "转换失败,获取attribute出错" + prod.MappingResult;
+ // LogSave.Add("[微店获取店铺attribute出错]" + " pid-" + prod.ProductId + " ptitle-" + prod.ProductTitle + " psid-" + vDianShop.ShopId
+ // + " psname-" + vDianShop.ShopName + " pfrom-" + prod.From + " pmsg-" + prod.MappingResult);
+ // return null;
+ //}
// 商品属性
retry:
@@ -372,10 +377,27 @@ namespace TemuKJD.BLL.VDian
// 上传属性获取属性ID
if (wdAttrList.Count > 0)
{
+ Thread.Sleep(Randomx.GetId(2000, 5000));
+
List wdAttrList_New = new List();
- var res = this.upLoadAttrx(prod, vDianShop, wdAttrList, wdAttrList_New);
- if (!res) return null;
+ //var res = this.upLoadAttrx(prod, vDianShop, wdAttrList, wdAttrList_New);
+ //if (!res) return null;
+
+ var inAttr = JsonHelper.SerializeObject(wdAttrList);
+ var outAttr = JsonHelper.SerializeObject(wdAttrList_New);
+
+ wdAttrList_New = JsonHelper.DeserializeJsonToList(JsonHelper.SerializeObject(wdAttrList));
+ foreach (var wdAttr in wdAttrList_New)
+ {
+ int id = 0;
+ foreach (var atv in wdAttr.attr_values)
+ {
+ id++;
+ atv.attr_id = id;
+ atv.attr_title = wdAttr.attr_title;
+ }
+ }
wdAttrList = wdAttrList_New;
vDianProduct.attrList = wdAttrList_New;
@@ -431,7 +453,8 @@ namespace TemuKJD.BLL.VDian
}
}
}
- vDianSku.price = ((sku.price * (100M + addPercent) / 100M + addPrice) * reduceRate + product.express_price).ToString();
+ int priceFen = (((sku.price * (100M + addPercent) / 100M + addPrice) * reduceRate + product.express_price) * 100).ParseToInt();
+ vDianSku.price = (priceFen * 0.01m).ToString();
vDianSku.stock = sku.number > 999999 ? 999999.ToString() : sku.number.ToString();
if (vDianSku.stock == "0")
vDianSku.stock = "1";
@@ -446,7 +469,7 @@ namespace TemuKJD.BLL.VDian
var wdMaxPrice = 0M;
try
{
- wdMaxPrice = (product.price * (100M + addPercent) / 100M + addPrice) * reduceRate + product.express_price;
+ //wdMaxPrice = (product.price * (100M + addPercent) / 100M + addPrice) * reduceRate + product.express_price;
wdMaxPrice = vDianProduct.sku.Max(wd => Convert.ToDecimal(wd.price));
}
catch
@@ -628,15 +651,15 @@ namespace TemuKJD.BLL.VDian
if (mainImgResult.Contains("\"message\":\"SUCCESS\""))
{
var imgUrl = BaseRegex.GetMatchRegexString(mainImgResult, "\"url\":\"([\\s\\S]*?)\"");
- //if (!string.IsNullOrEmpty(imgUrl))
- //{
- // bigImages.Add(imgUrl);
+ if (!string.IsNullOrEmpty(imgUrl))
+ {
+ bigImages.Add(imgUrl);
- // // 写图片缓存
- // var url = BaseClass.LoginApiUrl + "?obj=upshopid/image_weidian&act=weidian_add";
- // var data = UserLogin.GetSignaturex() + "&data=" + item.Item2.Key + "," + imgUrl + ";";
- // var html = GetHtml.PostUtf8(url, data);
- //}
+ //// 写图片缓存
+ //var url = BaseClass.LoginApiUrl + "?obj=upshopid/image_weidian&act=weidian_add";
+ //var data = UserLogin.GetSignaturex() + "&data=" + item.Item2.Key + "," + imgUrl + ";";
+ //var html = GetHtml.PostUtf8(url, data);
+ }
}
else
{
@@ -753,7 +776,7 @@ namespace TemuKJD.BLL.VDian
if (++timesx > 1 || !IsUploadLimitedFailed(tmp_detailId)) break;
Thread.Sleep(Randomx.GetId(2000, 3000));
}
- if (tmp_detailId.Contains("\"message\":\"OK\""))
+ if (tmp_detailId.ParseToString().Contains("\"message\":\"OK\""))
{
tmp_detailId = BaseRegex.GetMatchRegexString(tmp_detailId, "\"tmp_detail_id\":\"([\\s\\S]*?)\"");
vDianProduct.tmpDetailId = tmp_detailId;
@@ -763,7 +786,7 @@ namespace TemuKJD.BLL.VDian
prod.MappingResult = BaseRegex.GetMatchRegexString(tmp_detailId, "\"message\":\"([\\s\\S]+?)\"");
if (string.IsNullOrEmpty(prod.MappingResult))
prod.MappingResult = tmp_detailId;
- if (tmp_detailId.Contains("LOGIN ERROR"))
+ if (tmp_detailId.ParseToString().Contains("LOGIN ERROR"))
{
vDianShop.LoginStatus = 2;
vDianShop.UpGoodAuth = "请先登录";
@@ -824,20 +847,27 @@ namespace TemuKJD.BLL.VDian
vDianProduct.bgCateId = 50023878;
}
+ vDianProduct.merchantCode = product.out_goods_sn;
+
// 上货上传商品
var jsonStr = JsonHelper.SerializeObject(vDianProduct);
var result = "";
int timesxx = 0;
while (true)
{
+ //Thread.Sleep(15000);
+ Thread.Sleep(Randomx.GetId(8000, 11000));
var ua = getUa(vDianShop);
+ Thread.Sleep(Randomx.GetId(8000, 11000));
if (string.IsNullOrEmpty(ua))
ua = getUa(vDianShop);
if (string.IsNullOrEmpty(ua))
LogSave.Add("[微店获取Ua失败]" + " pid-" + prod.ProductId + " ptitle-" + prod.ProductTitle + " psid-" + vDianShop.ShopId
+ " psname-" + vDianShop.ShopName + " pfrom-" + prod.From + " pmsg-" + prod.MappingResult);
- Thread.Sleep(15000);
+ //JObject obj = JsonHelper.JObjectParse(jsonStr);
+ //(obj["attrList"] as JArray).RemoveAt(0);
+ //var str1 = JsonHelper.SerializeObject(obj);
result = request_vdian_product_com(jsonStr, ua);
if (string.IsNullOrEmpty(result))
@@ -895,7 +925,7 @@ namespace TemuKJD.BLL.VDian
}
if (result.Contains("创建商品过于频繁"))
{
- prod.MappingResult = "商品驳回,请更换其它商品转换";
+ prod.MappingResult = "过于频繁,商品驳回,请更换其它商品转换";
}
prod.MappingResult = "转换失败,上传商品出错:" + prod.MappingResult;
LogSave.Add("[微店上传商品出错]" + " pid-" + prod.ProductId + " ptitle-" + prod.ProductTitle + " psid-" + vDianShop.ShopId
@@ -1009,7 +1039,8 @@ namespace TemuKJD.BLL.VDian
request.KeepAlive = true;
request.Accept = "application/json, */*";
request.Headers.Add("Origin", @"https://d.weidian.com");
- request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36";
+ //request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36";
+ request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36";
request.ContentType = "multipart/form-data; boundary=----WebKitFormBoundaryl8PNkxxP0AKTlrpf";
request.Referer = "https://d.weidian.com/weidian-pc/pc-vue-item/?spider_token=" + spider_token;
request.Headers.Set(HttpRequestHeader.AcceptEncoding, "gzip, deflate, br");
@@ -1117,6 +1148,7 @@ Content-Disposition: form-data; name=""wdtoken""
isGetAttrId = true;
string param = attrList;
+ //https://thor.weidian.com/wditem/itemSearch.searchAttrs/1.0
string url = "https://thor.weidian.com/wditem/itemWrite.updateAttrList/1.0";
var result = request_vdian_common(url, param);
@@ -1165,7 +1197,8 @@ Content-Disposition: form-data; name=""wdtoken""
request.KeepAlive = true;
request.Accept = "application/json, */*";
request.Headers.Add("Origin", @"https://d.weidian.com");
- request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36";
+ //request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36";
+ request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36";
request.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
request.Referer = "https://d.weidian.com/weidian-pc/pc-vue-item/?spider_token=" + spider_token;
request.Headers.Set(HttpRequestHeader.AcceptEncoding, "gzip, deflate, br");
@@ -1261,7 +1294,8 @@ Content-Disposition: form-data; name=""wdtoken""
request.Headers.Add("sec-ch-ua", @"""Google Chrome"";v=""89"", ""Chromium"";v=""89"", "";Not A Brand"";v=""99""");
request.Accept = "application/json, */*";
request.Headers.Add("sec-ch-ua-mobile", @"?0");
- request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36";
+ //request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36";
+ request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36";
request.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
request.Headers.Add("Origin", @"https://d.weidian.com");
request.Headers.Add("Sec-Fetch-Site", @"same-site");
@@ -1453,6 +1487,7 @@ Content-Disposition: form-data; name=""wdtoken""
request.Accept = "application/json, */*";
request.Headers.Add("Origin", @"https://d.weidian.com");
request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36";
+ //request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36";
request.Referer = "https://d.weidian.com/weidian-pc/pc-vue-item/?spider_token=" + spider_token;
request.Headers.Set(HttpRequestHeader.AcceptEncoding, "gzip, deflate, br");
request.Headers.Set(HttpRequestHeader.AcceptLanguage, "zh-CN,zh;q=0.9");
@@ -1658,6 +1693,8 @@ Content-Disposition: form-data; name=""wdtoken""
///
private static bool IsUploadLimitedFailed(string result)
{
+ if (result == null)
+ result = "";
return result.Contains("无法连接到远程服务器") || result.Contains("操作超时") || result.Contains("基础连接已经关闭")
|| result.Contains("远程主机强迫关闭") || result.Contains("Unable to write data") || result.Contains("现在人太多了, 请稍后重试");
}
diff --git a/TEMUKJD/KJD.csproj b/TEMUKJD/KJD.csproj
index 0d9497a..7b6d41e 100644
--- a/TEMUKJD/KJD.csproj
+++ b/TEMUKJD/KJD.csproj
@@ -158,6 +158,12 @@
PDDAddActivityForm.cs
+
+ Form
+
+
+ ExprotProductForm.cs
+
Form
@@ -219,6 +225,18 @@
GetAddressForm.cs
+
+ Form
+
+
+ VDianShopEditForm.cs
+
+
+ Form
+
+
+ VDianLoginForm.cs
+
Form
@@ -1204,6 +1222,9 @@
PDDAddActivityForm.cs
+
+ ExprotProductForm.cs
+
PDDGetChanceProdByImgForm.cs
@@ -1234,6 +1255,12 @@
DataGridViewEx.cs
+
+ VDianShopEditForm.cs
+
+
+ VDianLoginForm.cs
+
VDianShopLoginForm.cs
diff --git a/TEMUKJD/KJDForms/ShopForms/ShopListForm.cs b/TEMUKJD/KJDForms/ShopForms/ShopListForm.cs
index 04f40c7..77289b0 100644
--- a/TEMUKJD/KJDForms/ShopForms/ShopListForm.cs
+++ b/TEMUKJD/KJDForms/ShopForms/ShopListForm.cs
@@ -67,7 +67,7 @@ namespace TemuKJD.KJDForms.ShopForms
localShop.ApiAuthInfoList = new List();
localShop.ApiAuthInfoList.AddRange(serverShop.ApiAuthInfoList);
localShop.BuyApiAuth.AccessToken = serverShop.BuyApiAuth.AccessToken;
- localShop.BuyApiAuth.AddTime = serverShop.BuyApiAuth.AddTime;
+ localShop.BuyApiAuth.UpdateTime = serverShop.BuyApiAuth.UpdateTime;
localShop.BuyApiAuth.AppKey = serverShop.BuyApiAuth.AppKey;
localShop.BuyApiAuth.ExpiresTime = serverShop.BuyApiAuth.ExpiresTime;
localShop.BuyApiAuth.RefreshToken = serverShop.BuyApiAuth.RefreshToken;
@@ -160,7 +160,7 @@ namespace TemuKJD.KJDForms.ShopForms
AppKey = appkey,
AccessToken = BaseRegex.GetStringJson(ref shopStr, "access_token"),
RefreshToken = BaseRegex.GetStringJson(ref shopStr, "refresh_token"),
- AddTime = BaseRegex.GetStringJson(ref shopStr, "add_time").ParseToDateTime(),
+ UpdateTime = BaseRegex.GetStringJson(ref shopStr, "add_time").ParseToDateTime(),
ExpiresTime = BaseRegex.GetStringJson(ref shopStr, "expires_in").ParseToDateTime(),
});
}
@@ -173,7 +173,7 @@ namespace TemuKJD.KJDForms.ShopForms
AppKey = appkey,
AccessToken = BaseRegex.GetStringJson(ref shopStr, "access_token"),
RefreshToken = BaseRegex.GetStringJson(ref shopStr, "refresh_token"),
- AddTime = BaseRegex.GetStringJson(ref shopStr, "add_time").ParseToDateTime(),
+ UpdateTime = BaseRegex.GetStringJson(ref shopStr, "add_time").ParseToDateTime(),
ExpiresTime = BaseRegex.GetStringJson(ref shopStr, "expires_in").ParseToDateTime(),
});
}
@@ -182,7 +182,7 @@ namespace TemuKJD.KJDForms.ShopForms
shop.BuyApiAuth.AppKey = appkey;
shop.BuyApiAuth.AccessToken = BaseRegex.GetStringJson(ref shopStr, "access_token");
shop.BuyApiAuth.RefreshToken = BaseRegex.GetStringJson(ref shopStr, "refresh_token");
- shop.BuyApiAuth.AddTime = BaseRegex.GetStringJson(ref shopStr, "add_time").ParseToDateTime();
+ shop.BuyApiAuth.UpdateTime = BaseRegex.GetStringJson(ref shopStr, "add_time").ParseToDateTime();
shop.BuyApiAuth.ExpiresTime = BaseRegex.GetStringJson(ref shopStr, "expires_in").ParseToDateTime();
}
}
diff --git a/TEMUKJD/PDDForms/AdminForms/PDDAdminForm.Designer.cs b/TEMUKJD/PDDForms/AdminForms/PDDAdminForm.Designer.cs
index b6bcde0..4769fb1 100644
--- a/TEMUKJD/PDDForms/AdminForms/PDDAdminForm.Designer.cs
+++ b/TEMUKJD/PDDForms/AdminForms/PDDAdminForm.Designer.cs
@@ -40,8 +40,9 @@
System.Windows.Forms.TreeNode treeNode10 = new System.Windows.Forms.TreeNode("库存上传");
System.Windows.Forms.TreeNode treeNode11 = new System.Windows.Forms.TreeNode("商品核价");
System.Windows.Forms.TreeNode treeNode12 = new System.Windows.Forms.TreeNode("随机厂商商品");
- System.Windows.Forms.TreeNode treeNode13 = new System.Windows.Forms.TreeNode("微店管理");
- System.Windows.Forms.TreeNode treeNode14 = new System.Windows.Forms.TreeNode("超级权限管理", new System.Windows.Forms.TreeNode[] {
+ System.Windows.Forms.TreeNode treeNode13 = new System.Windows.Forms.TreeNode("商品导入");
+ System.Windows.Forms.TreeNode treeNode14 = new System.Windows.Forms.TreeNode("微店管理");
+ System.Windows.Forms.TreeNode treeNode15 = new System.Windows.Forms.TreeNode("超级权限管理", new System.Windows.Forms.TreeNode[] {
treeNode1,
treeNode2,
treeNode3,
@@ -54,7 +55,8 @@
treeNode10,
treeNode11,
treeNode12,
- treeNode13});
+ treeNode13,
+ treeNode14});
this.panel1 = new System.Windows.Forms.Panel();
this.panel3 = new System.Windows.Forms.Panel();
this.panel2 = new System.Windows.Forms.Panel();
@@ -169,12 +171,14 @@
treeNode11.Text = "商品核价";
treeNode12.Name = "随机厂商商品";
treeNode12.Text = "随机厂商商品";
- treeNode13.Name = "微店管理";
- treeNode13.Text = "微店管理";
- treeNode14.Name = "超级权限管理";
- treeNode14.Text = "超级权限管理";
+ treeNode13.Name = "商品导入";
+ treeNode13.Text = "商品导入";
+ treeNode14.Name = "微店管理";
+ treeNode14.Text = "微店管理";
+ treeNode15.Name = "超级权限管理";
+ treeNode15.Text = "超级权限管理";
this.tv.Nodes.AddRange(new System.Windows.Forms.TreeNode[] {
- treeNode14});
+ treeNode15});
this.tv.OverForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(235)))), ((int)(((byte)(235)))));
this.tv.Size = new System.Drawing.Size(140, 446);
this.tv.TabIndex = 1;
diff --git a/TEMUKJD/PDDForms/AdminForms/PDDAdminForm.cs b/TEMUKJD/PDDForms/AdminForms/PDDAdminForm.cs
index a54c21a..de5be43 100644
--- a/TEMUKJD/PDDForms/AdminForms/PDDAdminForm.cs
+++ b/TEMUKJD/PDDForms/AdminForms/PDDAdminForm.cs
@@ -11,6 +11,7 @@ using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using TemuKJD.BaseForms;
+using TemuKJD.PDDForms.ProductForms;
using TemuKJD.PDDForms.ProductSelectForms;
using TemuKJD.ToolForms;
//using TemuKJD.KJDForms.ProductSelectForms;
@@ -28,6 +29,7 @@ namespace TemuKJD.PDDForms.AdminForms
public Lazy getChanceProdByImgForm = new Lazy();
public Lazy getJuShuitanProdForm = new Lazy();
public Lazy randomComProductForm = new Lazy();
+ public Lazy importProdForm = new Lazy();
public Lazy vDianUploadProductForm = new Lazy();
//public Lazy dbPriceMarkUpForm = new Lazy();
//public Lazy dbProductSelectListManageForm = new Lazy();
@@ -108,6 +110,9 @@ namespace TemuKJD.PDDForms.AdminForms
case "随机厂商商品":
SetForm(randomComProductForm.Value);
break;
+ case "商品导入":
+ SetForm(importProdForm.Value);
+ break;
case "微店管理":
SetForm(vDianUploadProductForm.Value);
break;
diff --git a/TEMUKJD/PDDForms/ProductForms/ActivityForms/PDDAddActivityForm.cs b/TEMUKJD/PDDForms/ProductForms/ActivityForms/PDDAddActivityForm.cs
index 7551ece..7ce458e 100644
--- a/TEMUKJD/PDDForms/ProductForms/ActivityForms/PDDAddActivityForm.cs
+++ b/TEMUKJD/PDDForms/ProductForms/ActivityForms/PDDAddActivityForm.cs
@@ -2861,7 +2861,7 @@ namespace TemuKJD.PDDForms.ProductForms.ActivityForms
=> row.Cells["colSelect"]?.Value.ParseToBool() == true).Select(r => r.Cells["colShopId"]?.Value.ToString()).ToList();
foreach (var shop in GlobalConfig.ShopLoginList)
{
- if (isForceRefresh || (shop.AuthAddTime <= DateTime.Now.AddDays(-1) && shop.AuthExpiresTime <= DateTime.Now))
+ if (isForceRefresh || (shop.AuthUpdateTime <= DateTime.Now.AddDays(-1) && shop.AuthExpiresTime <= DateTime.Now))
{
Invoke(new Action(() =>
{
@@ -2876,26 +2876,26 @@ namespace TemuKJD.PDDForms.ProductForms.ActivityForms
}));
}
}
- List> NewApiInfolsts = JsonHelper.DeserializeJsonToList>(JsonHelper.SerializeObject(GlobalConfig.ShopLoginList.Select(s => s.ApiAuthInfoList).ToList()));
- foreach (var newLst in NewApiInfolsts)
- {
- if (newLst.FirstOrDefault()!= null)
- {
- var oldApiAuths = PddApiHelper.LstAuthInfos.FirstOrDefault(oldLst => oldLst.FirstOrDefault()?.ShopId == newLst.FirstOrDefault().ShopId);
- if (oldApiAuths != null)
- {
- oldApiAuths.Clear();
- oldApiAuths.AddRange(newLst);
- }
- else
- {
- PddApiHelper.LstAuthInfos.Add(newLst);
- }
- }
- }
+ //List> NewApiInfolsts = JsonHelper.DeserializeJsonToList>(JsonHelper.SerializeObject(GlobalConfig.ShopLoginList.Select(s => s.ApiAuthInfoList).ToList()));
+ //foreach (var newLst in NewApiInfolsts)
+ //{
+ // if (newLst.FirstOrDefault()!= null)
+ // {
+ // var oldApiAuths = PddApiHelper.LstAuthInfos.FirstOrDefault(oldLst => oldLst.FirstOrDefault()?.ShopId == newLst.FirstOrDefault().ShopId);
+ // if (oldApiAuths != null)
+ // {
+ // oldApiAuths.Clear();
+ // oldApiAuths.AddRange(newLst);
+ // }
+ // else
+ // {
+ // PddApiHelper.LstAuthInfos.Add(newLst);
+ // }
+ // }
+ //}
- PddApiHelper.LstAuthInfos = PddApiHelper.LstAuthInfos.Where(a => a.OrderBy(o => o.AddTime).LastOrDefault().AddTime > DateTime.Now.AddDays(-30)).ToList();
- NaiBa.Util.Helper.ConfigHelper.SaveConfig("pdd_shop_api_auth_info_lists", PddApiHelper.LstAuthInfos);
+ //PddApiHelper.LstAuthInfos = PddApiHelper.LstAuthInfos.Where(a => a.OrderBy(o => o.UpdateTime).LastOrDefault().UpdateTime > DateTime.Now.AddDays(-30)).ToList();
+ //NaiBa.Util.Helper.ConfigHelper.SaveConfig("pdd_shop_api_auth_info_lists", PddApiHelper.LstAuthInfos);
Invoke(new Action(() => { pbShopLoading.Visible = false; }));
});
}
diff --git a/TEMUKJD/PDDForms/ProductForms/ExprotProductForm.Designer.cs b/TEMUKJD/PDDForms/ProductForms/ExprotProductForm.Designer.cs
new file mode 100644
index 0000000..e70efb1
--- /dev/null
+++ b/TEMUKJD/PDDForms/ProductForms/ExprotProductForm.Designer.cs
@@ -0,0 +1,102 @@
+
+namespace TemuKJD.PDDForms.ProductForms
+{
+ partial class ExprotProductForm
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.panel1 = new System.Windows.Forms.Panel();
+ this.statusBar = new TemuKJD.UserControls.StatusBarUserControl();
+ this.btnExportWxApp = new DevComponents.DotNetBar.PanelEx();
+ this.panel1.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // panel1
+ //
+ this.panel1.BackColor = System.Drawing.Color.White;
+ this.panel1.Controls.Add(this.statusBar);
+ this.panel1.Controls.Add(this.btnExportWxApp);
+ this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.panel1.Location = new System.Drawing.Point(0, 0);
+ this.panel1.Name = "panel1";
+ this.panel1.Size = new System.Drawing.Size(800, 450);
+ this.panel1.TabIndex = 432;
+ //
+ // statusBar
+ //
+ this.statusBar.BackColor = System.Drawing.Color.White;
+ this.statusBar.Dock = System.Windows.Forms.DockStyle.Bottom;
+ this.statusBar.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+ this.statusBar.Location = new System.Drawing.Point(0, 427);
+ this.statusBar.Margin = new System.Windows.Forms.Padding(0);
+ this.statusBar.Name = "statusBar";
+ this.statusBar.Size = new System.Drawing.Size(800, 23);
+ this.statusBar.TabIndex = 435;
+ //
+ // btnExportWxApp
+ //
+ this.btnExportWxApp.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
+ this.btnExportWxApp.Cursor = System.Windows.Forms.Cursors.Hand;
+ this.btnExportWxApp.DisabledBackColor = System.Drawing.Color.Empty;
+ this.btnExportWxApp.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+ this.btnExportWxApp.Location = new System.Drawing.Point(32, 26);
+ this.btnExportWxApp.Name = "btnExportWxApp";
+ this.btnExportWxApp.Size = new System.Drawing.Size(167, 23);
+ this.btnExportWxApp.Style.Alignment = System.Drawing.StringAlignment.Center;
+ this.btnExportWxApp.Style.BackColor1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
+ this.btnExportWxApp.Style.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
+ this.btnExportWxApp.Style.BorderColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBorder;
+ this.btnExportWxApp.Style.BorderDashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
+ this.btnExportWxApp.Style.BorderSide = DevComponents.DotNetBar.eBorderSide.None;
+ this.btnExportWxApp.Style.ForeColor.Color = System.Drawing.Color.White;
+ this.btnExportWxApp.Style.GradientAngle = 90;
+ this.btnExportWxApp.StyleMouseOver.Alignment = System.Drawing.StringAlignment.Center;
+ this.btnExportWxApp.StyleMouseOver.BackColor1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(25)))), ((int)(((byte)(102)))), ((int)(((byte)(255)))));
+ this.btnExportWxApp.StyleMouseOver.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(25)))), ((int)(((byte)(102)))), ((int)(((byte)(255)))));
+ this.btnExportWxApp.TabIndex = 431;
+ this.btnExportWxApp.Text = "微信App商品";
+ this.btnExportWxApp.Click += new System.EventHandler(this.btnExportWxApp_Click);
+ //
+ // ExprotProductForm
+ //
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
+ this.ClientSize = new System.Drawing.Size(800, 450);
+ this.Controls.Add(this.panel1);
+ this.Name = "ExprotProductForm";
+ this.Text = "ExprotProductForm";
+ this.panel1.ResumeLayout(false);
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private DevComponents.DotNetBar.PanelEx btnExportWxApp;
+ private System.Windows.Forms.Panel panel1;
+ private UserControls.StatusBarUserControl statusBar;
+ }
+}
\ No newline at end of file
diff --git a/TEMUKJD/PDDForms/ProductForms/ExprotProductForm.cs b/TEMUKJD/PDDForms/ProductForms/ExprotProductForm.cs
new file mode 100644
index 0000000..9fd9562
--- /dev/null
+++ b/TEMUKJD/PDDForms/ProductForms/ExprotProductForm.cs
@@ -0,0 +1,486 @@
+using AllBase;
+using AllBase.Model.Result.WXResult;
+using NaiBa.Util.Extension;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using TemuKJD.BaseForms;
+using Work;
+
+namespace TemuKJD.PDDForms.ProductForms
+{
+ public partial class ExprotProductForm : BaseForms.BaseForm
+ {
+ public ExprotProductForm()
+ {
+ InitializeComponent();
+ }
+
+ private void btnExportWxApp_Click(object sender, EventArgs e)
+ {
+ OpenFileDialog openFileDialog = new OpenFileDialog();
+ openFileDialog.Multiselect = true;
+ // 设置过滤条件,只显示文本文件
+ openFileDialog.Filter = "文本文件 (*.txt)|*.txt|All files (*.*)|*.*";
+ // 显示对话框并获取结果
+ if (openFileDialog.ShowDialog() == DialogResult.OK)
+ {
+ var filePathLst = openFileDialog.FileNames.ToList();
+ //pbLoading.Visible = true;
+ this.statusBar.pgbTaskProgress.Maximum = filePathLst.Count;
+ this.statusBar.UpdateProgressBar(0);
+ Task.Run(() =>
+ {
+ int successNum = 0;
+ int failedNum = 0;
+ foreach (var path in filePathLst)
+ {
+ Invoke(new Action(() =>
+ {
+ this.statusBar.lblTaskStatus.Text = "正在导入 " + (successNum + failedNum) + "/" + filePathLst.Count + " 成功:" + successNum + " 失败:" + failedNum;
+ }));
+ //string content = "";
+ string rst = "";
+ try
+ {
+ rst = getProd(path);
+ if (!rst.Contains("成功"))
+ {
+
+ }
+ }
+ catch (Exception ex)
+ {
+ rst = ex.Message;
+ }
+ if (string.IsNullOrEmpty(rst) || rst.Contains("入库成功"))
+ successNum++;
+ else
+ failedNum++;
+ Invoke(new Action(() =>
+ {
+ this.statusBar.UpdateProgressBar(this.statusBar.pgbTaskProgress.Value + 1);
+ this.statusBar.lblTaskStatus.Text = "正在导入 " + (successNum + failedNum) + "/" + filePathLst.Count + " 成功:" + successNum + " 失败:" + failedNum;
+ }));
+ }
+ Invoke(new Action(() =>
+ {
+ //pbLoading.Visible = false;
+ this.statusBar.lblTaskStatus.Text = "导入完成" + (successNum + failedNum) + "/" + filePathLst.Count + " 成功:" + successNum + " 失败:" + failedNum;
+ BaseMsgForm.ShowInfo("导入完成!");
+ }));
+ });
+ }
+ }
+
+ string getProd(string filePath)
+ {
+ string prodStr = "";
+ //prodStr = Encoding.UTF8.GetString(this.FileUpload1.FileBytes);
+ //prodStr = TextBox2.Text.Trim();
+ //prodStr = FileBase.ReadAllText(filePath, Encoding.UTF8);
+
+ using (StreamReader sr = new StreamReader(filePath))
+ {
+ prodStr = sr.ReadToEnd();
+
+ }
+
+ var reducePer = filePath.Replace(".txt", "").Split(new string[] { "-" }, StringSplitOptions.RemoveEmptyEntries).LastOrDefault().ParseToInt();
+ if (reducePer > 0)
+ prodStr = "{\"reducePre\":" + reducePer + "}" + prodStr;
+ var realPricePer = 1m - reducePer * 0.01m;
+ if (realPricePer < 0.1m)
+ realPricePer = 0.1m;
+
+ WXClientProductInfoLite wxClientProd = new WXClientProductInfoLite();
+
+ var str_lst = BaseRegex.GetJsonObjStrJson(ref prodStr, "product_key");
+ try
+ {
+ var regex_str = str_lst.OrderByDescending(s => s.Length).FirstOrDefault();
+ wxClientProd.product_key = JsonHelper.DeserializeJsonToObject(regex_str);
+ if (wxClientProd.product_key == null)
+ return "解析失败product_key";
+ }
+ catch
+ {
+ return "解析失败product_key";
+ }
+
+ //商品详情格式
+ wxClientProd.info = new wx_client_prod_info();
+
+ //主标题
+ wxClientProd.info.title = BaseRegex.GetStringJson(ref prodStr, "title");
+ if (wxClientProd.info.title.IsNullOrEmpty())
+ return "解析失败title";
+
+ //副标题
+ wxClientProd.info.sub_title = BaseRegex.GetStringJson(ref prodStr, "sub_title");
+
+ str_lst = BaseRegex.GetJsonArrStrJson(ref prodStr, "head_img");
+ try
+ {
+ var regex_str = str_lst.OrderByDescending(s => s.Length).FirstOrDefault();
+ wxClientProd.info.head_img = JsonHelper.DeserializeJsonToListNullable(regex_str);
+ if (wxClientProd.info.head_img == null)
+ return "解析失败sub_title";
+ }
+ catch
+ {
+ return "解析失败sub_title";
+ }
+
+ var nodeCatId = BaseRegex.GetStringJson(ref prodStr, "nodeCatId");
+
+ str_lst = BaseRegex.GetJsonArrStrJson(ref prodStr, "category");
+ try
+ {
+ var regex_str = str_lst.OrderByDescending(s => s.Length).FirstOrDefault();
+ wxClientProd.info.category = JsonHelper.DeserializeJsonToListNullable(regex_str);
+ if (wxClientProd.info.category != null && !str_lst.IsNullOrEmpty() && !wxClientProd.info.category.Any(c => c.catIdStr == nodeCatId))
+ {
+ wxClientProd.info.category.Add(new wx_client_category() { catId = nodeCatId, cat_id = nodeCatId });
+ }
+ //if (wxClientProd.info.category == null)
+ // return "解析失败";
+ }
+ catch
+ {
+ return "解析失败category";
+ }
+
+ str_lst = BaseRegex.GetJsonObjStrJson(ref prodStr, "detail");
+ try
+ {
+ var regex_str = str_lst.OrderByDescending(s => s.Length).FirstOrDefault();
+ wxClientProd.info.detail = JsonHelper.DeserializeJsonToObjectNullable(regex_str);
+ if (wxClientProd.info.detail == null)
+ {
+ wxClientProd.info.detail = new wx_client_prod_detail();
+ wxClientProd.info.detail.detail_img.Add(wxClientProd.info.head_img.FirstOrDefault());
+ }
+
+ //if (wxClientProd.info.detail == null)
+ // return "解析失败";
+ }
+ catch
+ {
+ return "解析失败detail";
+ }
+
+ str_lst = BaseRegex.GetJsonArrStrJson(ref prodStr, "param");
+ try
+ {
+ var regex_str = str_lst.OrderByDescending(s => s.Length).FirstOrDefault();
+ wxClientProd.info.param = JsonHelper.DeserializeJsonToListNullable(regex_str);
+ if (wxClientProd.info.param == null)
+ wxClientProd.info.param = new List();
+ //if (wxClientProd.info.param == null)
+ // return "解析失败";
+ }
+ catch
+ {
+ return "解析失败param";
+ }
+
+ //品牌id
+ wxClientProd.info.brand_id = BaseRegex.GetStringJson(ref prodStr, "brand_id");
+ //if (wxClientProd.info.brand_id.IsNullOrEmpty())
+ // return "解析失败";
+
+ str_lst = BaseRegex.GetJsonObjStrJson(ref prodStr, "sku_id_list");
+ try
+ {
+ var regex_str = str_lst.OrderByDescending(s => s.Length).FirstOrDefault();
+ wxClientProd.info.sku_id_list = JsonHelper.DeserializeJsonToObjectNullable(regex_str);
+ //if (wxClientProd.info.sku_id_list == null)
+ // return "解析失败";
+ }
+ catch
+ {
+ return "解析失败sku_id_list";
+ }
+
+ str_lst = BaseRegex.GetJsonObjStrJson(ref prodStr, "sku_list");
+ try
+ {
+ var regex_str = str_lst.OrderByDescending(s => s.Length).FirstOrDefault();
+ wxClientProd.info.sku_list = JsonHelper.DeserializeJsonToObjectNullable(regex_str);
+ //if (wxClientProd.info.sku_list == null)
+ // return "解析失败";
+ }
+ catch
+ {
+ return "解析失败sku_id_list";
+ }
+
+ if (wxClientProd.info.sku_list == null)
+ {
+ str_lst = BaseRegex.GetJsonArrStrJson(ref prodStr, "sku_info");
+ try
+ {
+ var regex_str = str_lst.OrderByDescending(s => s.Length).FirstOrDefault();
+ var sku_infos = JsonHelper.DeserializeJsonToListNullable(regex_str);
+ if (sku_infos != null)
+ {
+ wxClientProd.info.sku_list = new wx_sku();
+ wxClientProd.info.sku_list.sku_info = sku_infos;
+ }
+ }
+ catch
+ {
+ return "解析失败sku_info";
+ }
+ }
+
+ // 佣金商品 根据折扣价格和佣金比例减去佣金
+ if (wxClientProd.info.sku_list != null)
+ {
+ foreach (var sku in wxClientProd.info.sku_list.sku_info)
+ {
+ sku.price = (sku.price - (sku.price - sku.discounted_price) * (1m - realPricePer)).ParseToInt();
+ }
+ }
+
+ str_lst = BaseRegex.GetJsonArrStrJson(ref prodStr, "product_sale_attrs");
+ try
+ {
+ var regex_str = str_lst.OrderByDescending(s => s.Length).FirstOrDefault();
+ wxClientProd.info.product_sale_attrs = JsonHelper.DeserializeJsonToListNullable(regex_str);
+ //if (wxClientProd.info.product_sale_attrs == null)
+ // return "解析失败";
+ }
+ catch
+ {
+ return "解析失败product_sale_attrs";
+ }
+
+
+ //总销量
+ wxClientProd.info.total_sold_num = BaseRegex.GetStringJson(ref prodStr, "total_sold_num");
+ //if (wxClientProd.info.total_sold_num.IsNullOrEmpty())
+ // return "解析失败";
+
+ str_lst = BaseRegex.GetJsonObjStrJson(ref prodStr, "service_desc");
+ try
+ {
+ var regex_str = str_lst.OrderByDescending(s => s.Length).FirstOrDefault();
+ wxClientProd.info.service_desc = JsonHelper.DeserializeJsonToObjectNullable(regex_str);
+ //if (wxClientProd.info.service_desc == null)
+ // return "解析失败";
+ }
+ catch
+ {
+ return "解析失败service_desc";
+ }
+
+ str_lst = BaseRegex.GetJsonObjStrJson(ref prodStr, "express_info");
+ try
+ {
+ var regex_str = str_lst.OrderByDescending(s => s.Length).FirstOrDefault();
+ wxClientProd.info.express_info = JsonHelper.DeserializeJsonToObjectNullable(regex_str);
+ //if (wxClientProd.info.express_info == null)
+ // return;
+ }
+ catch
+ {
+ return "解析失败express_info";
+ }
+
+ str_lst = BaseRegex.GetJsonArrStrJson(ref prodStr, "headVideoInfo");
+ try
+ {
+ var regex_str = str_lst.OrderByDescending(s => s.Length).FirstOrDefault();
+ wxClientProd.info.headVideoInfo = JsonHelper.DeserializeJsonToListNullable(regex_str);
+ //if (wxClientProd.info.headVideoInfo == null)
+ // return "解析失败";
+ }
+ catch
+ {
+ return "解析失败headVideoInfo";
+ }
+
+ str_lst = BaseRegex.GetJsonObjStrJson(ref prodStr, "afterSaleInfo");
+ try
+ {
+ var regex_str = str_lst.OrderByDescending(s => s.Length).FirstOrDefault();
+ wxClientProd.info.afterSaleInfo = JsonHelper.DeserializeJsonToObjectNullable