微信类目获取
This commit is contained in:
1 parent
c2c4c8da1a
commit
ddc5f6490f
24 files changed
+1082
-268
No files matched your search
@@ -3,6 +3,8 @@ using KJD_Web.Model.ShopModel;
|
||||
using KJD_Web.Utils;
|
||||
using MySql.Data.MySqlClient;
|
||||
using NaiBa.Util.Extension;
|
||||
using NaiBa.Util.Helper;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
@@ -30,6 +32,7 @@ namespace KJD_Web.BLL.BXX
|
||||
string offline_supplier_id = RegexUtils.GetStringQuery(ref inputData, "offline_supplier_id")?.Replace("'", "\\'");
|
||||
string offline_supplier_name = RegexUtils.GetStringQuery(ref inputData, "offline_supplier_name")?.Replace("'", "\\'");
|
||||
string spu_id = RegexUtils.GetStringQuery(ref inputData, "spu_id")?.Replace("'", "\\'");
|
||||
//厂商直采微信商品使用skcid存储coid数据
|
||||
string skc_id = RegexUtils.GetStringQuery(ref inputData, "skc_id")?.Replace("'", "\\'");
|
||||
string price_text = RegexUtils.GetStringQuery(ref inputData, "price_text")?.Replace("'", "\\'");
|
||||
string main_cat_id = RegexUtils.GetStringQuery(ref inputData, "main_cat_id")?.Replace("'", "\\'");
|
||||
@@ -38,8 +41,8 @@ namespace KJD_Web.BLL.BXX
|
||||
string cat_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "cat_name"))?.Replace("'", "\\'");
|
||||
string ext_code = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "ext_code"))?.Replace("'", "\\'");
|
||||
string product_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "product_name"))?.Replace("'", "\\'");
|
||||
string product_json = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "product_json"))?.Replace("'", "\\'");
|
||||
string size_json = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "size_json"))?.Replace("'", "\\'");
|
||||
string product_json = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "product_json"));
|
||||
string size_json = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "size_json"));
|
||||
string main_img = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "main_img"))?.Replace("'", "\\'");
|
||||
string notes = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "notes"))?.Replace("'", "\\'");
|
||||
string product_get_type = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "product_get_type"))?.Replace("'", "\\'");
|
||||
@@ -70,11 +73,15 @@ namespace KJD_Web.BLL.BXX
|
||||
"add_time,mdy_time) " +
|
||||
"values ('" + from_shop_id + "','" + from_shop_name + "','" + offline_supplier_id + "','" + offline_supplier_name + "','" + spu_id + "','" +
|
||||
skc_id + "','" + main_cat_id + "','" + main_cat_name + "','" + cat_id + "','" + cat_name + "','" + price_text + "','" + product_name + "','" +
|
||||
ext_code + "','" + main_img + "','" + product_json + "','" + size_json + "','" + notes + "','" + product_get_type + "','" +
|
||||
ext_code + "','" + main_img + "',@product_json,@size_json,'" + notes + "','" + product_get_type + "','" +
|
||||
sale_count + "','" + sale_count_text + "','" + special_prod_type + "'," + distribution_set.ParseToInt() + ",'" +
|
||||
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','" +
|
||||
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "');";
|
||||
var rst = mySql.ExecuteNonQuery(sql);
|
||||
|
||||
List<MySqlParameter> paramLst = new List<MySqlParameter>();
|
||||
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "product_json", Value = product_json, });
|
||||
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "size_json", Value = size_json, });
|
||||
var rst = mySql.ExecuteNonQuery(sql, paramLst.ToArray());
|
||||
mySql.Close();
|
||||
if (rst)
|
||||
{
|
||||
@@ -112,8 +119,8 @@ namespace KJD_Web.BLL.BXX
|
||||
string cat_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "cat_name"))?.Replace("'", "\\'");
|
||||
string ext_code = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "ext_code"))?.Replace("'", "\\'");
|
||||
string product_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "product_name"))?.Replace("'", "\\'");
|
||||
string product_json = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "product_json"))?.Replace("'", "\\'");
|
||||
string size_json = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "size_json"))?.Replace("'", "\\'");
|
||||
string product_json = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "product_json"));
|
||||
string size_json = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "size_json"));
|
||||
string main_img = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "main_img"))?.Replace("'", "\\'");
|
||||
string group = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "group"))?.Replace("'", "\\'");
|
||||
string notes = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "notes"))?.Replace("'", "\\'");
|
||||
@@ -121,7 +128,10 @@ namespace KJD_Web.BLL.BXX
|
||||
string sale_count_text = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sale_count_text"))?.Replace("'", "\\'");
|
||||
string wx_safe_status = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "wx_safe_status"))?.Replace("'", "\\'");
|
||||
string special_prod_type = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "special_prod_type"))?.Replace("'", "\\'");
|
||||
string wx_cate = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "wx_cate"))?.Replace("'", "\\'");
|
||||
string wx_cat_1 = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "wx_cat_1"))?.Replace("'", "\\'");
|
||||
string wx_cat_2 = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "wx_cat_2"))?.Replace("'", "\\'");
|
||||
string wx_cat_3 = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "wx_cat_3"))?.Replace("'", "\\'");
|
||||
string wx_cat_leaf = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "wx_cat_leaf"))?.Replace("'", "\\'");
|
||||
string delivery_fee_set = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "delivery_fee_set"))?.Replace("'", "\\'");
|
||||
string after_sale_set = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "after_sale_set"))?.Replace("'", "\\'");
|
||||
string distribution_set = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "distribution_set"))?.Replace("'", "\\'");
|
||||
@@ -161,9 +171,9 @@ namespace KJD_Web.BLL.BXX
|
||||
if (main_img != null)
|
||||
sql += " p.main_img='" + main_img + "',";
|
||||
if (product_json != null)
|
||||
sql += " p.product_json='" + product_json + "',";
|
||||
sql += " p.product_json=@product_json,";
|
||||
if (size_json != null)
|
||||
sql += " p.size_json='" + size_json + "',";
|
||||
sql += " p.size_json=@size_json,";
|
||||
if (group != null)
|
||||
sql += " p.group='" + group + "',";
|
||||
if (notes != null)
|
||||
@@ -176,8 +186,14 @@ namespace KJD_Web.BLL.BXX
|
||||
sql += " p.wx_safe_status='" + wx_safe_status + "',";
|
||||
if (special_prod_type != null && special_prod_type != "")
|
||||
sql += " p.special_prod_type='" + special_prod_type + "',";
|
||||
if (wx_cate != null)
|
||||
sql += " p.wx_cate='" + wx_cate + "',";
|
||||
if (wx_cat_1 != null)
|
||||
sql += " p.wx_cat_1=" + wx_cat_1 + ",";
|
||||
if (wx_cat_2 != null)
|
||||
sql += " p.wx_cat_2=" + wx_cat_2 + ",";
|
||||
if (wx_cat_3 != null)
|
||||
sql += " p.wx_cat_3=" + wx_cat_3 + ",";
|
||||
if (wx_cat_leaf != null)
|
||||
sql += " p.wx_cat_leaf=" + wx_cat_leaf + ",";
|
||||
if (delivery_fee_set != null)
|
||||
sql += " p.delivery_fee_set='" + delivery_fee_set + "',";
|
||||
if (after_sale_set != null)
|
||||
@@ -187,7 +203,12 @@ namespace KJD_Web.BLL.BXX
|
||||
sql += " p.mdy_time='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',";
|
||||
sql = sql.TrimEnd(',');
|
||||
sql += " where spu_id='" + spu_id + "';";
|
||||
var rst = mySql.ExecuteNonQuery(sql);
|
||||
|
||||
List<MySqlParameter> paramLst = new List<MySqlParameter>();
|
||||
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "product_json", Value = product_json, });
|
||||
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "size_json", Value = size_json, });
|
||||
|
||||
var rst = mySql.ExecuteNonQuery(sql, paramLst.ToArray());
|
||||
mySql.Close();
|
||||
if (rst)
|
||||
{
|
||||
@@ -230,6 +251,7 @@ 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 has_wx_cat = RegexUtils.GetStringQuery(ref inputData, "has_wx_cat")?.Replace("'", "\\'");
|
||||
|
||||
int page = RegexUtils.GetStringQuery(ref inputData, "page").ParseToInt();
|
||||
int page_size= RegexUtils.GetStringQuery(ref inputData, "page_size").ParseToInt(50);
|
||||
@@ -267,13 +289,20 @@ namespace KJD_Web.BLL.BXX
|
||||
where += " and p.group like '%" + search_group + "%'";
|
||||
if (!string.IsNullOrWhiteSpace(search_notes))
|
||||
where += " and p.notes like '%" + search_notes + "%'";
|
||||
if (!string.IsNullOrEmpty(has_wx_cat))
|
||||
{
|
||||
if (has_wx_cat == "true")
|
||||
where += " and wx_cat_leaf is NOT NULL";
|
||||
else
|
||||
where += " and wx_cat_leaf is NULL";
|
||||
}
|
||||
// 供应商货源是否已完成初始设置
|
||||
if (!string.IsNullOrEmpty(is_supplier_prod_ok))
|
||||
{
|
||||
if (is_supplier_prod_ok == "1" || is_supplier_prod_ok == "已设置")
|
||||
where += " and wx_cate!='' and delivery_fee_set=1 and after_sale_set=1 and distribution_set=1";
|
||||
where += " and wx_cat_leaf IS NOT NULL and send_to_out_server=1 and delivery_fee_set=1 and after_sale_set=1 and distribution_set=1";
|
||||
else
|
||||
where += " and (wx_cate='' or delivery_fee_set=0 or after_sale_set=0 or distribution_set=0)";
|
||||
where += " and (wx_cat_leaf IS NULL or send_to_out_server=0 or delivery_fee_set=0 or after_sale_set=0 or distribution_set=0)";
|
||||
}
|
||||
sql += where;
|
||||
|
||||
@@ -294,7 +323,8 @@ namespace KJD_Web.BLL.BXX
|
||||
else if (string.IsNullOrEmpty(get_select_count))
|
||||
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_cate," +
|
||||
" 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," +
|
||||
" 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" +
|
||||
@@ -303,7 +333,8 @@ namespace KJD_Web.BLL.BXX
|
||||
else
|
||||
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_cate" +
|
||||
" 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" +
|
||||
" 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" +
|
||||
@@ -341,7 +372,10 @@ namespace KJD_Web.BLL.BXX
|
||||
spu_id = row["spu_id"].ToString(),
|
||||
cat_id = row["cat_id"].ToString(),
|
||||
cat_name = row["cat_name"].ToString(),
|
||||
wx_cate = row["wx_cate"].ToString(),
|
||||
wx_cat_1 = row["wx_cat_1"].ToString(),
|
||||
wx_cat_2 = row["wx_cat_2"].ToString(),
|
||||
wx_cat_3 = row["wx_cat_3"].ToString(),
|
||||
wx_cat_leaf = row["wx_cat_leaf"].ToString(),
|
||||
product_name = row["product_name"].ToString(),
|
||||
main_img = row["main_img"].ToString(),
|
||||
ext_code = row["ext_code"].ToString(),
|
||||
@@ -661,9 +695,9 @@ namespace KJD_Web.BLL.BXX
|
||||
if (!string.IsNullOrEmpty(is_supplier_prod_ok))
|
||||
{
|
||||
if (is_supplier_prod_ok == "1" || is_supplier_prod_ok == "已设置")
|
||||
where += " and wx_cate!='' and delivery_fee_set=1 and after_sale_set=1 and distribution_set=1";
|
||||
where += " and wx_cat_leaf IS NOT NULL and send_to_out_server=1 and delivery_fee_set=1 and after_sale_set=1 and distribution_set=1";
|
||||
else
|
||||
where += " and (wx_cate='' or delivery_fee_set=0 or after_sale_set=0 or distribution_set=0)";
|
||||
where += " and (wx_cat_leaf IS NULL or send_to_out_server=0 or delivery_fee_set=0 or after_sale_set=0 or distribution_set=0)";
|
||||
}
|
||||
sql += where;
|
||||
|
||||
@@ -677,8 +711,10 @@ namespace KJD_Web.BLL.BXX
|
||||
else
|
||||
{
|
||||
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.select_total_count,p.product_get_type,p.sale_count,p.sale_count_text," +
|
||||
"p.fission_words,p.head_words,p.end_words,p.wx_safe_status,p.special_prod_type from bxx.product p where p.is_del=0";
|
||||
" p.product_name,p.main_img,p.group,p.notes,p.add_time,p.mdy_time,p.select_total_count,p.product_get_type,p.sale_count,p.sale_count_text," +
|
||||
" p.fission_words,p.head_words,p.end_words,p.wx_safe_status,p.special_prod_type,p.wx_cat_1,p.wx_cat_2,p.wx_cat_3," +
|
||||
" p.wx_cat_leaf" +
|
||||
" from bxx.product p where p.is_del=0";
|
||||
|
||||
//where子句
|
||||
sql += where;
|
||||
@@ -706,6 +742,10 @@ namespace KJD_Web.BLL.BXX
|
||||
cat_name = row["cat_name"].ToString(),
|
||||
main_cat_id = row["main_cat_id"].ToString(),
|
||||
main_cat_name = row["main_cat_name"].ToString(),
|
||||
wx_cat_1 = row["wx_cat_1"].ToString(),
|
||||
wx_cat_2 = row["wx_cat_2"].ToString(),
|
||||
wx_cat_3 = row["wx_cat_3"].ToString(),
|
||||
wx_cat_leaf = row["wx_cat_leaf"].ToString(),
|
||||
price_text = row["price_text"].ToString(),
|
||||
product_name = row["product_name"].ToString(),
|
||||
main_img = row["main_img"].ToString(),
|
||||
@@ -1646,6 +1686,120 @@ namespace KJD_Web.BLL.BXX
|
||||
}
|
||||
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
||||
}
|
||||
|
||||
public string GetWxTokens(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 id = (RegexUtils.GetStringQuery(ref inputData, "db_id")?.Replace("'", "\\'")).ParseToInt();
|
||||
if (id == 0)
|
||||
id = 1;
|
||||
|
||||
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
||||
MysqlUtils mySql = new MysqlUtils(conn);
|
||||
string sql = "select tokens,mdy_time from wxxd.wx_token WHERE id=" + id + ";";
|
||||
var rst = mySql.ExecuteDataTableRow(sql);
|
||||
mySql.Close();
|
||||
|
||||
if (!string.IsNullOrEmpty(mySql.Message))
|
||||
{
|
||||
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}";
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
string tokens = rst["tokens"].ParseToString();
|
||||
var mdyTime = Convert.ToDateTime(rst["mdy_time"]);
|
||||
if (mdyTime.AddMinutes(115) < DateTime.Now)
|
||||
{
|
||||
var tokenRst = HttpUtils.e57GetResponse("https://po.e57.cn/prod-api/api/sys-api/system/open/api/shop/list?userName=阿杰账户", "");
|
||||
if (!tokenRst.Contains("\"code\":0"))
|
||||
tokenRst = HttpUtils.e57GetResponse("https://po.e57.cn/prod-api/api/sys-api/system/open/api/shop/list?userName=阿杰账户", "");
|
||||
if (!tokenRst.Contains("\"code\":0"))
|
||||
{
|
||||
var errMsg = RegexUtils.GetStringJson(ref tokenRst, "msg");
|
||||
if (string.IsNullOrEmpty(errMsg))
|
||||
errMsg = tokenRst;
|
||||
return "{\"code\":500,\"msg\":\"" + errMsg + "\"}";
|
||||
}
|
||||
mdyTime = DateTime.Now;
|
||||
tokens = JsonUtils.SerializerObjectToString(JObject.Parse(tokenRst)["list"]);
|
||||
|
||||
conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
||||
mySql = new MysqlUtils(conn);
|
||||
sql = "update wxxd.wx_token set tokens='" + tokens + "' where id=1;";
|
||||
bool su = mySql.ExecuteNonQuery(sql);
|
||||
mySql.Close();
|
||||
|
||||
if (!string.IsNullOrEmpty(mySql.Message))
|
||||
{
|
||||
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}";
|
||||
}
|
||||
}
|
||||
return "{\"code\":200,\"tokens\":" + tokens + ",\"mdy_time\":\"" + mdyTime.ToString("yyyy-MM-dd HH:mm:ss") + "\"}";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return "{\"code\":500,\"msg\":\"" + ex.Message + "\"}";
|
||||
}
|
||||
}
|
||||
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
||||
}
|
||||
|
||||
public string GetWxAllCate(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\":\"校验失败\"}";
|
||||
string token = RegexUtils.GetStringQuery(ref inputData, "token", true);
|
||||
return HttpUtils.WxApiGetResponse("https://api.weixin.qq.com/shop/ec/category/all?access_token=" + token, "");
|
||||
}
|
||||
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
||||
}
|
||||
|
||||
public string WxApiCategoryClassify(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\":\"校验失败\"}";
|
||||
|
||||
string post_data = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "post_data"));
|
||||
string token = RegexUtils.GetStringQuery(ref inputData, "token");
|
||||
|
||||
return HttpUtils.WxApiPostResponse("https://api.weixin.qq.com/channels/ec/product/category/classify?access_token=" + token, post_data, "");
|
||||
}
|
||||
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
||||
}
|
||||
|
||||
public string WxApiUploadImage(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\":\"校验失败\"}";
|
||||
|
||||
string post_data = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "post_data"));
|
||||
string token = RegexUtils.GetStringQuery(ref inputData, "token");
|
||||
|
||||
//https://api.weixin.qq.com/shop/ec/basics/img/upload?access_token=ACCESS_TOKEN&upload_type=1&resp_type=1
|
||||
return HttpUtils.WxApiPostResponse("https://api.weixin.qq.com/shop/ec/basics/img/upload?access_token=" + token +
|
||||
"&upload_type=1&resp_type=1", post_data, "");
|
||||
}
|
||||
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -348,5 +348,53 @@ namespace KJD_Web
|
||||
Context.Response.Write(result);
|
||||
Context.Response.End();
|
||||
}
|
||||
|
||||
[WebMethod]
|
||||
public void get_wx_all_cate()
|
||||
{
|
||||
string jsontext = GetRequestJsonString();
|
||||
|
||||
var result = jsontext;
|
||||
result = new BXXProductManage().GetWxAllCate(jsontext);
|
||||
|
||||
Context.Response.Write(result);
|
||||
Context.Response.End();
|
||||
}
|
||||
|
||||
[WebMethod]
|
||||
public void get_wx_tokens()
|
||||
{
|
||||
string jsontext = GetRequestJsonString();
|
||||
|
||||
var result = jsontext;
|
||||
result = new BXXProductManage().GetWxTokens(jsontext);
|
||||
|
||||
Context.Response.Write(result);
|
||||
Context.Response.End();
|
||||
}
|
||||
|
||||
[WebMethod]
|
||||
public void wx_api_category_classify()
|
||||
{
|
||||
string jsontext = GetRequestJsonString();
|
||||
|
||||
var result = jsontext;
|
||||
result = new BXXProductManage().WxApiCategoryClassify(jsontext);
|
||||
|
||||
Context.Response.Write(result);
|
||||
Context.Response.End();
|
||||
}
|
||||
|
||||
[WebMethod]
|
||||
public void wx_api_upload_image()
|
||||
{
|
||||
string jsontext = GetRequestJsonString();
|
||||
|
||||
var result = jsontext;
|
||||
result = new BXXProductManage().WxApiUploadImage(jsontext);
|
||||
|
||||
Context.Response.Write(result);
|
||||
Context.Response.End();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -114,6 +114,7 @@
|
||||
<Compile Include="BLL\WXXD\WXProductManage.cs" />
|
||||
<Compile Include="BLL\WXXD\WXShopManage.cs" />
|
||||
<Compile Include="BLL\WXXD\WXUserManage.cs" />
|
||||
<Compile Include="Utils\HttpUtils.cs" />
|
||||
<Compile Include="WXProductService.asmx.cs">
|
||||
<DependentUpon>WXProductService.asmx</DependentUpon>
|
||||
<SubType>Component</SubType>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<IISExpressWindowsAuthentication />
|
||||
<IISExpressUseClassicPipelineMode />
|
||||
<UseGlobalApplicationHostFile />
|
||||
<LastActiveSolutionConfig>Release|Any CPU</LastActiveSolutionConfig>
|
||||
<LastActiveSolutionConfig>Debug|Any CPU</LastActiveSolutionConfig>
|
||||
<ProjectView>ShowAllFiles</ProjectView>
|
||||
</PropertyGroup>
|
||||
<ProjectExtensions>
|
||||
|
||||
@@ -21,7 +21,10 @@ namespace KJD_Web.Model
|
||||
public string cat_id { get; set; }
|
||||
public string main_cat_name { get; set; }
|
||||
public string cat_name { get; set; }
|
||||
public string wx_cate { get; set; }
|
||||
public string wx_cat_1 { get; set; }
|
||||
public string wx_cat_2 { get; set; }
|
||||
public string wx_cat_3 { get; set; }
|
||||
public string wx_cat_leaf { get; set; }
|
||||
/// <summary>
|
||||
/// 母店价格
|
||||
/// </summary>
|
||||
|
||||
@@ -0,0 +1,178 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
|
||||
namespace KJD_Web.Utils
|
||||
{
|
||||
public class HttpUtils
|
||||
{
|
||||
public static string WxApiPostResponse(string _url, string _data, string referer)
|
||||
{
|
||||
HttpWebResponse response = null;
|
||||
string result;
|
||||
try
|
||||
{
|
||||
string url = _url;
|
||||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
|
||||
|
||||
request.KeepAlive = true;
|
||||
request.Headers.Set(HttpRequestHeader.CacheControl, "max-age=0");
|
||||
request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36";
|
||||
request.ContentType = "application/json";
|
||||
request.Accept = "*/*";
|
||||
request.Referer = referer;
|
||||
request.Headers.Set(HttpRequestHeader.AcceptEncoding, "gzip, deflate, br, zstd");
|
||||
request.Headers.Set(HttpRequestHeader.AcceptLanguage, "zh-CN,zh;q=0.9");
|
||||
|
||||
request.Method = "POST";
|
||||
request.ServicePoint.Expect100Continue = false;
|
||||
|
||||
string body = _data;
|
||||
byte[] postBytes = System.Text.Encoding.UTF8.GetBytes(body);
|
||||
request.ContentLength = postBytes.Length;
|
||||
Stream stream = request.GetRequestStream();
|
||||
stream.Write(postBytes, 0, postBytes.Length);
|
||||
stream.Close();
|
||||
|
||||
response = (HttpWebResponse)request.GetResponse();
|
||||
}
|
||||
catch (WebException ex)
|
||||
{
|
||||
if (ex.Status == WebExceptionStatus.ProtocolError)
|
||||
{
|
||||
response = (HttpWebResponse)ex.Response;
|
||||
result = ReadResponse(response);
|
||||
return result;
|
||||
}
|
||||
else return ex.Message;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (response != null) response.Close();
|
||||
return e.Message;
|
||||
}
|
||||
result = ReadResponse(response);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static string WxApiGetResponse(string _url, string referer)
|
||||
{
|
||||
HttpWebResponse response = null;
|
||||
string result;
|
||||
try
|
||||
{
|
||||
string url = _url;
|
||||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
|
||||
|
||||
request.KeepAlive = true;
|
||||
request.Headers.Set(HttpRequestHeader.CacheControl, "max-age=0");
|
||||
request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36";
|
||||
request.ContentType = "application/json";
|
||||
request.Accept = "*/*";
|
||||
request.Referer = referer;
|
||||
request.Headers.Set(HttpRequestHeader.AcceptEncoding, "gzip, deflate, br, zstd");
|
||||
request.Headers.Set(HttpRequestHeader.AcceptLanguage, "zh-CN,zh;q=0.9");
|
||||
|
||||
response = (HttpWebResponse)request.GetResponse();
|
||||
}
|
||||
catch (WebException ex)
|
||||
{
|
||||
if (ex.Status == WebExceptionStatus.ProtocolError)
|
||||
{
|
||||
response = (HttpWebResponse)ex.Response;
|
||||
result = ReadResponse(response);
|
||||
return result;
|
||||
}
|
||||
else return ex.Message;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (response != null) response.Close();
|
||||
return e.Message;
|
||||
}
|
||||
result = ReadResponse(response);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static string e57GetResponse(string _url, string referer)
|
||||
{
|
||||
HttpWebResponse response = null;
|
||||
string result;
|
||||
try
|
||||
{
|
||||
string url = _url;
|
||||
|
||||
HttpWebRequest request;
|
||||
if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true;
|
||||
ServicePointManager.SecurityProtocol =
|
||||
ServicePointManager.SecurityProtocol | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
|
||||
request = WebRequest.Create(url) as HttpWebRequest;
|
||||
request.ProtocolVersion = HttpVersion.Version10;
|
||||
}
|
||||
else
|
||||
request = (HttpWebRequest)WebRequest.Create(url);
|
||||
|
||||
request.KeepAlive = true;
|
||||
request.Headers.Add("sec-ch-ua", @"""Not(A:Brand"";v=""8"", ""Chromium"";v=""144"", ""Google Chrome"";v=""144""");
|
||||
request.Headers.Add("sec-ch-ua-mobile", @"?0");
|
||||
request.Headers.Add("sec-ch-ua-platform", @"""Windows""");
|
||||
request.Headers.Add("Upgrade-Insecure-Requests", @"1");
|
||||
request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36";
|
||||
request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7";
|
||||
request.Headers.Add("Sec-Fetch-Site", @"none");
|
||||
request.Headers.Add("Sec-Fetch-Mode", @"navigate");
|
||||
request.Headers.Add("Sec-Fetch-User", @"?1");
|
||||
request.Headers.Add("Sec-Fetch-Dest", @"document");
|
||||
request.Headers.Set(HttpRequestHeader.AcceptEncoding, "gzip, deflate");
|
||||
request.Headers.Set(HttpRequestHeader.AcceptLanguage, "zh-CN,zh;q=0.9");
|
||||
|
||||
response = (HttpWebResponse)request.GetResponse();
|
||||
}
|
||||
catch (WebException ex)
|
||||
{
|
||||
if (ex.Status == WebExceptionStatus.ProtocolError)
|
||||
{
|
||||
response = (HttpWebResponse)ex.Response;
|
||||
result = ReadResponse(response);
|
||||
return result;
|
||||
}
|
||||
else return ex.Message;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (response != null) response.Close();
|
||||
return e.Message;
|
||||
}
|
||||
result = ReadResponse(response);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static string ReadResponse(HttpWebResponse response)
|
||||
{
|
||||
using (Stream responseStream = response.GetResponseStream())
|
||||
{
|
||||
Stream streamToRead = responseStream;
|
||||
if (response.ContentEncoding.ToLower().Contains("gzip"))
|
||||
{
|
||||
streamToRead = new GZipStream(streamToRead, CompressionMode.Decompress);
|
||||
}
|
||||
else if (response.ContentEncoding.ToLower().Contains("deflate"))
|
||||
{
|
||||
streamToRead = new DeflateStream(streamToRead, CompressionMode.Decompress);
|
||||
}
|
||||
|
||||
using (StreamReader streamReader = new StreamReader(streamToRead, Encoding.UTF8))
|
||||
{
|
||||
return streamReader.ReadToEnd();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using MySqlX.XDevAPI.Common;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Web;
|
||||
@@ -621,13 +623,16 @@ namespace KJD_Web.Utils
|
||||
/// <param name="html"></param>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetStringQuery(ref string queryString, string key)
|
||||
public static string GetStringQuery(ref string queryString, string key, bool isGetJson = false)
|
||||
{
|
||||
List<string> strLst = queryString.Split('&').ToList();
|
||||
var temp = strLst.FirstOrDefault(s => s.StartsWith(key + "="));
|
||||
if (temp != null)
|
||||
temp = ("&" + temp).Replace("&" + key + "=", "");
|
||||
|
||||
if (temp == null && isGetJson)
|
||||
temp = GetStringJson(ref queryString, key);
|
||||
|
||||
//queryString = "&" + queryString;
|
||||
//int nIndex = queryString.IndexOf("&" + key + "=");
|
||||
//if (nIndex == -1)
|
||||
|
||||
Reference in new issue
Block a user