加入爆款数据 提供微信爆款数据采集功能
This commit is contained in:
1 parent
a3d15b1b3d
commit
be8c35ccb2
12 files changed
+796
-604
No files matched your search
@@ -505,6 +505,8 @@ namespace KJD_Web.BLL.BXX
|
||||
var sort_field = RegexUtils.GetStringQuery(ref inputData, "sort_field")?.Replace("'", "\\'");
|
||||
var wx_safe_status = RegexUtils.GetStringQuery(ref inputData, "wx_safe_status")?.Replace("'", "\\'");
|
||||
var special_prod_type = RegexUtils.GetStringQuery(ref inputData, "special_prod_type")?.Replace("'", "\\'");
|
||||
if (special_prod_type.IsNullOrEmpty())
|
||||
special_prod_type = "普通商品,书籍";
|
||||
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("'", "\\'");
|
||||
var send_to_out_server = RegexUtils.GetStringQuery(ref inputData, "send_to_out_server")?.Replace("'", "\\'");
|
||||
@@ -563,7 +565,7 @@ namespace KJD_Web.BLL.BXX
|
||||
// where += ") ";
|
||||
//}
|
||||
if (!string.IsNullOrEmpty(special_prod_type))
|
||||
where += " and p.special_prod_type ='" + special_prod_type + "'";
|
||||
where += " and p.special_prod_type in ('" + special_prod_type.Replace(",", "','") + "')";
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(search_spu))
|
||||
{
|
||||
|
||||
@@ -75,6 +75,7 @@
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Upload\Prod\WXProdHot.aspx" />
|
||||
<Content Include="Upload\Prod\WXProd.aspx" />
|
||||
<Content Include="WXProductService.asmx" />
|
||||
<Content Include="WXShopService.asmx" />
|
||||
@@ -132,8 +133,18 @@
|
||||
<Compile Include="Model\WxModel\WxOptimizeExpressInfo.cs" />
|
||||
<Compile Include="Model\WxProdSecretSpuIdShopIdMapParam.cs" />
|
||||
<Compile Include="Model\WXShopDefaultAddressInfo.cs" />
|
||||
<Compile Include="Upload\Prod\BaseClass.cs" />
|
||||
<Compile Include="Upload\Prod\BaseWxProd.cs" />
|
||||
<Compile Include="Upload\Prod\WXProdHot.aspx.cs">
|
||||
<DependentUpon>WXProdHot.aspx</DependentUpon>
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Upload\Prod\WXProdHot.aspx.designer.cs">
|
||||
<DependentUpon>WXProdHot.aspx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Upload\Prod\WXProd.aspx.cs">
|
||||
<DependentUpon>WXProd.aspx</DependentUpon>
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Upload\Prod\WXProd.aspx.designer.cs">
|
||||
<DependentUpon>WXProd.aspx</DependentUpon>
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
using KJD_Web.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
namespace KJD_Web.Upload.Prod
|
||||
{
|
||||
|
||||
public class BaseClass
|
||||
{
|
||||
public static string BuildPDDObjString(string file, bool IsLoginDef = false)
|
||||
{
|
||||
string LoginApiUrl = "http://1.13.195.131:9001";
|
||||
string MainPath = "kuajingda";
|
||||
return LoginApiUrl + "/bxx_" + file + "?obj=" + MainPath + "/bxx_" + file;
|
||||
}
|
||||
|
||||
public static int TimeDifferent = 0;
|
||||
public static int VersionCount = 99999999;
|
||||
public static int CompanyId = 1;
|
||||
public static string CompanyName = "1";
|
||||
public static string UserKey = "1";
|
||||
public static string Mobile = "18888888888";
|
||||
public static string UserName = "18888888888";
|
||||
public static string ShopId = "18888888888";
|
||||
public static string ShopName = "18888888888";
|
||||
}
|
||||
|
||||
public class UserLogin
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取签名字符串,新版
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static string GetSignaturex()
|
||||
{
|
||||
return GetSignaturex(BaseClass.ShopId, BaseClass.ShopName);
|
||||
}
|
||||
public static string GetSignaturex(string shopId, string shopName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(shopId))
|
||||
shopId = "11111111";
|
||||
if (string.IsNullOrEmpty(shopName))
|
||||
shopName = "wx11111111";
|
||||
int time = TimeUtils.DateTimeToTimestampSeconds(DateTime.Now) + BaseClass.TimeDifferent;
|
||||
string time1 = EncrypUtil.Encryption(time);
|
||||
return "time=" + time + "&code=" + time1 + "&NbCodeVersion=1" + "&version=" + BaseClass.VersionCount +
|
||||
"&company_id=" + BaseClass.CompanyId + "&company=" + HtmlUtils.UrlEncodeUtf8(BaseClass.CompanyName) +
|
||||
"&user_name=" + BaseClass.UserName + "&user_key=" + BaseClass.UserKey + "&mobile=" + BaseClass.Mobile +
|
||||
"&sid=" + shopId + "&shop=" + HtmlUtils.UrlEncodeUtf8(shopName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,408 @@
|
||||
using KJD_Web.Utils;
|
||||
using KJD_WebService.Model.WxModel;
|
||||
using NaiBa.Util.Extension;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
|
||||
namespace KJD_Web.Upload.Prod
|
||||
{
|
||||
public class BaseWxProd
|
||||
{
|
||||
public string getProd(string prodStr, string special_prod_type = null)
|
||||
{
|
||||
var reducePer = 0m;
|
||||
var realPricePer = 1m - reducePer * 0.01m;
|
||||
if (realPricePer < 0.1m)
|
||||
realPricePer = 0.1m;
|
||||
|
||||
WXClientProductInfoLite wxClientProd = new WXClientProductInfoLite();
|
||||
|
||||
var str_lst = RegexUtils.GetJsonObjStrJson(ref prodStr, "product_key");
|
||||
try
|
||||
{
|
||||
var regex_str = str_lst.OrderByDescending(s => s.Length).FirstOrDefault();
|
||||
wxClientProd.product_key = JsonUtils.DeserializeJsonToObject<wx_client_prod_key>(regex_str);
|
||||
if (wxClientProd.product_key == null)
|
||||
return "解析失败product_key";
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "解析失败product_key";
|
||||
}
|
||||
|
||||
//商品详情格式
|
||||
wxClientProd.info = new wx_client_prod_info();
|
||||
|
||||
//主标题
|
||||
wxClientProd.info.title = RegexUtils.GetStringJson(ref prodStr, "title");
|
||||
if (wxClientProd.info.title.IsNullOrEmpty())
|
||||
return "解析失败title";
|
||||
|
||||
//副标题
|
||||
wxClientProd.info.sub_title = RegexUtils.GetStringJson(ref prodStr, "sub_title");
|
||||
|
||||
str_lst = RegexUtils.GetJsonArrStrJson(ref prodStr, "head_img");
|
||||
try
|
||||
{
|
||||
var regex_str = str_lst.OrderByDescending(s => s.Length).FirstOrDefault();
|
||||
wxClientProd.info.head_img = JsonUtils.DeserializeJsonToListNullable<string>(regex_str);
|
||||
if (wxClientProd.info.head_img == null)
|
||||
return "解析失败head_img";
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "解析失败head_img";
|
||||
}
|
||||
|
||||
var nodeCatId = RegexUtils.GetStringJson(ref prodStr, "nodeCatId");
|
||||
|
||||
str_lst = RegexUtils.GetJsonArrStrJson(ref prodStr, "category");
|
||||
try
|
||||
{
|
||||
var regex_str = str_lst.OrderByDescending(s => s.Length).FirstOrDefault();
|
||||
wxClientProd.info.category = JsonUtils.DeserializeJsonToListNullable<wx_client_category>(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 = RegexUtils.GetJsonObjStrJson(ref prodStr, "detail");
|
||||
try
|
||||
{
|
||||
var regex_str = str_lst.OrderByDescending(s => s.Length).FirstOrDefault();
|
||||
wxClientProd.info.detail = JsonUtils.DeserializeJsonToObjectNullable<wx_client_prod_detail>(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 = RegexUtils.GetJsonArrStrJson(ref prodStr, "param");
|
||||
try
|
||||
{
|
||||
var regex_str = str_lst.OrderByDescending(s => s.Length).FirstOrDefault();
|
||||
wxClientProd.info.param = JsonUtils.DeserializeJsonToListNullable<wx_client_param>(regex_str);
|
||||
if (wxClientProd.info.param == null)
|
||||
wxClientProd.info.param = new List<wx_client_param>();
|
||||
//if (wxClientProd.info.param == null)
|
||||
// return "解析失败";
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "解析失败param";
|
||||
}
|
||||
|
||||
//品牌id
|
||||
wxClientProd.info.brand_id = RegexUtils.GetStringJson(ref prodStr, "brand_id");
|
||||
//if (wxClientProd.info.brand_id.IsNullOrEmpty())
|
||||
// return "解析失败";
|
||||
|
||||
str_lst = RegexUtils.GetJsonObjStrJson(ref prodStr, "sku_id_list");
|
||||
try
|
||||
{
|
||||
var regex_str = str_lst.OrderByDescending(s => s.Length).FirstOrDefault();
|
||||
wxClientProd.info.sku_id_list = JsonUtils.DeserializeJsonToObjectNullable<wx_client_sku_id_list>(regex_str);
|
||||
//if (wxClientProd.info.sku_id_list == null)
|
||||
// return "解析失败";
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "解析失败sku_id_list";
|
||||
}
|
||||
|
||||
str_lst = RegexUtils.GetJsonObjStrJson(ref prodStr, "sku_list");
|
||||
try
|
||||
{
|
||||
var regex_str = str_lst.OrderByDescending(s => s.Length).FirstOrDefault();
|
||||
wxClientProd.info.sku_list = JsonUtils.DeserializeJsonToObjectNullable<wx_sku>(regex_str);
|
||||
//if (wxClientProd.info.sku_list == null)
|
||||
// return "解析失败";
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "解析失败sku_list";
|
||||
}
|
||||
|
||||
if (wxClientProd.info.sku_list == null)
|
||||
{
|
||||
str_lst = RegexUtils.GetJsonArrStrJson(ref prodStr, "sku_info");
|
||||
try
|
||||
{
|
||||
var regex_str = str_lst.OrderByDescending(s => s.Length).FirstOrDefault();
|
||||
var sku_infos = JsonUtils.DeserializeJsonToListNullable<wx_client_sku_info>(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 = RegexUtils.GetJsonArrStrJson(ref prodStr, "product_sale_attrs");
|
||||
try
|
||||
{
|
||||
var regex_str = str_lst.OrderByDescending(s => s.Length).FirstOrDefault();
|
||||
wxClientProd.info.product_sale_attrs = JsonUtils.DeserializeJsonToListNullable<wx_client_product_sale_attr>(regex_str);
|
||||
//if (wxClientProd.info.product_sale_attrs == null)
|
||||
// return "解析失败";
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "解析失败product_sale_attrs";
|
||||
}
|
||||
|
||||
|
||||
//总销量
|
||||
wxClientProd.info.total_sold_num = RegexUtils.GetStringJson(ref prodStr, "total_sold_num");
|
||||
//if (wxClientProd.info.total_sold_num.IsNullOrEmpty())
|
||||
// return "解析失败";
|
||||
|
||||
str_lst = RegexUtils.GetJsonObjStrJson(ref prodStr, "service_desc");
|
||||
try
|
||||
{
|
||||
var regex_str = str_lst.OrderByDescending(s => s.Length).FirstOrDefault();
|
||||
wxClientProd.info.service_desc = JsonUtils.DeserializeJsonToObjectNullable<wx_client_service_desc>(regex_str);
|
||||
//if (wxClientProd.info.service_desc == null)
|
||||
// return "解析失败";
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "解析失败service_desc";
|
||||
}
|
||||
|
||||
str_lst = RegexUtils.GetJsonObjStrJson(ref prodStr, "express_info");
|
||||
try
|
||||
{
|
||||
var regex_str = str_lst.OrderByDescending(s => s.Length).FirstOrDefault();
|
||||
wxClientProd.info.express_info = JsonUtils.DeserializeJsonToObjectNullable<wx_client_express_info>(regex_str);
|
||||
//if (wxClientProd.info.express_info == null)
|
||||
// return;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "解析失败express_info";
|
||||
}
|
||||
|
||||
str_lst = RegexUtils.GetJsonArrStrJson(ref prodStr, "headVideoInfo");
|
||||
try
|
||||
{
|
||||
var regex_str = str_lst.OrderByDescending(s => s.Length).FirstOrDefault();
|
||||
wxClientProd.info.headVideoInfo = JsonUtils.DeserializeJsonToListNullable<wx_client_head_video_info>(regex_str);
|
||||
//if (wxClientProd.info.headVideoInfo == null)
|
||||
// return "解析失败";
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "解析失败headVideoInfo";
|
||||
}
|
||||
|
||||
str_lst = RegexUtils.GetJsonObjStrJson(ref prodStr, "afterSaleInfo");
|
||||
try
|
||||
{
|
||||
var regex_str = str_lst.OrderByDescending(s => s.Length).FirstOrDefault();
|
||||
wxClientProd.info.afterSaleInfo = JsonUtils.DeserializeJsonToObjectNullable<object>(regex_str);
|
||||
//if (wxClientProd.info.afterSaleInfo == null)
|
||||
// return "解析失败";
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "解析失败afterSaleInfo";
|
||||
}
|
||||
|
||||
str_lst = RegexUtils.GetJsonArrStrJson(ref prodStr, "deliveryExpressFee");
|
||||
try
|
||||
{
|
||||
var regex_str = str_lst.OrderByDescending(s => s.Length).FirstOrDefault();
|
||||
wxClientProd.info.deliveryExpressFee = JsonUtils.DeserializeJsonToListNullable<object>(regex_str);
|
||||
//if (wxClientProd.info.deliveryExpressFee == null)
|
||||
// return "解析失败";
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "解析失败deliveryExpressFee";
|
||||
}
|
||||
|
||||
str_lst = RegexUtils.GetJsonArrStrJson(ref prodStr, "templateInfo");
|
||||
try
|
||||
{
|
||||
var regex_str = str_lst.OrderByDescending(s => s.Length).FirstOrDefault();
|
||||
wxClientProd.info.templateInfo = JsonUtils.DeserializeJsonToListNullable<object>(regex_str);
|
||||
//if (wxClientProd.info.templateInfo == null)
|
||||
// return "解析失败";
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "解析失败templateInfo";
|
||||
}
|
||||
|
||||
wxClientProd.info.spuCode = RegexUtils.GetStringJson(ref prodStr, "spuCode");
|
||||
|
||||
str_lst = RegexUtils.GetJsonArrStrJson(ref prodStr, "productSkus");
|
||||
try
|
||||
{
|
||||
var regex_str = str_lst.OrderByDescending(s => s.Length).FirstOrDefault();
|
||||
wxClientProd.productSkus = JsonUtils.DeserializeJsonToList<WXProductSkuInfoLite>(regex_str);
|
||||
if (wxClientProd.productSkus == null)
|
||||
return "解析失败productSkus";
|
||||
}
|
||||
catch
|
||||
{
|
||||
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, special_prod_type);
|
||||
}
|
||||
|
||||
public string SaveWxProd(string prodId, WXClientProductInfoLite wxClientProdInfoLite, string baseProdStr, string special_prod_type = null)
|
||||
{
|
||||
bool isExist = false;
|
||||
var existUrl = BaseClass.BuildPDDObjString("product/get_product_spu_id_list");
|
||||
string existData = UserLogin.GetSignaturex() + "&search_spu_ids=" + prodId;
|
||||
//if (!string.IsNullOrEmpty(prod.dbProduct.real_spu_id))
|
||||
// existData = UserLogin.GetSignaturex() + "&search_spu_ids=" + prod.spuId + "," + prod.dbProduct.real_spu_id;
|
||||
string html = HtmlUtils.PostUtf8(existUrl, existData);
|
||||
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
||||
html = HtmlUtils.PostUtf8(existUrl, existData);
|
||||
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
||||
{
|
||||
return "采集入库失败,产品数据库连接失败";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (html.Contains("\"data\":[") && !html.Contains("\"data\":[]"))
|
||||
isExist = true;
|
||||
}
|
||||
|
||||
var url = BaseClass.BuildPDDObjString("product/add_product");
|
||||
if (isExist)
|
||||
url = BaseClass.BuildPDDObjString("product/mdy_product");
|
||||
|
||||
var skus = wxClientProdInfoLite.productSkus;
|
||||
|
||||
var product_json = "{\"wxxdData\":" + JsonUtils.SerializeObject(wxClientProdInfoLite) + ",\"baseData\":" + JsonUtils.SerializeObject(baseProdStr) + "}";
|
||||
var data = UserLogin.GetSignaturex() +
|
||||
"&from_shop_id=" + wxClientProdInfoLite.product_key.appid +
|
||||
"&from_shop_name=" + wxClientProdInfoLite.product_key.appid +
|
||||
"&spu_id=" + prodId +
|
||||
"&skc_id=" + prodId +
|
||||
"&price_text=" + skus.Min(s => s.productSkuInfo.salePrice * 0.01m) + " - " + skus.Max(s => s.productSkuInfo.salePrice * 0.01m) +
|
||||
"&ext_code=" + wxClientProdInfoLite.info.spuCode +
|
||||
"&product_name=" + HttpUtility.UrlEncode(wxClientProdInfoLite.info.title, Encoding.UTF8) +
|
||||
"&product_json=" + HttpUtility.UrlEncode(product_json, Encoding.UTF8) + // product_json /*HttpUtility.UrlEncode(JsonUtils.SerializeObject(wxClientProdInfoLite), Encoding.UTF8)*/
|
||||
"&sale_count=" + wxClientProdInfoLite.info.total_sold_num +
|
||||
"&sale_count_text=" + wxClientProdInfoLite.info.total_sold_num +
|
||||
"&main_img=" + HttpUtility.UrlEncode(wxClientProdInfoLite.info.head_img.FirstOrDefault(), Encoding.UTF8) +
|
||||
"&wx_safe_status=" + HttpUtility.UrlEncode("安全商品", Encoding.UTF8) +
|
||||
"&product_get_type=" + HttpUtility.UrlEncode("微信小店", Encoding.UTF8);
|
||||
|
||||
if (wxClientProdInfoLite.info.category.Count > 0)
|
||||
{
|
||||
data += "&wx_cat_1=" + wxClientProdInfoLite.info.category[0].catIdStr;
|
||||
data += "&main_cat_id=" + wxClientProdInfoLite.info.category[0].catIdStr;
|
||||
data += "&main_cat_name=" + wxClientProdInfoLite.info.category[0].name;
|
||||
|
||||
data += "&wx_cat_leaf=" + wxClientProdInfoLite.info.category.LastOrDefault()?.catIdStr;
|
||||
data += "&cat_id=" + wxClientProdInfoLite.info.category.LastOrDefault()?.catIdStr;
|
||||
data += "&cat_name=" + HttpUtility.UrlEncode((wxClientProdInfoLite.info.category.LastOrDefault()?.name).ParseToString(), Encoding.UTF8);
|
||||
}
|
||||
if (wxClientProdInfoLite.info.category.Count > 1)
|
||||
{
|
||||
data += "&wx_cat_2=" + wxClientProdInfoLite.info.category[1].catIdStr;
|
||||
}
|
||||
if (wxClientProdInfoLite.info.category.Count > 2)
|
||||
{
|
||||
data += "&wx_cat_3=" + wxClientProdInfoLite.info.category[2].catIdStr;
|
||||
}
|
||||
|
||||
//if (wxClientProdInfoLite.info.category.FirstOrDefault().name == "图书")
|
||||
//{
|
||||
// data += "&special_prod_type=" + HttpUtility.UrlEncode("书籍", Encoding.UTF8);
|
||||
//}
|
||||
if (special_prod_type != null)
|
||||
{
|
||||
data += "&special_prod_type=" + special_prod_type;
|
||||
}
|
||||
|
||||
html = HtmlUtils.PostUtf8(url, data);
|
||||
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
||||
html = HtmlUtils.PostUtf8(url, data);
|
||||
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
||||
{
|
||||
string msg = "商品入库失败!请检查网络连接:" + RegexUtils.GetStringJson(ref html, "msg");
|
||||
//Invoke(new Action(() =>
|
||||
//{
|
||||
// row.Cells["colMsg"].Value = msg;
|
||||
//}));
|
||||
return msg;
|
||||
}
|
||||
else
|
||||
{
|
||||
//prod.getProductMsg = "商品入库成功!";
|
||||
//Invoke(new Action(() =>
|
||||
//{
|
||||
// row.Cells["colMsg"].Value = prod.getProductMsg;
|
||||
//}));
|
||||
if (!isExist)
|
||||
{
|
||||
url = BaseClass.BuildPDDObjString("product/mdy_product");
|
||||
html = HtmlUtils.PostUtf8(url, data);
|
||||
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
||||
html = HtmlUtils.PostUtf8(url, data);
|
||||
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
||||
{
|
||||
string msg = "商品入库失败!请检查网络连接:" + RegexUtils.GetStringJson(ref html, "msg");
|
||||
return msg;
|
||||
}
|
||||
}
|
||||
|
||||
return "微信商品采集入库成功!";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,51 +15,6 @@ using System.Web.UI.WebControls;
|
||||
|
||||
namespace KJD_Web.Upload.Prod
|
||||
{
|
||||
public class BaseClass
|
||||
{
|
||||
public static string BuildPDDObjString(string file, bool IsLoginDef = false)
|
||||
{
|
||||
string LoginApiUrl = "http://1.13.195.131:9001";
|
||||
string MainPath = "kuajingda";
|
||||
return LoginApiUrl + "/bxx_" + file + "?obj=" + MainPath + "/bxx_" + file;
|
||||
}
|
||||
|
||||
public static int TimeDifferent = 0;
|
||||
public static int VersionCount = 99999999;
|
||||
public static int CompanyId = 1;
|
||||
public static string CompanyName = "1";
|
||||
public static string UserKey = "1";
|
||||
public static string Mobile = "18888888888";
|
||||
public static string UserName = "18888888888";
|
||||
public static string ShopId = "18888888888";
|
||||
public static string ShopName = "18888888888";
|
||||
}
|
||||
|
||||
public class UserLogin
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取签名字符串,新版
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static string GetSignaturex()
|
||||
{
|
||||
return GetSignaturex(BaseClass.ShopId, BaseClass.ShopName);
|
||||
}
|
||||
public static string GetSignaturex(string shopId, string shopName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(shopId))
|
||||
shopId = "11111111";
|
||||
if (string.IsNullOrEmpty(shopName))
|
||||
shopName = "wx11111111";
|
||||
int time = TimeUtils.DateTimeToTimestampSeconds(DateTime.Now) + BaseClass.TimeDifferent;
|
||||
string time1 = EncrypUtil.Encryption(time);
|
||||
return "time=" + time + "&code=" + time1 + "&NbCodeVersion=1" + "&version=" + BaseClass.VersionCount +
|
||||
"&company_id=" + BaseClass.CompanyId + "&company=" + HtmlUtils.UrlEncodeUtf8(BaseClass.CompanyName) +
|
||||
"&user_name=" + BaseClass.UserName + "&user_key=" + BaseClass.UserKey + "&mobile=" + BaseClass.Mobile +
|
||||
"&sid=" + shopId + "&shop=" + HtmlUtils.UrlEncodeUtf8(shopName);
|
||||
}
|
||||
}
|
||||
|
||||
public partial class WXProd : System.Web.UI.Page
|
||||
{
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
@@ -83,401 +38,7 @@ namespace KJD_Web.Upload.Prod
|
||||
{
|
||||
string prodStr = Encoding.UTF8.GetString(this.FileUpload1.FileBytes);
|
||||
prodStr = TextBox2.Text.Trim();
|
||||
return getProd(prodStr);
|
||||
}
|
||||
|
||||
public static string getProd(string prodStr, string special_prod_type = null)
|
||||
{
|
||||
var reducePer = 0m;
|
||||
var realPricePer = 1m - reducePer * 0.01m;
|
||||
if (realPricePer < 0.1m)
|
||||
realPricePer = 0.1m;
|
||||
|
||||
WXClientProductInfoLite wxClientProd = new WXClientProductInfoLite();
|
||||
|
||||
var str_lst = RegexUtils.GetJsonObjStrJson(ref prodStr, "product_key");
|
||||
try
|
||||
{
|
||||
var regex_str = str_lst.OrderByDescending(s => s.Length).FirstOrDefault();
|
||||
wxClientProd.product_key = JsonUtils.DeserializeJsonToObject<wx_client_prod_key>(regex_str);
|
||||
if (wxClientProd.product_key == null)
|
||||
return "解析失败product_key";
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "解析失败product_key";
|
||||
}
|
||||
|
||||
//商品详情格式
|
||||
wxClientProd.info = new wx_client_prod_info();
|
||||
|
||||
//主标题
|
||||
wxClientProd.info.title = RegexUtils.GetStringJson(ref prodStr, "title");
|
||||
if (wxClientProd.info.title.IsNullOrEmpty())
|
||||
return "解析失败title";
|
||||
|
||||
//副标题
|
||||
wxClientProd.info.sub_title = RegexUtils.GetStringJson(ref prodStr, "sub_title");
|
||||
|
||||
str_lst = RegexUtils.GetJsonArrStrJson(ref prodStr, "head_img");
|
||||
try
|
||||
{
|
||||
var regex_str = str_lst.OrderByDescending(s => s.Length).FirstOrDefault();
|
||||
wxClientProd.info.head_img = JsonUtils.DeserializeJsonToListNullable<string>(regex_str);
|
||||
if (wxClientProd.info.head_img == null)
|
||||
return "解析失败head_img";
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "解析失败head_img";
|
||||
}
|
||||
|
||||
var nodeCatId = RegexUtils.GetStringJson(ref prodStr, "nodeCatId");
|
||||
|
||||
str_lst = RegexUtils.GetJsonArrStrJson(ref prodStr, "category");
|
||||
try
|
||||
{
|
||||
var regex_str = str_lst.OrderByDescending(s => s.Length).FirstOrDefault();
|
||||
wxClientProd.info.category = JsonUtils.DeserializeJsonToListNullable<wx_client_category>(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 = RegexUtils.GetJsonObjStrJson(ref prodStr, "detail");
|
||||
try
|
||||
{
|
||||
var regex_str = str_lst.OrderByDescending(s => s.Length).FirstOrDefault();
|
||||
wxClientProd.info.detail = JsonUtils.DeserializeJsonToObjectNullable<wx_client_prod_detail>(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 = RegexUtils.GetJsonArrStrJson(ref prodStr, "param");
|
||||
try
|
||||
{
|
||||
var regex_str = str_lst.OrderByDescending(s => s.Length).FirstOrDefault();
|
||||
wxClientProd.info.param = JsonUtils.DeserializeJsonToListNullable<wx_client_param>(regex_str);
|
||||
if (wxClientProd.info.param == null)
|
||||
wxClientProd.info.param = new List<wx_client_param>();
|
||||
//if (wxClientProd.info.param == null)
|
||||
// return "解析失败";
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "解析失败param";
|
||||
}
|
||||
|
||||
//品牌id
|
||||
wxClientProd.info.brand_id = RegexUtils.GetStringJson(ref prodStr, "brand_id");
|
||||
//if (wxClientProd.info.brand_id.IsNullOrEmpty())
|
||||
// return "解析失败";
|
||||
|
||||
str_lst = RegexUtils.GetJsonObjStrJson(ref prodStr, "sku_id_list");
|
||||
try
|
||||
{
|
||||
var regex_str = str_lst.OrderByDescending(s => s.Length).FirstOrDefault();
|
||||
wxClientProd.info.sku_id_list = JsonUtils.DeserializeJsonToObjectNullable<wx_client_sku_id_list>(regex_str);
|
||||
//if (wxClientProd.info.sku_id_list == null)
|
||||
// return "解析失败";
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "解析失败sku_id_list";
|
||||
}
|
||||
|
||||
str_lst = RegexUtils.GetJsonObjStrJson(ref prodStr, "sku_list");
|
||||
try
|
||||
{
|
||||
var regex_str = str_lst.OrderByDescending(s => s.Length).FirstOrDefault();
|
||||
wxClientProd.info.sku_list = JsonUtils.DeserializeJsonToObjectNullable<wx_sku>(regex_str);
|
||||
//if (wxClientProd.info.sku_list == null)
|
||||
// return "解析失败";
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "解析失败sku_list";
|
||||
}
|
||||
|
||||
if (wxClientProd.info.sku_list == null)
|
||||
{
|
||||
str_lst = RegexUtils.GetJsonArrStrJson(ref prodStr, "sku_info");
|
||||
try
|
||||
{
|
||||
var regex_str = str_lst.OrderByDescending(s => s.Length).FirstOrDefault();
|
||||
var sku_infos = JsonUtils.DeserializeJsonToListNullable<wx_client_sku_info>(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 = RegexUtils.GetJsonArrStrJson(ref prodStr, "product_sale_attrs");
|
||||
try
|
||||
{
|
||||
var regex_str = str_lst.OrderByDescending(s => s.Length).FirstOrDefault();
|
||||
wxClientProd.info.product_sale_attrs = JsonUtils.DeserializeJsonToListNullable<wx_client_product_sale_attr>(regex_str);
|
||||
//if (wxClientProd.info.product_sale_attrs == null)
|
||||
// return "解析失败";
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "解析失败product_sale_attrs";
|
||||
}
|
||||
|
||||
|
||||
//总销量
|
||||
wxClientProd.info.total_sold_num = RegexUtils.GetStringJson(ref prodStr, "total_sold_num");
|
||||
//if (wxClientProd.info.total_sold_num.IsNullOrEmpty())
|
||||
// return "解析失败";
|
||||
|
||||
str_lst = RegexUtils.GetJsonObjStrJson(ref prodStr, "service_desc");
|
||||
try
|
||||
{
|
||||
var regex_str = str_lst.OrderByDescending(s => s.Length).FirstOrDefault();
|
||||
wxClientProd.info.service_desc = JsonUtils.DeserializeJsonToObjectNullable<wx_client_service_desc>(regex_str);
|
||||
//if (wxClientProd.info.service_desc == null)
|
||||
// return "解析失败";
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "解析失败service_desc";
|
||||
}
|
||||
|
||||
str_lst = RegexUtils.GetJsonObjStrJson(ref prodStr, "express_info");
|
||||
try
|
||||
{
|
||||
var regex_str = str_lst.OrderByDescending(s => s.Length).FirstOrDefault();
|
||||
wxClientProd.info.express_info = JsonUtils.DeserializeJsonToObjectNullable<wx_client_express_info>(regex_str);
|
||||
//if (wxClientProd.info.express_info == null)
|
||||
// return;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "解析失败express_info";
|
||||
}
|
||||
|
||||
str_lst = RegexUtils.GetJsonArrStrJson(ref prodStr, "headVideoInfo");
|
||||
try
|
||||
{
|
||||
var regex_str = str_lst.OrderByDescending(s => s.Length).FirstOrDefault();
|
||||
wxClientProd.info.headVideoInfo = JsonUtils.DeserializeJsonToListNullable<wx_client_head_video_info>(regex_str);
|
||||
//if (wxClientProd.info.headVideoInfo == null)
|
||||
// return "解析失败";
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "解析失败headVideoInfo";
|
||||
}
|
||||
|
||||
str_lst = RegexUtils.GetJsonObjStrJson(ref prodStr, "afterSaleInfo");
|
||||
try
|
||||
{
|
||||
var regex_str = str_lst.OrderByDescending(s => s.Length).FirstOrDefault();
|
||||
wxClientProd.info.afterSaleInfo = JsonUtils.DeserializeJsonToObjectNullable<object>(regex_str);
|
||||
//if (wxClientProd.info.afterSaleInfo == null)
|
||||
// return "解析失败";
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "解析失败afterSaleInfo";
|
||||
}
|
||||
|
||||
str_lst = RegexUtils.GetJsonArrStrJson(ref prodStr, "deliveryExpressFee");
|
||||
try
|
||||
{
|
||||
var regex_str = str_lst.OrderByDescending(s => s.Length).FirstOrDefault();
|
||||
wxClientProd.info.deliveryExpressFee = JsonUtils.DeserializeJsonToListNullable<object>(regex_str);
|
||||
//if (wxClientProd.info.deliveryExpressFee == null)
|
||||
// return "解析失败";
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "解析失败deliveryExpressFee";
|
||||
}
|
||||
|
||||
str_lst = RegexUtils.GetJsonArrStrJson(ref prodStr, "templateInfo");
|
||||
try
|
||||
{
|
||||
var regex_str = str_lst.OrderByDescending(s => s.Length).FirstOrDefault();
|
||||
wxClientProd.info.templateInfo = JsonUtils.DeserializeJsonToListNullable<object>(regex_str);
|
||||
//if (wxClientProd.info.templateInfo == null)
|
||||
// return "解析失败";
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "解析失败templateInfo";
|
||||
}
|
||||
|
||||
wxClientProd.info.spuCode = RegexUtils.GetStringJson(ref prodStr, "spuCode");
|
||||
|
||||
str_lst = RegexUtils.GetJsonArrStrJson(ref prodStr, "productSkus");
|
||||
try
|
||||
{
|
||||
var regex_str = str_lst.OrderByDescending(s => s.Length).FirstOrDefault();
|
||||
wxClientProd.productSkus = JsonUtils.DeserializeJsonToList<WXProductSkuInfoLite>(regex_str);
|
||||
if (wxClientProd.productSkus == null)
|
||||
return "解析失败productSkus";
|
||||
}
|
||||
catch
|
||||
{
|
||||
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, special_prod_type);
|
||||
}
|
||||
|
||||
public static string SaveWxProd(string prodId, WXClientProductInfoLite wxClientProdInfoLite, string baseProdStr, string special_prod_type = null)
|
||||
{
|
||||
bool isExist = false;
|
||||
var existUrl = BaseClass.BuildPDDObjString("product/get_product_spu_id_list");
|
||||
string existData = UserLogin.GetSignaturex() + "&search_spu_ids=" + prodId;
|
||||
//if (!string.IsNullOrEmpty(prod.dbProduct.real_spu_id))
|
||||
// existData = UserLogin.GetSignaturex() + "&search_spu_ids=" + prod.spuId + "," + prod.dbProduct.real_spu_id;
|
||||
string html = HtmlUtils.PostUtf8(existUrl, existData);
|
||||
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
||||
html = HtmlUtils.PostUtf8(existUrl, existData);
|
||||
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
||||
{
|
||||
return "采集入库失败,产品数据库连接失败";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (html.Contains("\"data\":[") && !html.Contains("\"data\":[]"))
|
||||
isExist = true;
|
||||
}
|
||||
|
||||
var url = BaseClass.BuildPDDObjString("product/add_product");
|
||||
if (isExist)
|
||||
url = BaseClass.BuildPDDObjString("product/mdy_product");
|
||||
|
||||
var skus = wxClientProdInfoLite.productSkus;
|
||||
|
||||
var product_json = "{\"wxxdData\":" + JsonUtils.SerializeObject(wxClientProdInfoLite) + ",\"baseData\":" + JsonUtils.SerializeObject(baseProdStr) + "}";
|
||||
var data = UserLogin.GetSignaturex() +
|
||||
"&from_shop_id=" + wxClientProdInfoLite.product_key.appid +
|
||||
"&from_shop_name=" + wxClientProdInfoLite.product_key.appid +
|
||||
"&spu_id=" + prodId +
|
||||
"&skc_id=" + prodId +
|
||||
"&price_text=" + skus.Min(s => s.productSkuInfo.salePrice * 0.01m) + " - " + skus.Max(s => s.productSkuInfo.salePrice * 0.01m) +
|
||||
"&ext_code=" + wxClientProdInfoLite.info.spuCode +
|
||||
"&product_name=" + HttpUtility.UrlEncode(wxClientProdInfoLite.info.title, Encoding.UTF8) +
|
||||
"&product_json=" + HttpUtility.UrlEncode(product_json, Encoding.UTF8) + // product_json /*HttpUtility.UrlEncode(JsonUtils.SerializeObject(wxClientProdInfoLite), Encoding.UTF8)*/
|
||||
"&sale_count=" + wxClientProdInfoLite.info.total_sold_num +
|
||||
"&sale_count_text=" + wxClientProdInfoLite.info.total_sold_num +
|
||||
"&main_img=" + HttpUtility.UrlEncode(wxClientProdInfoLite.info.head_img.FirstOrDefault(), Encoding.UTF8) +
|
||||
"&wx_safe_status=" + HttpUtility.UrlEncode("安全商品", Encoding.UTF8) +
|
||||
"&product_get_type=" + HttpUtility.UrlEncode("微信小店", Encoding.UTF8);
|
||||
|
||||
if (wxClientProdInfoLite.info.category.Count > 0)
|
||||
{
|
||||
data += "&wx_cat_1=" + wxClientProdInfoLite.info.category[0].catIdStr;
|
||||
data += "&main_cat_id=" + wxClientProdInfoLite.info.category[0].catIdStr;
|
||||
data += "&main_cat_name=" + wxClientProdInfoLite.info.category[0].name;
|
||||
|
||||
data += "&wx_cat_leaf=" + wxClientProdInfoLite.info.category.LastOrDefault()?.catIdStr;
|
||||
data += "&cat_id=" + wxClientProdInfoLite.info.category.LastOrDefault()?.catIdStr;
|
||||
data += "&cat_name=" + HttpUtility.UrlEncode((wxClientProdInfoLite.info.category.LastOrDefault()?.name).ParseToString(), Encoding.UTF8);
|
||||
}
|
||||
if (wxClientProdInfoLite.info.category.Count > 1)
|
||||
{
|
||||
data += "&wx_cat_2=" + wxClientProdInfoLite.info.category[1].catIdStr;
|
||||
}
|
||||
if (wxClientProdInfoLite.info.category.Count > 2)
|
||||
{
|
||||
data += "&wx_cat_3=" + wxClientProdInfoLite.info.category[2].catIdStr;
|
||||
}
|
||||
|
||||
//if (wxClientProdInfoLite.info.category.FirstOrDefault().name == "图书")
|
||||
//{
|
||||
// data += "&special_prod_type=" + HttpUtility.UrlEncode("书籍", Encoding.UTF8);
|
||||
//}
|
||||
if (special_prod_type != null)
|
||||
{
|
||||
data += "&special_prod_type=" + special_prod_type;
|
||||
}
|
||||
|
||||
html = HtmlUtils.PostUtf8(url, data);
|
||||
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
||||
html = HtmlUtils.PostUtf8(url, data);
|
||||
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
||||
{
|
||||
string msg = "商品入库失败!请检查网络连接:" + RegexUtils.GetStringJson(ref html, "msg");
|
||||
//Invoke(new Action(() =>
|
||||
//{
|
||||
// row.Cells["colMsg"].Value = msg;
|
||||
//}));
|
||||
return msg;
|
||||
}
|
||||
else
|
||||
{
|
||||
//prod.getProductMsg = "商品入库成功!";
|
||||
//Invoke(new Action(() =>
|
||||
//{
|
||||
// row.Cells["colMsg"].Value = prod.getProductMsg;
|
||||
//}));
|
||||
if (!isExist)
|
||||
{
|
||||
url = BaseClass.BuildPDDObjString("product/mdy_product");
|
||||
html = HtmlUtils.PostUtf8(url, data);
|
||||
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
||||
html = HtmlUtils.PostUtf8(url, data);
|
||||
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
||||
{
|
||||
string msg = "商品入库失败!请检查网络连接:" + RegexUtils.GetStringJson(ref html, "msg");
|
||||
return msg;
|
||||
}
|
||||
}
|
||||
|
||||
return "微信商品采集入库成功!";
|
||||
}
|
||||
return new BaseWxProd().getProd(prodStr);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WXProdHot.aspx.cs" Inherits="KJD_Web.Upload.Prod.WXProdHot" ValidateRequest="false"%>
|
||||
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head runat="server">
|
||||
<!--<pre name="code" class="html" />-->
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||
<title></title>
|
||||
</head>
|
||||
<body>
|
||||
<form id="form1" runat="server">
|
||||
<div style="padding:0px 0px;">
|
||||
<div style="padding:0px 20px;">
|
||||
<asp:FileUpload ID="FileUpload1" runat="server" />
|
||||
</div>
|
||||
<div style="padding:10px 20px;">
|
||||
<asp:Button ID="btnSubmit" runat="server" Text="提交爆款数据" Width="100px" OnClick="btnSubmit_Click" />
|
||||
<asp:Label ID="Label1" runat="server" Text=""></asp:Label>
|
||||
</div>
|
||||
<div style="padding:10px 20px;">
|
||||
<asp:TextBox ID="TextBox2" runat="server" TextMode="MultiLine" Height="650px" Width="300px"></asp:TextBox>
|
||||
</div>
|
||||
<div style="padding:10px 20px;">
|
||||
<asp:Button ID="Button1" runat="server" Text="提交爆款数据" Width="100px" OnClick="btnSubmit_Click" />
|
||||
<asp:Label ID="Label2" runat="server" Text=""></asp:Label>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,44 @@
|
||||
using KJD_Web.Model;
|
||||
using KJD_Web.Utils;
|
||||
using KJD_WebService.Model;
|
||||
using KJD_WebService.Model.WxModel;
|
||||
using NaiBa.Util.Extension;
|
||||
using NaiBa.Util.Helper;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
namespace KJD_Web.Upload.Prod
|
||||
{
|
||||
public partial class WXProdHot : System.Web.UI.Page
|
||||
{
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
FileUpload1.Visible = false;
|
||||
}
|
||||
|
||||
protected void btnSubmit_Click(object sender, EventArgs e)
|
||||
{
|
||||
Label1.Text = "";
|
||||
Label2.Text = "";
|
||||
|
||||
string rst = getProd();
|
||||
Label1.Text = rst;
|
||||
Label2.Text = rst;
|
||||
TextBox2.Text = "";
|
||||
FileUpload1.Visible = false;
|
||||
}
|
||||
|
||||
string getProd()
|
||||
{
|
||||
string prodStr = Encoding.UTF8.GetString(this.FileUpload1.FileBytes);
|
||||
prodStr = TextBox2.Text.Trim();
|
||||
return new BaseWxProd().getProd(prodStr, "爆款数据");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <自动生成>
|
||||
// 此代码由工具生成。
|
||||
//
|
||||
// 对此文件的更改可能导致不正确的行为,如果
|
||||
// 重新生成代码,则所做更改将丢失。
|
||||
// </自动生成>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace KJD_Web.Upload.Prod
|
||||
{
|
||||
|
||||
|
||||
public partial class WXProdHot
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// form1 控件。
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 自动生成的字段。
|
||||
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.HtmlControls.HtmlForm form1;
|
||||
|
||||
/// <summary>
|
||||
/// FileUpload1 控件。
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 自动生成的字段。
|
||||
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.FileUpload FileUpload1;
|
||||
|
||||
/// <summary>
|
||||
/// btnSubmit 控件。
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 自动生成的字段。
|
||||
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Button btnSubmit;
|
||||
|
||||
/// <summary>
|
||||
/// Label1 控件。
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 自动生成的字段。
|
||||
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Label Label1;
|
||||
|
||||
/// <summary>
|
||||
/// TextBox2 控件。
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 自动生成的字段。
|
||||
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.TextBox TextBox2;
|
||||
|
||||
/// <summary>
|
||||
/// Button1 控件。
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 自动生成的字段。
|
||||
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Button Button1;
|
||||
|
||||
/// <summary>
|
||||
/// Label2 控件。
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 自动生成的字段。
|
||||
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Label Label2;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user