优化微信上传代码
This commit is contained in:
1 parent
9e1a354ee5
commit
f71cb1bba8
13 files changed
+749
-159
No files matched your search
@@ -244,43 +244,87 @@ namespace TemuKJD.KJDForms.AdminForms
|
||||
}
|
||||
|
||||
List<ShopLoginInfo> shopLst = new List<ShopLoginInfo>();
|
||||
bool IsOnlyUpdateDBProduct = false;
|
||||
ShopListForm.Instance.Invoke(new Action(() =>
|
||||
{
|
||||
ProductThirdSelectAddShopForm shopForm = new ProductThirdSelectAddShopForm();
|
||||
shopForm.ShowDialog();
|
||||
IsOnlyUpdateDBProduct = shopForm.IsOnlyUpdateDBProduct;
|
||||
shopLst.AddRange(shopForm.lstSelectShop);
|
||||
}));
|
||||
if (shopLst.Count == 0 && IsOnlyUpdateDBProduct != true)
|
||||
return;
|
||||
|
||||
var url = BaseClass.BuildObjString("product_third/add_product");
|
||||
var data = UserLogin.GetSignaturex() +
|
||||
"&spu_id=" + product?.productId +
|
||||
"&skc_id=" + product?.productSkcList?.FirstOrDefault()?.productSkcId +
|
||||
"&cat_id=" + GetCat(product).catId +
|
||||
"&cat_name=" + HttpUtility.UrlEncode(GetCat(product).catName, Encoding.UTF8) +
|
||||
"&ext_code=" + HttpUtility.UrlEncode(product?.productSkcList?.FirstOrDefault()?.extCode, Encoding.UTF8) +
|
||||
"&product_name=" + HttpUtility.UrlEncode(product?.productName, Encoding.UTF8) +
|
||||
"&product_json=" + HttpUtility.UrlEncode(result, Encoding.UTF8) +
|
||||
"&size_json=" + HttpUtility.UrlEncode(sizeRst, Encoding.UTF8) +
|
||||
"&main_img=" + HttpUtility.UrlEncode(product?.carouselImageUrls?.FirstOrDefault(), Encoding.UTF8);
|
||||
// 读取数据库是否有相同商品
|
||||
var url = BaseClass.BuildObjString("product_third/get_product_list");
|
||||
var data = "";
|
||||
|
||||
data = UserLogin.GetSignaturex() +
|
||||
"&page=" + 1 +
|
||||
"&page_size=" + 1;
|
||||
data += "&search_spu=" + product?.productId;
|
||||
|
||||
long dbId = 0;
|
||||
html = GetHtml.PostUtf8(url, data);
|
||||
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
||||
html = GetHtml.PostUtf8(url, data);
|
||||
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
||||
html = GetHtml.PostUtf8(url, data);
|
||||
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
||||
if (!string.IsNullOrEmpty(html) && html.Contains("\"code\":200"))
|
||||
{
|
||||
errorMsg = "选品商品保存失败!请检查网络连接:" +
|
||||
BaseRegex.GetStringJson(ref html, "msg").Replace("'", "\\'").Replace("\"", "\\\"");
|
||||
dbId = BaseRegex.GetIntJson(ref html, "id");
|
||||
}
|
||||
var id = BaseRegex.GetLongJson(ref html, "id");
|
||||
if (id == 0)
|
||||
|
||||
if (dbId > 0 && (1==1 || BaseMsgForm.ShowConfirm("数据库已存在相同 Spu Id 的商品,是否覆盖?(选择 取消 将新增一条数据)").DialogResult == DialogResult.OK))
|
||||
{
|
||||
url = BaseClass.BuildObjString("product_third/mdy_db_product");
|
||||
data = UserLogin.GetSignaturex() +
|
||||
"&db_id=" + dbId;
|
||||
data += "&product_json=" + HttpUtility.UrlEncode(result, Encoding.UTF8);
|
||||
data += "&size_json=" + HttpUtility.UrlEncode(sizeRst, Encoding.UTF8);
|
||||
html = GetHtml.PostUtf8(url, data);
|
||||
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
||||
html = GetHtml.PostUtf8(url, data);
|
||||
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
||||
{
|
||||
errorMsg = "库存商品更新保存失败!请检查网络连接:" + BaseRegex.GetStringJson(ref html, "msg");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
url = BaseClass.BuildObjString("product_third/add_product");
|
||||
data = UserLogin.GetSignaturex() +
|
||||
"&spu_id=" + product?.productId +
|
||||
"&skc_id=" + product?.productSkcList?.FirstOrDefault()?.productSkcId +
|
||||
"&cat_id=" + GetCat(product).catId +
|
||||
"&cat_name=" + HttpUtility.UrlEncode(GetCat(product).catName, Encoding.UTF8) +
|
||||
"&ext_code=" + HttpUtility.UrlEncode(product?.productSkcList?.FirstOrDefault()?.extCode, Encoding.UTF8) +
|
||||
"&product_name=" + HttpUtility.UrlEncode(product?.productName, Encoding.UTF8) +
|
||||
"&product_json=" + HttpUtility.UrlEncode(result, Encoding.UTF8) +
|
||||
"&size_json=" + HttpUtility.UrlEncode(sizeRst, Encoding.UTF8) +
|
||||
"&main_img=" + HttpUtility.UrlEncode(product?.carouselImageUrls?.FirstOrDefault(), Encoding.UTF8);
|
||||
html = GetHtml.PostUtf8(url, data);
|
||||
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
||||
html = GetHtml.PostUtf8(url, data);
|
||||
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
||||
html = GetHtml.PostUtf8(url, data);
|
||||
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
||||
{
|
||||
errorMsg = "选品商品保存失败!请检查网络连接:" +
|
||||
BaseRegex.GetStringJson(ref html, "msg").Replace("'", "\\'").Replace("\"", "\\\"");
|
||||
}
|
||||
dbId = BaseRegex.GetLongJson(ref html, "id");
|
||||
}
|
||||
|
||||
if (dbId == 0)
|
||||
goto end;
|
||||
|
||||
foreach (var addProdShop in shopLst)
|
||||
{
|
||||
url = BaseClass.BuildObjString("product_third/add_user_select_product");
|
||||
data = UserLogin.GetSignaturex() +
|
||||
"&out_product_id=" + id +
|
||||
"&out_product_id=" + dbId +
|
||||
"&shop_id=" + addProdShop.ShopId +
|
||||
"&shop_account=" + addProdShop.ShopAccount +
|
||||
"&main_user_name=" + addProdShop.UserName +
|
||||
|
||||
Reference in new issue
Block a user