拼多多商品获取逻辑
This commit is contained in:
1 parent
840636d5c9
commit
6639224771
68 files changed
+7132
-692
No files matched your search
@@ -1,15 +1,20 @@
|
||||
using AllBase;
|
||||
using AllBase.Helper;
|
||||
using AllBase.Model.Result;
|
||||
using AllBase.Model.Result.PDDResult;
|
||||
using NaiBa.Util.Extension;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using TemuKJD.BaseForms;
|
||||
using TemuKJD.BLL;
|
||||
using TemuKJD.PDDForms.AdminForms;
|
||||
using TemuKJD.PDDForms.ProductThirdSelectForms;
|
||||
using Work;
|
||||
|
||||
namespace TemuKJD.PDDForms.ShopForms
|
||||
@@ -19,15 +24,16 @@ namespace TemuKJD.PDDForms.ShopForms
|
||||
public delegate void InfoReceivedHandler(string information);
|
||||
public event InfoReceivedHandler OnInfoReceived;
|
||||
|
||||
public string getProduct(ShopLoginInfo shop, string productId)
|
||||
public string getProduct(string sProdId, string supplierId)
|
||||
{
|
||||
var prodId = productId.ParseToLong();
|
||||
var prodId = sProdId.ParseToLong();
|
||||
if (prodId <= 0)
|
||||
{
|
||||
BaseMsgForm.ShowError("商品Id不存在!");
|
||||
return "failed";
|
||||
}
|
||||
if (shop == null)
|
||||
var shop = GlobalConfig.ShopLoginList.FirstOrDefault(s => s.ShopId == supplierId.ParseToString());
|
||||
if (string.IsNullOrEmpty(supplierId) || shop == null)
|
||||
{
|
||||
BaseMsgForm.ShowError("店铺不存在!");
|
||||
return "failed";
|
||||
@@ -37,51 +43,101 @@ namespace TemuKJD.PDDForms.ShopForms
|
||||
{
|
||||
try
|
||||
{
|
||||
var shop1 = shop;
|
||||
var prodId1 = prodId;
|
||||
var sourceShop = shop;
|
||||
var sourceProdId = prodId;
|
||||
string success_err_msg = "";
|
||||
var html = ProductQuery(shop1, prodId1.ToString());
|
||||
|
||||
var testHtml1 = GetHtml.UrlEncodeUtf8(html);
|
||||
var testHtml2 = GetHtml.UrlDecode(testHtml1);
|
||||
testHtml1 = HttpUtility.UrlEncode(html, Encoding.UTF8);
|
||||
testHtml2 = HttpUtility.UrlDecode(testHtml1);
|
||||
string errorMsg = "";
|
||||
var html = GetProdCommitId(sourceShop, sourceProdId.ToString());
|
||||
if (!html.Contains("\"success\":true") || !html.Contains("\"result\""))
|
||||
{
|
||||
OnInfoReceived("商品获取失败!" + BaseRegex.GetStringJson(ref html, "errorMsg"));
|
||||
var errMsg = BaseRegex.GetStringJson(ref html, "error_msg");
|
||||
if (string.IsNullOrEmpty(errMsg))
|
||||
errMsg = html;
|
||||
OnInfoReceived("商品获取失败!" + errMsg);
|
||||
return;
|
||||
}
|
||||
var commitId = BaseRegex.GetStringJson(ref html, "goods_commit_id");
|
||||
if (string.IsNullOrEmpty(commitId))
|
||||
{
|
||||
OnInfoReceived("商品获取失败!商品提交编号获取失败!");
|
||||
return;
|
||||
}
|
||||
html = GetPddProduct(sourceShop, sourceProdId.ToString(), commitId);
|
||||
|
||||
JObject obj = JObject.Parse(html);
|
||||
var result = JsonHelper.SerializeObject(obj["result"]);
|
||||
var sizeRst = "";
|
||||
TemuDetailProductInfo product = JsonHelper.DeserializeJsonToObject<TemuDetailProductInfo>(result);
|
||||
|
||||
if (product.sizeTemplateId > 0)
|
||||
PDDProductDetailInfo product = JsonHelper.DeserializeJsonToObject<PDDProductDetailInfo>(result);
|
||||
if (product == null)
|
||||
{
|
||||
html = SizeSpecQuery(shop1, prodId1.ToString(), product.sizeTemplateId.ToString());
|
||||
if(!html.Contains("\"success\":true"))
|
||||
{
|
||||
success_err_msg += " 尺码表获取失败!" + BaseRegex.GetStringJson(ref html, "errorMsg");
|
||||
}
|
||||
else
|
||||
{
|
||||
obj = JObject.Parse(html);
|
||||
sizeRst = JsonHelper.SerializeObject(obj["result"]);
|
||||
}
|
||||
OnInfoReceived("商品获取失败!商品数据格式获取失败!");
|
||||
return;
|
||||
}
|
||||
|
||||
//尺码表注释
|
||||
//if (product.sizeTemplateId > 0)
|
||||
//{
|
||||
// html = SizeSpecQuery(shop1, prodId1.ToString(), product.sizeTemplateId.ToString());
|
||||
// if(!html.Contains("\"success\":true"))
|
||||
// {
|
||||
// success_err_msg += " 尺码表获取失败!" + BaseRegex.GetStringJson(ref html, "errorMsg");
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// obj = JObject.Parse(html);
|
||||
// sizeRst = JsonHelper.SerializeObject(obj["result"]);
|
||||
// }
|
||||
//}
|
||||
|
||||
bool isExist = false;
|
||||
var existUrl = BaseClass.BuildObjString("product/get_product_list");
|
||||
string existData = UserLogin.GetSignaturex() + "&search_spu=" + product.goods_id;
|
||||
html = GetHtml.PostUtf8(existUrl, existData);
|
||||
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
||||
html = GetHtml.PostUtf8(existUrl, existData);
|
||||
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
||||
html = GetHtml.PostUtf8(existUrl, existData);
|
||||
if (!string.IsNullOrEmpty(html) && html.Contains("\"code\":200"))
|
||||
{
|
||||
if (html.Contains("\"data\":[") && !html.Contains("\"data\":[]"))
|
||||
isExist = true;
|
||||
}
|
||||
|
||||
var main_img = product.image_url;
|
||||
if (string.IsNullOrEmpty(main_img))
|
||||
main_img = product.hd_thumb_url;
|
||||
if (string.IsNullOrEmpty(main_img))
|
||||
main_img = product.thumb_url;
|
||||
if (string.IsNullOrEmpty(main_img))
|
||||
main_img = (product.galleries?.FirstOrDefault()?.url).ParseToString().Replace("https://", "http://");
|
||||
var url = BaseClass.BuildObjString("product/add_product");
|
||||
if (isExist)
|
||||
{
|
||||
bool isCover = false;
|
||||
MainForm.instance.Invoke(new Action(() =>
|
||||
{
|
||||
var ok = BaseMsgForm.ShowConfirm("产品库内已存在相同id商品,是否更新?").DialogResult;
|
||||
if (ok == DialogResult.OK)
|
||||
isCover = true;
|
||||
}));
|
||||
if (isCover)
|
||||
url = BaseClass.BuildObjString("product/mdy_product");
|
||||
else
|
||||
return;
|
||||
}
|
||||
|
||||
var data = Work.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) +
|
||||
"&from_shop_id=" + shop.ShopId +
|
||||
"&spu_id=" + product.goods_id.ParseToString() +
|
||||
"&skc_id=" + product.goods_id.ParseToString() +
|
||||
"&cat_id=" + (product.cat_id).ParseToString() +
|
||||
"&cat_name=" + HttpUtility.UrlEncode((product.cats?.LastOrDefault(c => !string.IsNullOrEmpty(c))).ParseToString(), Encoding.UTF8) +
|
||||
"&ext_code=" + HttpUtility.UrlEncode(product.out_goods_sn, Encoding.UTF8) +
|
||||
"&product_name=" + HttpUtility.UrlEncode(product.goods_name, 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);
|
||||
"&main_img=" + HttpUtility.UrlEncode(main_img, Encoding.UTF8);
|
||||
|
||||
html = GetHtml.PostUtf8(url, data);
|
||||
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
||||
html = GetHtml.PostUtf8(url, data);
|
||||
@@ -89,7 +145,7 @@ namespace TemuKJD.PDDForms.ShopForms
|
||||
html = GetHtml.PostUtf8(url, data);
|
||||
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
||||
{
|
||||
string msg = "选品商品保存失败!请检查网络连接:" +
|
||||
string msg = "选品商品保存失败!请检查网络连接:" +
|
||||
BaseRegex.GetStringJson(ref html, "msg");
|
||||
OnInfoReceived(msg);
|
||||
}
|
||||
@@ -98,7 +154,6 @@ namespace TemuKJD.PDDForms.ShopForms
|
||||
OnInfoReceived("选品商品保存成功!" + success_err_msg);
|
||||
}
|
||||
|
||||
|
||||
//// 创建 SaveFileDialog 的实例
|
||||
//SaveFileDialog saveFileDialog = new SaveFileDialog();
|
||||
|
||||
@@ -140,7 +195,7 @@ namespace TemuKJD.PDDForms.ShopForms
|
||||
/// <param name="sProdId"></param>
|
||||
/// <param name="supplierId"></param>
|
||||
/// <returns></returns>
|
||||
public string getThirdProduct(string sProdId, long supplierId)
|
||||
public string getThirdProduct(string sProdId, string supplierId)
|
||||
{
|
||||
var prodId = sProdId.ParseToLong();
|
||||
if (prodId <= 0)
|
||||
@@ -148,8 +203,8 @@ namespace TemuKJD.PDDForms.ShopForms
|
||||
BaseMsgForm.ShowError("商品Id不存在!");
|
||||
return "failed";
|
||||
}
|
||||
var shop = GlobalConfig.ShopLoginList.FirstOrDefault(s => s.ShopId == supplierId.ToString());
|
||||
if (supplierId <= 0 || shop == null)
|
||||
var shop = GlobalConfig.ShopLoginList.FirstOrDefault(s => s.ShopId == supplierId.ParseToString());
|
||||
if (string.IsNullOrEmpty(supplierId) || shop == null)
|
||||
{
|
||||
BaseMsgForm.ShowError("店铺不存在!");
|
||||
return "failed";
|
||||
@@ -163,61 +218,89 @@ namespace TemuKJD.PDDForms.ShopForms
|
||||
var sourceProdId = prodId;
|
||||
string success_err_msg = "";
|
||||
string errorMsg = "";
|
||||
var html = ProductQuery(sourceShop, sourceProdId.ToString());
|
||||
var html = GetProdCommitId(sourceShop, sourceProdId.ToString());
|
||||
if (!html.Contains("\"success\":true") || !html.Contains("\"result\""))
|
||||
{
|
||||
OnInfoReceived("商品获取失败!" + BaseRegex.GetStringJson(ref html, "errorMsg"));
|
||||
var errMsg = BaseRegex.GetStringJson(ref html, "error_msg");
|
||||
if (string.IsNullOrEmpty(errMsg))
|
||||
errMsg = html;
|
||||
OnInfoReceived("商品获取失败!" + errMsg);
|
||||
return;
|
||||
}
|
||||
var commitId = BaseRegex.GetStringJson(ref html, "goods_commit_id");
|
||||
if (string.IsNullOrEmpty(commitId))
|
||||
{
|
||||
OnInfoReceived("商品获取失败!商品提交编号获取失败!");
|
||||
return;
|
||||
}
|
||||
html = GetPddProduct(sourceShop, sourceProdId.ToString(), commitId);
|
||||
|
||||
JObject obj = JObject.Parse(html);
|
||||
var result = JsonHelper.SerializeObject(obj["result"]);
|
||||
var sizeRst = "";
|
||||
TemuDetailProductInfo product = JsonHelper.DeserializeJsonToObject<TemuDetailProductInfo>(result);
|
||||
|
||||
if (product.sizeTemplateId > 0)
|
||||
PDDProductDetailInfo product = JsonHelper.DeserializeJsonToObject<PDDProductDetailInfo>(result);
|
||||
if (product == null)
|
||||
{
|
||||
html = SizeSpecQuery(sourceShop, sourceProdId.ToString(), product.sizeTemplateId.ToString());
|
||||
if (!html.Contains("\"success\":true"))
|
||||
{
|
||||
success_err_msg += " 尺码表获取失败!" + BaseRegex.GetStringJson(ref html, "errorMsg");
|
||||
}
|
||||
else
|
||||
{
|
||||
obj = JObject.Parse(html);
|
||||
sizeRst = JsonHelper.SerializeObject(obj["result"]);
|
||||
}
|
||||
OnInfoReceived("商品获取失败!商品数据格式获取失败!");
|
||||
return;
|
||||
}
|
||||
|
||||
//拼多多暂时注释
|
||||
//if (product.sizeTemplateId > 0)
|
||||
//{
|
||||
// html = SizeSpecQuery(sourceShop, sourceProdId.ToString(), product.sizeTemplateId.ToString());
|
||||
// if (!html.Contains("\"success\":true"))
|
||||
// {
|
||||
// success_err_msg += " 尺码表获取失败!" + BaseRegex.GetStringJson(ref html, "errorMsg");
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// obj = JObject.Parse(html);
|
||||
// sizeRst = JsonHelper.SerializeObject(obj["result"]);
|
||||
// }
|
||||
//}
|
||||
|
||||
List<ShopLoginInfo> shopLst = new List<ShopLoginInfo>();
|
||||
PDDShopListForm.Instance.Invoke(new Action(() =>
|
||||
{
|
||||
//todo:
|
||||
//ProductThirdSelectAddShopForm shopForm = new ProductThirdSelectAddShopForm();
|
||||
//shopForm.ShowDialog();
|
||||
//shopLst.AddRange(shopForm.lstSelectShop);
|
||||
PDDThirdProdSelectAddShopForm shopForm = new PDDThirdProdSelectAddShopForm();
|
||||
shopForm.ShowDialog();
|
||||
shopLst.AddRange(shopForm.lstSelectShop);
|
||||
}));
|
||||
if (shopLst.Count == 0)
|
||||
{
|
||||
OnInfoReceived("库存上传操作取消或未选择上传店铺!");
|
||||
return;
|
||||
}
|
||||
|
||||
var main_img = product.image_url;
|
||||
if (string.IsNullOrEmpty(main_img))
|
||||
main_img = product.hd_thumb_url;
|
||||
if (string.IsNullOrEmpty(main_img))
|
||||
main_img = product.thumb_url;
|
||||
if (string.IsNullOrEmpty(main_img))
|
||||
main_img = (product.galleries?.FirstOrDefault()?.url).ParseToString().Replace("https://", "http://");
|
||||
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) +
|
||||
"&from_shop_id=" + shop.ShopId +
|
||||
"&spu_id=" + product.goods_id.ParseToString() +
|
||||
"&skc_id=" + product.goods_id.ParseToString() +
|
||||
"&cat_id=" + (product.cat_id).ParseToString() +
|
||||
"&cat_name=" + HttpUtility.UrlEncode((product.cats?.LastOrDefault(c => !string.IsNullOrEmpty(c))).ParseToString(), Encoding.UTF8) +
|
||||
"&ext_code=" + HttpUtility.UrlEncode(product.out_goods_sn, Encoding.UTF8) +
|
||||
"&product_name=" + HttpUtility.UrlEncode(product.goods_name, 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);
|
||||
"&main_img=" + HttpUtility.UrlEncode(main_img, 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"))
|
||||
// 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("\"", "\\\"");
|
||||
errorMsg = "库存商品保存失败!请检查网络连接:" +
|
||||
BaseRegex.GetStringJson(ref html, "msg").ParseToString().Replace("'", "\\'").Replace("\"", "\\\"");
|
||||
}
|
||||
var id = BaseRegex.GetLongJson(ref html, "id");
|
||||
if (id == 0)
|
||||
@@ -241,7 +324,7 @@ namespace TemuKJD.PDDForms.ShopForms
|
||||
html = GetHtml.PostUtf8(url, data);
|
||||
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
||||
{
|
||||
errorMsg += product?.productId + " " + BaseRegex.GetStringJson(ref html, "msg") + "; ";
|
||||
errorMsg += product?.goods_id + " " + BaseRegex.GetStringJson(ref html, "msg") + "; ";
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -297,14 +380,35 @@ namespace TemuKJD.PDDForms.ShopForms
|
||||
|
||||
|
||||
|
||||
private string ProductQuery(ShopLoginInfo shop, string prodId)
|
||||
private string GetProdCommitId(ShopLoginInfo shop, string prodId)
|
||||
{
|
||||
//string url = "https://seller.kuajingmaihuo.com/bg-visage-mms/product/query";
|
||||
//string body = @"{""productId"":" + prodId + @",""productEditTaskUid"":""""}";
|
||||
//string refere = "https://seller.kuajingmaihuo.com/goods/product-create/product-edit?from=productList&productId=" + prodId;
|
||||
//return KJDHttpResponse.PostResponse(shop, url, body, refere);
|
||||
|
||||
return "";
|
||||
string url = "https://mms.pinduoduo.com/glide/v2/mms/edit/commit/create_by_sn";
|
||||
string body = @"{""goods_id"":" + prodId + "}";
|
||||
string refere = "https://mms.pinduoduo.com/goods/goods_list?msfrom=mms_sidenav";
|
||||
var result = HttpResponseBLL.PDDPostResponse(shop, url, body, refere, shop.AntiContents.LastOrDefault().ParseToString());
|
||||
return result;
|
||||
}
|
||||
private string GetPddProduct(ShopLoginInfo shop, string prodId, string commitId)
|
||||
{
|
||||
var anti = shop.AntiContents.LastOrDefault().ParseToString();
|
||||
if (shop.AntiContents.Count > 0)
|
||||
anti = shop.AntiContents[Randomx.GetId(shop.AntiContents.Count)];
|
||||
string url = "https://mms.pinduoduo.com/glide/v2/mms/query/commit/detail";
|
||||
string body = @"{""goods_commit_id"":""" + commitId + @""",""goods_id"":""" + prodId + @"""}";
|
||||
string refere = "https://mms.pinduoduo.com/goods/goods_add/index?id=" + commitId + "&goods_id=" + prodId + "&type=edit";
|
||||
var result = HttpResponseBLL.PDDPostResponse(shop, url, body, refere, anti);
|
||||
for (int i = 0; i < 2 && result.Contains("网络繁忙,请不要频繁操作"); i++)
|
||||
{
|
||||
shop.AntiContents.Remove(anti);
|
||||
anti = shop.AntiContents.LastOrDefault().ParseToString();
|
||||
if (shop.AntiContents.Count > 0)
|
||||
{
|
||||
Thread.Sleep(Randomx.GetId(300, 500));
|
||||
anti = shop.AntiContents[Randomx.GetId(shop.AntiContents.Count)];
|
||||
result = HttpResponseBLL.PDDPostResponse(shop, url, body, refere, anti);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private string SizeSpecQuery(ShopLoginInfo shop, string prodId, string sizeSpecId)
|
||||
@@ -312,7 +416,7 @@ namespace TemuKJD.PDDForms.ShopForms
|
||||
//string url = "https://seller.kuajingmaihuo.com/bg-anniston-mms/sizespec/query";
|
||||
//string body = @"{""businessId"":" + sizeSpecId + @",""reusable"":false}";
|
||||
//string refere = "https://seller.kuajingmaihuo.com/goods/product-create/product-edit?from=productList&productId=" + prodId;
|
||||
//return KJDHttpResponse.PostResponse(shop, url, body, refere);
|
||||
//return HttpResponseBLL.PostResponse(shop, url, body, refere);
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace TemuKJD.PDDForms.ShopForms
|
||||
private bool isLoading { get; set; } = false;
|
||||
|
||||
#region 服务端店铺管理
|
||||
public static string AddServerDouShop(ShopLoginInfo _shop)
|
||||
public static string AddServerPddShop(ShopLoginInfo _shop)
|
||||
{
|
||||
var url = BaseClass.BuildObjString("shop/add_shop");
|
||||
var data = UserLogin.GetSignaturex()
|
||||
@@ -43,6 +43,7 @@ namespace TemuKJD.PDDForms.ShopForms
|
||||
+ "&shop_account=" + _shop.ShopAccount
|
||||
+ "&cookie=" + _shop.Cookies
|
||||
+ "&cookie2=" + _shop.Cookies2
|
||||
+ "&anti_contents=" + JsonHelper.SerializeObject(_shop.AntiContents)
|
||||
+ "&shop_group=" + GetHtml.UrlEncodeUtf8(_shop.GroupName)
|
||||
+ "&sub_user_name=" + GetHtml.UrlEncodeUtf8(_shop.SubUserName)
|
||||
+ "¬es=" + GetHtml.UrlEncodeUtf8(_shop.Notes)
|
||||
@@ -63,12 +64,14 @@ namespace TemuKJD.PDDForms.ShopForms
|
||||
return result;
|
||||
}
|
||||
|
||||
public static string MdyServerDouShop(ShopLoginInfo _shop)
|
||||
public static string MdyServerPddShop(ShopLoginInfo _shop)
|
||||
{
|
||||
var url = BaseClass.BuildObjString("shop/mdy_shop");
|
||||
var data = UserLogin.GetSignaturex()
|
||||
+ "&login_name=" + _shop.LoginName
|
||||
+ "&login_pass=" + GetHtml.UrlEncodeUtf8(_shop.Password)
|
||||
+ "&shop_id=" + _shop.ShopId
|
||||
+ "&shop_account=" + _shop.ShopAccount
|
||||
+ "&shop_group=" + GetHtml.UrlEncodeUtf8(_shop.GroupName)
|
||||
+ "&sub_user_name=" + _shop.SubUserName
|
||||
+ "¬es=" + GetHtml.UrlEncodeUtf8(_shop.Notes);
|
||||
@@ -123,6 +126,7 @@ namespace TemuKJD.PDDForms.ShopForms
|
||||
localShop.Notes = serverShop.Notes;
|
||||
localShop.LoginStatus = serverShop.LoginStatus;
|
||||
localShop.LoginStatus2 = serverShop.LoginStatus2;
|
||||
localShop.AntiContents = serverShop.AntiContents;
|
||||
localShop.AddProductRemaining = serverShop.AddProductRemaining;
|
||||
localShop.OperateSubSaName = serverShop.OperateSubSaName;
|
||||
if (localShop.TrialUploadCount < 0)
|
||||
@@ -316,13 +320,13 @@ namespace TemuKJD.PDDForms.ShopForms
|
||||
}
|
||||
else
|
||||
{
|
||||
PDDShopListForm.AddServerDouShop(shopInfo);
|
||||
PDDShopListForm.AddServerPddShop(shopInfo);
|
||||
btnRefreshCookie_Click(null, null);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
PDDShopListForm.MdyServerDouShop(shopInfo);
|
||||
PDDShopListForm.MdyServerPddShop(shopInfo);
|
||||
btnRefreshCookie_Click(null, null);
|
||||
}
|
||||
}
|
||||
@@ -406,7 +410,7 @@ namespace TemuKJD.PDDForms.ShopForms
|
||||
else
|
||||
GlobalConfig.ShopLoginList.Add(shop);
|
||||
StartUp.SaveLocalShopLoginInfo();
|
||||
PDDShopListForm.AddServerDouShop(shop);
|
||||
PDDShopListForm.AddServerPddShop(shop);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -680,11 +684,10 @@ namespace TemuKJD.PDDForms.ShopForms
|
||||
|
||||
public static string GetShopStatus(ShopLoginInfo shop)
|
||||
{
|
||||
//string url = "https://seller.kuajingmaihuo.com/bg/quiet/api/mms/userInfo";
|
||||
//string refere = "https://seller.kuajingmaihuo.com/";
|
||||
//string body = @"{}";
|
||||
//return KJDHttpResponse.PostResponse(shop, url, body, refere);
|
||||
return "";
|
||||
string url = "https://mms.pinduoduo.com/janus/api/userinfo";
|
||||
string refere = "https://mms.pinduoduo.com/login/";
|
||||
string body = @"{}";
|
||||
return HttpResponseBLL.PDDPostResponse(shop, url, body, refere);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -697,7 +700,7 @@ namespace TemuKJD.PDDForms.ShopForms
|
||||
//string url = "https://agentseller.temu.com/api/seller/auth/userInfo";
|
||||
//string refere = "https://agentseller.temu.com/";
|
||||
//string body = @"{}";
|
||||
//return KJDHttpResponse.PostResponse2(shop, url, body, refere);
|
||||
//return HttpResponseBLL.PDDPostResponse2(shop, url, body, refere);
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -706,7 +709,7 @@ namespace TemuKJD.PDDForms.ShopForms
|
||||
//string url = "https://seller.kuajingmaihuo.com/bg/quiet/api/auth/obtainCode";
|
||||
//string refere = "https://seller.kuajingmaihuo.com/settle/seller-login?redirectUrl=https%3A%2F%2Fagentseller.temu.com%2F®ion=1&source=https%3A%2F%2Fagentseller.temu.com%2Fmain%2Fauthentication%3FredirectUrl%3Dhttps%253A%252F%252Fagentseller.temu.com%252F";
|
||||
//string body = @"{""redirectUrl"":""https://agentseller.temu.com/main/authentication""}";
|
||||
//return KJDHttpResponse.PostResponse(shop, url, body, refere);
|
||||
//return HttpResponseBLL.PostResponse(shop, url, body, refere);
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -789,52 +792,52 @@ namespace TemuKJD.PDDForms.ShopForms
|
||||
}
|
||||
break;
|
||||
case "复制Cookie":
|
||||
string cook = shop.Cookies;
|
||||
List<CefSharp.Cookie> cooks = null;
|
||||
try { cooks = JsonHelper.DeserializeJsonToList<CefSharp.Cookie>(shop.Cookies); } catch (Exception ex) { }
|
||||
if (cooks == null)
|
||||
cooks = new List<CefSharp.Cookie>();
|
||||
|
||||
string cookJs = "";
|
||||
var keys = new string[] { "a42", "_bee", "_f77", "_nano_fp", "api_uid", "rckk", "ru1k", "ru2k", "SUB_PASS_ID" };
|
||||
//var keys2 = new string[] { "_bee", "_nano_fp", "api_uid", "dilx", "hfsc", "mallid", "njrpl", "seller_temp" };
|
||||
var keys2 = new string[] { "_bee", "_nano_fp", "api_uid", "dilx", "hfsc", "njrpl", "seller_temp" };
|
||||
foreach (var shopCook in shop.Cookies.Split(';'))
|
||||
var keys = new string[] { "_a42", "_bee", "_f77", "_nano_fp", "api_uid", "JSESSIONID", "mms_b84d1838", "rckk", "ru1k", "ru2k", "PASS_ID", "webp", "x-visit-time" };
|
||||
var keys2 = new string[] { /*"_bee", "_nano_fp", "api_uid", "dilx", "hfsc", "njrpl", "seller_temp"*/ };
|
||||
foreach (var shopCook in cooks)
|
||||
{
|
||||
var cookie = shopCook.Trim();
|
||||
var cookie = shopCook.Name + "=" + shopCook.Value;
|
||||
if (!keys.Any(k=>cookie.StartsWith(k)))
|
||||
continue;
|
||||
cookJs += "\r\ndocument.cookie='" + cookie.Substring(0, Math.Max(0, cookie.IndexOf("="))) + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;';";
|
||||
}
|
||||
foreach (var shopCook in shop.Cookies2.Split(';'))
|
||||
foreach (var shopCook in cooks)
|
||||
{
|
||||
var cookie = shopCook.Trim();
|
||||
cookJs += "\r\ndocument.cookie='" + cookie.Substring(0, Math.Max(0, cookie.IndexOf("="))) + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;';";
|
||||
}
|
||||
foreach (var shopCook in shop.Cookies.Split(';'))
|
||||
{
|
||||
var cookie = shopCook.Trim();
|
||||
var cookie = shopCook.Name + "=" + shopCook.Value;
|
||||
if (!keys.Any(k => cookie.StartsWith(k)))
|
||||
continue;
|
||||
if (!cookie.StartsWith("SUB_PASS_ID") && !cookie.StartsWith("_nano_fp"))
|
||||
cookJs += "\r\ndocument.cookie='" + cookie + "; domain=.kuajingmaihuo.com;';";
|
||||
if (!cookie.StartsWith("PASS_ID") && !cookie.StartsWith("_nano_fp") && !cookie.StartsWith("JSESSIONID") &&
|
||||
!cookie.StartsWith("mms_b84d1838") && !cookie.StartsWith("webp") && !cookie.StartsWith("x-visit-time"))
|
||||
cookJs += "\r\ndocument.cookie='" + cookie + "; domain=.pinduoduo.com;expires=" +
|
||||
DateTime.Now.AddMonths(1).ToUniversalTime().ToString("ddd, dd MMM yyyy HH:mm:ss 'UTC'", new DateTimeFormatInfo()) + "; path=/';";
|
||||
else
|
||||
cookJs += "\r\ndocument.cookie='" + cookie + "; domain=seller.kuajingmaihuo.com;';";
|
||||
cookJs += "\r\ndocument.cookie='" + cookie + "; domain=mms.pinduoduo.com; expires=" +
|
||||
DateTime.Now.AddMonths(1).ToUniversalTime().ToString("ddd, dd MMM yyyy HH:mm:ss 'UTC'", new DateTimeFormatInfo()) + "; path=/';";
|
||||
}
|
||||
// 全球站cookie
|
||||
foreach (var shopCook in shop.Cookies2.Split(';'))
|
||||
{
|
||||
var cookie = shopCook.Trim();
|
||||
if (cookie.StartsWith("mallid"))
|
||||
cookie = "mallid=" + shop.ShopId;
|
||||
if (!keys2.Any(k => cookie.StartsWith(k)))
|
||||
continue;
|
||||
if (!cookie.StartsWith("seller_temp") && !cookie.StartsWith("_nano_fp") && !cookie.StartsWith("mallid"))
|
||||
cookJs += "\r\ndocument.cookie='" + cookie + "; domain=.temu.com; expires=" +
|
||||
DateTime.Now.AddDays(1).ToUniversalTime().ToString("ddd, dd MMM yyyy HH:mm:ss 'UTC'", new DateTimeFormatInfo()) + "; path=/';";
|
||||
else
|
||||
cookJs += "\r\ndocument.cookie='" + cookie + "; domain=agentseller.temu.com; expires=" +
|
||||
DateTime.Now.AddDays(1).ToUniversalTime().ToString("ddd, dd MMM yyyy HH:mm:ss 'UTC'", new DateTimeFormatInfo()) + "; path=/';";
|
||||
}
|
||||
cookJs += "\r\nwindow.localStorage.setItem('" + "mall-info-id" + "', '" + shop.ShopId + "');";
|
||||
cookJs += "\r\nwindow.localStorage.setItem('" + "agentseller-mall-info-id" + "', '" + shop.ShopId + "');";
|
||||
cookJs += "\r\nsetTimeout(() => { window.location.href='https://agentseller.temu.com'; }, 200)";
|
||||
//foreach (var shopCook in shop.Cookies2.Split(';'))
|
||||
//{
|
||||
// var cookie = shopCook.Trim();
|
||||
// if (cookie.StartsWith("mallid"))
|
||||
// cookie = "mallid=" + shop.ShopId;
|
||||
// if (!keys2.Any(k => cookie.StartsWith(k)))
|
||||
// continue;
|
||||
// if (!cookie.StartsWith("seller_temp") && !cookie.StartsWith("_nano_fp") && !cookie.StartsWith("mallid"))
|
||||
// cookJs += "\r\ndocument.cookie='" + cookie + "; domain=.temu.com; expires=" +
|
||||
// DateTime.Now.AddDays(1).ToUniversalTime().ToString("ddd, dd MMM yyyy HH:mm:ss 'UTC'", new DateTimeFormatInfo()) + "; path=/';";
|
||||
// else
|
||||
// cookJs += "\r\ndocument.cookie='" + cookie + "; domain=agentseller.temu.com; expires=" +
|
||||
// DateTime.Now.AddDays(1).ToUniversalTime().ToString("ddd, dd MMM yyyy HH:mm:ss 'UTC'", new DateTimeFormatInfo()) + "; path=/';";
|
||||
//}
|
||||
//cookJs += "\r\nwindow.localStorage.setItem('" + "mall-info-id" + "', '" + shop.ShopId + "');";
|
||||
//cookJs += "\r\nwindow.localStorage.setItem('" + "agentseller-mall-info-id" + "', '" + shop.ShopId + "');";
|
||||
cookJs += "\r\nsetTimeout(() => { window.location.href='https://mms.pinduoduo.com/home'; }, 200)";
|
||||
Clipboard.SetDataObject(cookJs);
|
||||
BaseMsgForm.ShowInfo("复制成功");
|
||||
break;
|
||||
|
||||
@@ -70,12 +70,6 @@ namespace TemuKJD.PDDForms.ShopForms
|
||||
{
|
||||
//this.splitContainer1.SplitterDistance = 674;
|
||||
|
||||
if (openType == EnumOpenType.login)
|
||||
{
|
||||
//this.shop.ShopId = "";
|
||||
//this.shop.ShopAccount = "";
|
||||
}
|
||||
|
||||
if (isMultiLogin && shop != null)
|
||||
{
|
||||
this.pnlMultiLogin.Visible = true;
|
||||
@@ -98,7 +92,7 @@ namespace TemuKJD.PDDForms.ShopForms
|
||||
AutoLogin();
|
||||
|
||||
CheckAndSaveShop(); //判断登录是否成功,成功则保存店铺信息和店铺cookie
|
||||
//ClosePopWindow(); //自动关闭弹窗
|
||||
//ClosePopWindow(); //自动关闭弹窗
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -112,7 +106,7 @@ namespace TemuKJD.PDDForms.ShopForms
|
||||
while (this.Created)
|
||||
{
|
||||
Thread.Sleep(3000);
|
||||
//continue;
|
||||
|
||||
if (!this.Created)
|
||||
break;
|
||||
|
||||
@@ -129,18 +123,21 @@ namespace TemuKJD.PDDForms.ShopForms
|
||||
|
||||
string cookies = "";
|
||||
List<Cookie> cookieList = CEFBrowser.GetCookieList(shopCookieHead, cefWebBrowser.GetCookieManager(null));
|
||||
List<Cookie> cookieListNew = new List<Cookie>();
|
||||
if (cookieList != null && cookieList.Count > 0)
|
||||
{
|
||||
foreach (var cookie in cookieList)
|
||||
{
|
||||
//SUB_PASS_ID同时出现两个,domain是seller.kuajingmaihuo.com才是能登录店铺后台的
|
||||
//PASS_ID同时出现两个,domain是mms.pinduoduo.com才是能登录店铺后台的
|
||||
if (cookie.Name == "PASS_ID" && cookie.Domain != "mms.pinduoduo.com"
|
||||
&& cookieList.Any(c=>c.Name== "PASS_ID" && c.Domain == "mms.pinduoduo.com"))
|
||||
&& cookieList.Any(c => c.Name == "PASS_ID" && c.Domain == "mms.pinduoduo.com"))
|
||||
continue;
|
||||
|
||||
cookies += cookie.Name + "=" + cookie.Value + "; ";
|
||||
cookieListNew.Add(cookie);
|
||||
}
|
||||
cookies = cookies.Trim().TrimEnd(';');
|
||||
//cookies = cookies.Trim().TrimEnd(';');
|
||||
cookies = JsonHelper.SerializeObject(cookieListNew);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(cookies)
|
||||
@@ -160,6 +157,7 @@ namespace TemuKJD.PDDForms.ShopForms
|
||||
ShopId = sc.AccountId,
|
||||
SubUserName = shop.SubUserName,
|
||||
Notes = shop.Notes,
|
||||
AntiContents = new List<string> { sc.AntiContent },
|
||||
};
|
||||
|
||||
var oldShop = GlobalConfig.ShopLoginList.FirstOrDefault(l =>
|
||||
@@ -167,7 +165,7 @@ namespace TemuKJD.PDDForms.ShopForms
|
||||
if (oldShop == null)
|
||||
{
|
||||
GlobalConfig.ShopLoginList.Add(newShop);
|
||||
PDDShopListForm.AddServerDouShop(newShop); // 店铺写入到服务端
|
||||
PDDShopListForm.AddServerPddShop(newShop); // 店铺写入到服务端
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -178,6 +176,24 @@ namespace TemuKJD.PDDForms.ShopForms
|
||||
oldShop.ShopId = newShop.ShopId;
|
||||
oldShop.SubUserName = newShop.SubUserName;
|
||||
oldShop.Notes = newShop.Notes;
|
||||
oldShop.AntiContents.AddRange(newShop.AntiContents);
|
||||
while (oldShop.AntiContents.Count > 10)
|
||||
oldShop.AntiContents.RemoveAt(0);
|
||||
|
||||
// 店铺更新写入到服务端
|
||||
var url = BaseClass.BuildObjString("shop/mdy_shop");
|
||||
var data = UserLogin.GetSignaturex()
|
||||
+ "&login_name=" + oldShop.LoginName
|
||||
+ "&new_shop_id=" + oldShop.ShopId
|
||||
+ "&shop_account=" + oldShop.ShopAccount;
|
||||
var result = GetHtml.PostUtf8(url, data);
|
||||
|
||||
var urlAddress = BaseClass.BuildObjString("shop/mdy_anti_content");
|
||||
data = UserLogin.GetSignaturex()
|
||||
+ "&login_name=" + shop.LoginName
|
||||
+ "&shop_id=" + shop.ShopId
|
||||
+ "&anti_contents=" + JsonHelper.SerializeObject(shop.AntiContents);
|
||||
result = GetHtml.PostUtf8(urlAddress, data);
|
||||
}
|
||||
}
|
||||
var lstShop = GlobalConfig.ShopLoginList.Where(l => l.LoginName == shop.LoginName).ToList();
|
||||
@@ -306,10 +322,19 @@ namespace TemuKJD.PDDForms.ShopForms
|
||||
if (shop.Cookies2 == null)
|
||||
shop.Cookies2 = "";
|
||||
|
||||
var cookie = shop.Cookies;
|
||||
if (isMultiLogin)
|
||||
cookie = shop.DictMultiCookies.Keys.Contains(MultiLoginCookieName) ? shop.DictMultiCookies[MultiLoginCookieName] : "";
|
||||
|
||||
//var cookie = shop.Cookies;
|
||||
//if (isMultiLogin)
|
||||
// cookie = shop.DictMultiCookies.Keys.Contains(MultiLoginCookieName) ? shop.DictMultiCookies[MultiLoginCookieName] : "";
|
||||
List<Cookie> cookieLst = new List<Cookie>();
|
||||
try
|
||||
{
|
||||
cookieLst = JsonHelper.DeserializeJsonToList<CefSharp.Cookie>(shop.Cookies);
|
||||
if (cookieLst == null)
|
||||
cookieLst = new List<Cookie>();
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
Task.Run(() =>
|
||||
{
|
||||
@@ -324,8 +349,15 @@ namespace TemuKJD.PDDForms.ShopForms
|
||||
CEFBrowser.DeleteCookie(cefWebBrowser.GetCookieManager(null));
|
||||
|
||||
//cef 138 如果没有设置RequestContext 可能为空,直接getCookieManager
|
||||
var t = CEFBrowser.SetCookieAsync(shopCookieHead, cookie, cefWebBrowser.GetCookieManager(null));
|
||||
t.Wait(5000);
|
||||
//if (this.openType != EnumOpenType.login)
|
||||
{
|
||||
//var t = CEFBrowser.SetCookieAsync(JsonHelper.SerializeObject(cookieLst), cefWebBrowser.GetCookieManager(null));
|
||||
foreach(var cook in cookieLst)
|
||||
{
|
||||
var t = CEFBrowser.SetCookieAsync(cook.Domain, cook.Name + "=" + cook.Value + ";", cefWebBrowser.GetCookieManager(null));
|
||||
t.Wait(5000);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.openType != EnumOpenType.login)
|
||||
{
|
||||
@@ -346,6 +378,8 @@ namespace TemuKJD.PDDForms.ShopForms
|
||||
|
||||
if (!string.IsNullOrEmpty(InitUrl))
|
||||
cefWebBrowser.Load(InitUrl);
|
||||
else
|
||||
cefWebBrowser.Load(shopMainUrl);
|
||||
|
||||
//不是登录的话就此返回
|
||||
if (openType != EnumOpenType.login)
|
||||
@@ -365,27 +399,17 @@ namespace TemuKJD.PDDForms.ShopForms
|
||||
}
|
||||
Thread.Sleep(Randomx.GetId(1500,2000));
|
||||
|
||||
//设置 local storage
|
||||
//if (GlobalConfig.dicLocalStorage != null)
|
||||
//{
|
||||
// Thread.Sleep(500);
|
||||
// string jsCode = "function setStorage() {";
|
||||
// foreach (var item in GlobalConfig.dicLocalStorage)
|
||||
// {
|
||||
// if (item.Key == "$TCC_CONFIG" || item.Key == "$TCC_CONFIG_operate_config" || item.Key == "menuStyleStr")
|
||||
// continue;
|
||||
|
||||
// jsCode += "window.localStorage.setItem('" + item.Key + "', '" + item.Value + "');\r\n";
|
||||
// }
|
||||
// jsCode += "}";
|
||||
// jsCode += "setStorage();";
|
||||
// if (cefWebBrowser.GetBrowser().MainFrame.IsValid)
|
||||
// cefWebBrowser.GetBrowser().MainFrame.ExecuteJavaScriptAsync(jsCode);
|
||||
//}
|
||||
|
||||
if (!this.Created)
|
||||
return;
|
||||
|
||||
while (!cefWebBrowser.Address.StartsWith(shopLoginUrl))
|
||||
{
|
||||
Thread.Sleep(1000);
|
||||
if (!this.Created)
|
||||
return;
|
||||
}
|
||||
|
||||
CEFBrowser.DeleteCookie(cefWebBrowser.GetCookieManager(null));
|
||||
InputUserNameAndPassword(cefWebBrowser, shop.LoginName, DataOpenSSL.DecryptString(shop.Password));
|
||||
});
|
||||
}
|
||||
@@ -436,32 +460,45 @@ namespace TemuKJD.PDDForms.ShopForms
|
||||
cefWebBrowser.GetBrowser().MainFrame.EvaluateScriptAsync(sb.ToString());
|
||||
}
|
||||
|
||||
int GetAntiContentsTimes = 0;
|
||||
private void RequestHandler_ResourceLoadComplete(object sender, string url, string postData, string responseData, IRequest request)
|
||||
{
|
||||
var antiContent = request.Headers.AllKeys.Contains("Anti-Content") ? request.Headers["Anti-Content"] : "";
|
||||
if (shop != null && !url.StartsWith("https://mms.pinduoduo.com/janus/api/userinfo") && !string.IsNullOrEmpty(antiContent))
|
||||
{
|
||||
GetAntiContentsTimes++;
|
||||
shop.AntiContents.Add(antiContent);
|
||||
while (shop.AntiContents.Count > 10)
|
||||
shop.AntiContents.RemoveAt(0);
|
||||
if (!string.IsNullOrEmpty(shop.ShopId) && GetAntiContentsTimes > 5)
|
||||
{
|
||||
GetAntiContentsTimes = 0;
|
||||
var antis = shop.AntiContents;
|
||||
Task.Run(() =>
|
||||
{
|
||||
var urlAddress = BaseClass.BuildObjString("shop/mdy_anti_content");
|
||||
var data = UserLogin.GetSignaturex()
|
||||
+ "&login_name=" + shop.LoginName
|
||||
+ "&shop_id=" + shop.ShopId
|
||||
+ "&anti_contents=" + JsonHelper.SerializeObject(antis);
|
||||
var result = GetHtml.PostUtf8(urlAddress, data);
|
||||
});
|
||||
}
|
||||
}
|
||||
Task.Run(() =>
|
||||
{
|
||||
var data = responseData;
|
||||
var uri = url;
|
||||
if (data.Contains("球球小小"))
|
||||
{
|
||||
|
||||
}
|
||||
if (data.Contains("supplierId") && data.Contains("\"success\":true"))
|
||||
{
|
||||
var supplierIds = BaseRegex.GetMatchRegex(ref data, "\"supplierId\":\\d{5,20}");
|
||||
if (supplierIds.Count > 0 && supplierIds[0].Groups.Count > 0)
|
||||
{
|
||||
var supplierId = supplierIds[0].Groups[0].Value.Replace("\"supplierId\":", "").ParseToLong();
|
||||
if (supplierId > 0)
|
||||
this.currentSupplierId = supplierId;
|
||||
}
|
||||
}
|
||||
//var data = responseData;
|
||||
//if (data.Contains("supplierId") && data.Contains("\"success\":true"))
|
||||
//{
|
||||
// var supplierIds = BaseRegex.GetMatchRegex(ref data, "\"supplierId\":\\d{5,20}");
|
||||
// if (supplierIds.Count > 0 && supplierIds[0].Groups.Count > 0)
|
||||
// {
|
||||
// var supplierId = supplierIds[0].Groups[0].Value.Replace("\"supplierId\":", "").ParseToLong();
|
||||
// if (supplierId > 0)
|
||||
// this.currentSupplierId = supplierId;
|
||||
// }
|
||||
//}
|
||||
});
|
||||
if (url.StartsWith("https://seller.kuajingmaihuo.com/settle/site-main"))
|
||||
{
|
||||
cefWebBrowser.Load(shopMainUrl);
|
||||
}
|
||||
//if (url == shopMainUrl)
|
||||
if (url == "https://mms.pinduoduo.com/janus/api/userinfo")
|
||||
{
|
||||
Task.Run(() =>
|
||||
@@ -471,7 +508,7 @@ namespace TemuKJD.PDDForms.ShopForms
|
||||
{
|
||||
var maskMobile = BaseRegex.GetStringJson(ref data, "mobile");
|
||||
maskMobile = maskMobile.Split('*').Last();
|
||||
if (shop.LoginName.EndsWith(maskMobile))
|
||||
if (!string.IsNullOrEmpty(maskMobile) && shop.LoginName.EndsWith(maskMobile))
|
||||
{
|
||||
lstShopCompany.Clear();
|
||||
var jObj = JObject.Parse(data);
|
||||
@@ -480,19 +517,6 @@ namespace TemuKJD.PDDForms.ShopForms
|
||||
jArr = new JArray();
|
||||
|
||||
Thread.Sleep(500);
|
||||
//foreach (var productObj in jArr)
|
||||
//{
|
||||
// var prod = JsonHelper.SerializeObject(productObj);
|
||||
// ShopCompany sc = new ShopCompany()
|
||||
// {
|
||||
// AccountId = BaseRegex.GetStringJson(ref prod, "mallId"),
|
||||
// AccountName = BaseRegex.GetStringJson(ref prod, "mallName"),
|
||||
// LoginName = shop.LoginName,
|
||||
// UserName = BaseClass.UserName,
|
||||
// LoginStatus = "登录成功",
|
||||
// };
|
||||
// this.lstShopCompany.Add(sc);
|
||||
//}
|
||||
|
||||
ShopCompany sc = new ShopCompany()
|
||||
{
|
||||
@@ -502,35 +526,15 @@ namespace TemuKJD.PDDForms.ShopForms
|
||||
LoginName = shop.LoginName,
|
||||
UserName = BaseClass.UserName,
|
||||
LoginStatus = "登录成功",
|
||||
AntiContent = antiContent,
|
||||
};
|
||||
this.lstShopCompany.Add(sc);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
//if (url.Contains("_signature"))
|
||||
//{
|
||||
// var re = request;
|
||||
// if ((re.Headers != null && re.Headers.AllKeys.Contains("x-secsdk-csrf-token")))
|
||||
// {
|
||||
// }
|
||||
// Task.Run(() =>
|
||||
// {
|
||||
// var _url = url;
|
||||
// var data = responseData;
|
||||
// var signature = url.Substring(url.IndexOf("_signature=") + "_signature=".Length).Split('&')[0];
|
||||
// if (shop != null)
|
||||
// {
|
||||
// shop.Signature = signature;
|
||||
// }
|
||||
// if (url.Contains("x-secsdk-csrf-token") || postData.Contains("x-secsdk-csrf-token") || data.Contains("x-secsdk-csrf-token"))
|
||||
// {
|
||||
// }
|
||||
// });
|
||||
//}
|
||||
// 库存上传按钮
|
||||
if (currentUrl.StartsWith("https://seller.kuajingmaihuo.com/goods/product/list") ||
|
||||
currentUrl.StartsWith("https://agentseller.temu.com/goods/list"))
|
||||
if (1 == 1 && currentUrl.StartsWith("https://mms.pinduoduo.com/goods/goods_list"))
|
||||
{
|
||||
Task.Run(() => {
|
||||
string sAddInputJs = @"
|
||||
@@ -556,11 +560,13 @@ namespace TemuKJD.PDDForms.ShopForms
|
||||
addGetProdButton();
|
||||
|
||||
function addGetProdButton() {
|
||||
var productLst = document.getElementsByClassName('product-info_idContent__iDukx');
|
||||
var productLst = document.getElementsByClassName('goods-id');
|
||||
for(i=0; i<productLst.length; i++) {
|
||||
if (productLst[i].innerHTML.indexOf('库存上传') < 0 && productLst[i].innerHTML.indexOf('SPU ID') >= 0) {
|
||||
var sSpuId = productLst[i].innerText.replace('\r','').replace('\n','').replace('SPU ID:', '');
|
||||
productLst[i].innerHTML = productLst[i].innerHTML.replace(""></div>"", ""><input type=\""button\"" style=\""margin-left: 50px; width:60px; text-align:center\"" value=\""库存上传\"" onclick=\""shopObj.getThirdProduct('"" + sSpuId + ""'," + this.currentSupplierId + @")\""></div>"");
|
||||
var addBtnItem = productLst[i].parentElement.parentElement;
|
||||
if (addBtnItem.parentElement.innerHTML.indexOf('库存上传') < 0 && addBtnItem.parentElement.innerHTML.indexOf('ID:') >= 0) {
|
||||
var sSpuId = addBtnItem.innerText.replace('\r','').replace('\n','').replace('ID: ', '');
|
||||
addBtnItem.outerHTML = addBtnItem.outerHTML.replace(""<section>"",""<section style=\""display:inline; float:left; \"">"")
|
||||
.replace(""</section>"", ""</section><input type=\""button\"" style=\""display:inline; width:60px; margin-left:10px; margin-top:0px; cursor:pointer; border:1px solid\"" value =\""库存上传\"" onclick=\""shopObj.getThirdProduct('"" + sSpuId + ""','" + this.shop.ShopId + @"')\"">"");
|
||||
}
|
||||
}
|
||||
}";
|
||||
|
||||
@@ -312,7 +312,7 @@ namespace TemuKJD.PDDForms.ShopForms
|
||||
if (updateFrom != SetCookieFromEnum.normal_user)
|
||||
ShopBLL.AdminAddServerShop(newShop); // 店铺写入到服务端
|
||||
else
|
||||
PDDShopListForm.AddServerDouShop(newShop); // 店铺写入到服务端
|
||||
PDDShopListForm.AddServerPddShop(newShop); // 店铺写入到服务端
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user