1上传草稿箱接口改用国际版 2配套相关登录、cookie保存、导出、导入等功能

This commit is contained in:
wule committed 2025-07-30 19:22:43 +08:00
1 parent c032747651
commit 096e1a450d
20 files changed
+825 -249

No files matched your search

@@ -105,6 +105,9 @@ namespace TemuKJD.KJDForms.ProductThirdSelectForms
lstAdminTemuDBProductSelect.AddRange(list);
this.ucSplitPage1.TotalPage = pageCount;
var shopIdLst = list.Select(p => p.shop_id).Distinct().ToList();
shopLst = AdminGetServerShopLst(shopIdLst);
if (defaultBitmap == null)
defaultBitmap = new Bitmap(80, 80);
// 获取Bitmap的Graphics对象
@@ -123,7 +126,7 @@ namespace TemuKJD.KJDForms.ProductThirdSelectForms
prodSelect.shop_id,
prodSelect.shop_account,
"进店",
"登录",
shopLst.FirstOrDefault(s => s.ShopId == prodSelect.shop_id)?.LoginStatus2 == "国际版在线" ? "在线" : "登录",
"导入Cookies",
"复制Cookies",
prodSelect.spu_id,
@@ -301,7 +304,8 @@ namespace TemuKJD.KJDForms.ProductThirdSelectForms
{
var shop = GetShop(shopId);
AdminShopLoginForm adminLoginForm = new AdminShopLoginForm(shop);
adminLoginForm.InitUrl = "https://seller.kuajingmaihuo.com/goods/product-create/product-edit?productDraftId=" +
//adminLoginForm.InitUrl = "https://seller.kuajingmaihuo.com/goods/product-create/product-edit?productDraftId=" +
adminLoginForm.InitUrl = "https://agentseller.temu.com/goods/edit?productDraftId=" +
draftId + "&from=productDraftList";
adminLoginForm.openType = EnumOpenType.manage;
adminLoginForm.WindowState = FormWindowState.Maximized;
@@ -312,7 +316,8 @@ namespace TemuKJD.KJDForms.ProductThirdSelectForms
{
var shop = GetShop(shopId);
AdminShopLoginForm adminLoginForm = new AdminShopLoginForm(shop);
adminLoginForm.InitUrl = "https://seller.kuajingmaihuo.com/goods/product/draft";
//adminLoginForm.InitUrl = "https://seller.kuajingmaihuo.com/goods/product/draft";
adminLoginForm.InitUrl = "https://agentseller.temu.com/goods/draft";
adminLoginForm.openType = EnumOpenType.manage;
adminLoginForm.WindowState = FormWindowState.Maximized;
adminLoginForm.ShowDialog();
@@ -326,13 +331,20 @@ namespace TemuKJD.KJDForms.ProductThirdSelectForms
shopLoginForm.openType = EnumOpenType.login;
shopLoginForm.SaveComplete += ShopLoginForm_SaveComplete;
shopLoginForm.ShowDialog();
foreach (DataGridViewRow row in this.dgvSelectProduct.Rows)
{
if (row.Cells["colSelectId"].Value.ParseToString() == shop.ShopId)
{
row.Cells["colLogin"].Value = shop.LoginStatus2 == "国际版在线" ? "在线" : "登录";
}
}
}
break;
case "导入Cookies":
{
var shop = GetShop(shopId);
ShopUpdateCookieForm updateCookieForm = new ShopUpdateCookieForm(shop, SetCookieFromEnum.sa);
ShopUpdateCookieForm updateCookieForm = new ShopUpdateCookieForm(shop, SetCookieFromEnum.sa, "国际版");
updateCookieForm.SaveComplete += UpdateCookieForm_SaveComplete;
updateCookieForm.ShowDialog();
}
@@ -349,6 +361,11 @@ namespace TemuKJD.KJDForms.ProductThirdSelectForms
//if (!cookie.StartsWith("SUB_PASS_ID") && !cookie.StartsWith("_nano_fp"))
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(';'))
{
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();
@@ -359,8 +376,20 @@ namespace TemuKJD.KJDForms.ProductThirdSelectForms
else
cookJs += "\r\ndocument.cookie='" + cookie + "; domain=seller.kuajingmaihuo.com;';";
}
// 全球站cookie
foreach (var shopCook in shop.Cookies2.Split(';'))
{
var cookie = shopCook.Trim();
if (cookie.StartsWith("mc-pc-cookie-captcha-token="))
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("yyyy-MM-ddTHH:mm:ss.fffZ") + "; path=/';";
else
cookJs += "\r\ndocument.cookie='" + cookie + "; domain=agentseller.temu.com; expires=" + DateTime.Now.AddDays(1).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffZ") + "; path=/';";
}
cookJs += "\r\nwindow.localStorage.setItem('" + "mall-info-id" + "', '" + shop.ShopId + "');";
cookJs += "\r\nsetTimeout(() => { window.location.href='https://seller.kuajingmaihuo.com'; }, 200)";
cookJs += "\r\nwindow.localStorage.setItem('" + "agentseller-mall-info-id" + "', '" + shop.ShopId + "');";
cookJs += "\r\nsetTimeout(() => { window.location.href='https://agentseller.temu.com'; }, 200)";
Clipboard.SetDataObject(cookJs);
BaseMsgForm.ShowInfo("复制成功");
}
@@ -504,6 +533,15 @@ namespace TemuKJD.KJDForms.ProductThirdSelectForms
continue;
}
if (shop.LoginStatus2 != "国际版在线")
{
Invoke(new Action(() =>
{
row.Cells["colOpResult"].Value = "店铺" + shop.LoginStatus2;
}));
continue;
}
//if (prod.status != "待上传")
//{
// Invoke(new Action(() =>
@@ -554,7 +592,7 @@ namespace TemuKJD.KJDForms.ProductThirdSelectForms
if (result.Contains("登录过期"))
{
shop.LoginStatus = "未登录";
ShopForms.ShopListForm.UpdateServerShopCookies(shop, shop.Cookies); // 店铺cookie写入服务端,多店共用一个登录账号一组cookie
ShopForms.ShopListForm.UpdateServerShopCookies(shop); // 店铺cookie写入服务端,多店共用一个登录账号一组cookie
}
}
catch (Exception ex)
@@ -618,12 +656,19 @@ namespace TemuKJD.KJDForms.ProductThirdSelectForms
}
public ShopLoginInfo AdminGetServerShop(string shop_id)
{
List<ShopLoginInfo> list = AdminGetServerShopLst(new string[] { shop_id }.ToList());
return list.FirstOrDefault();
}
public List<ShopLoginInfo> AdminGetServerShopLst(List<string> shop_ids)
{
List<ShopLoginInfo> list = new List<ShopLoginInfo>();
var url = BaseClass.BuildObjString("shop/admin_get_shop_list");
var data = UserLogin.GetSignaturex() +
"&search_id=" + shop_id;
"&shop_ids='" + string.Join("','", shop_ids) + "'";
data += "&page_size=200";
var html = GetHtml.PostUtf8(url, data);
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
html = GetHtml.PostUtf8(url, data);
@@ -632,12 +677,12 @@ namespace TemuKJD.KJDForms.ProductThirdSelectForms
if (string.IsNullOrEmpty(html)
|| !html.Contains("shop_id") || !html.Contains("shop_account") || !html.Contains("login_pass"))
{
return null;
return new List<ShopLoginInfo>();
}
var jArr = JObject.Parse(html)["data"];
if (jArr.Count() == 0)
return null;
return new List<ShopLoginInfo>();
foreach (JObject jObj in jArr)
{
@@ -660,11 +705,12 @@ namespace TemuKJD.KJDForms.ProductThirdSelectForms
shop.CompanyName = BaseRegex.GetStringJson(ref shopStr, "company_name");
shop.Notes = BaseRegex.GetStringJson(ref shopStr, "notes");
shop.LoginStatus = BaseRegex.GetStringJson(ref shopStr, "login_status");
shop.LoginStatus2 = BaseRegex.GetStringJson(ref shopStr, "login_status2");
shop.OperateSubSaName = BaseRegex.GetStringJson(ref shopStr, "operate_sub_sa_name");
list.Add(shop);
}
return list.FirstOrDefault();
return list;
}
public TemuDBProduct GetProductDetail(string prodDbId)
@@ -710,7 +756,7 @@ namespace TemuKJD.KJDForms.ProductThirdSelectForms
string UploadProduct(ShopLoginInfo shop, TemuProductInfo prodInfo, string sTemuSizeSpec = null)
{
if (shop == null || string.IsNullOrEmpty(shop.ShopId) || shop.LoginStatus != "登录成功")
if (shop == null || string.IsNullOrEmpty(shop.ShopId) || shop.LoginStatus != "登录成功" || shop.LoginStatus2 != "国际版在线")
{
return "店铺为空或未登录!";
}
@@ -1033,31 +1079,36 @@ namespace TemuKJD.KJDForms.ProductThirdSelectForms
private string AddDraft(ShopLoginInfo shop, string catId)
{
string url = "https://seller.kuajingmaihuo.com/bg-visage-mms/product/draft/add";
string refere = "https://seller.kuajingmaihuo.com/goods/product-create/category?from=productList";
//string url = "https://seller.kuajingmaihuo.com/bg-visage-mms/product/draft/add";
string url = "https://agentseller.temu.com/visage-agent-seller/product/draft/add";
//string refere = "https://seller.kuajingmaihuo.com/goods/product-create/category?from=productList";
string refere = "https://agentseller.temu.com/goods/create/category";
string body = @"{""catId"":" + catId + "}";
return KJDHttpResponse.PostResponse(shop, url, body, refere);
return KJDHttpResponse.PostResponse2(shop, url, body, refere);
}
private string CreateSizeSpec(ShopLoginInfo shop, string draftId, TemuSizeSpecParam sizeParam)
{
string url = "https://seller.kuajingmaihuo.com/bg-anniston-mms/sizespec/createSizeSpec";
//string url = "https://seller.kuajingmaihuo.com/bg-anniston-mms/sizespec/createSizeSpec";
string url = "https://agentseller.temu.com/anniston-agent-seller/sizespec/createSizeSpec";
string body = JsonHelper.SerializeObject(sizeParam);
string refere = "https://seller.kuajingmaihuo.com/goods/product-create/product-edit?productDraftId="+
draftId + "&from=productDraftList";
return KJDHttpResponse.PostResponse(shop, url, body, refere);
//string refere = "https://seller.kuajingmaihuo.com/goods/product-create/product-edit?productDraftId="+
// draftId + "&from=productDraftList";
string refere = "https://agentseller.temu.com/goods/edit?productDraftId=" + draftId + "&from=productDraftList";
return KJDHttpResponse.PostResponse2(shop, url, body, refere);
}
private string SaveDraft(ShopLoginInfo shop, string draftId, TemuProductParam prodParam)
{
string url = "https://seller.kuajingmaihuo.com/bg-visage-mms/product/draft/save";
//string url = "https://seller.kuajingmaihuo.com/bg-visage-mms/product/draft/save";
string url = "https://agentseller.temu.com/visage-agent-seller/product/draft/save";
string body = JsonHelper.SerializeObject(prodParam);
string refere = "https://seller.kuajingmaihuo.com/goods/product-create/product-edit?productDraftId=" +
draftId + "&from=productDraftList";
return KJDHttpResponse.PostResponse(shop, url, body, refere);
//string refere = "https://seller.kuajingmaihuo.com/goods/product-create/product-edit?productDraftId=" +
// draftId + "&from=productDraftList";
string refere = "https://agentseller.temu.com/goods/edit?productDraftId=" + draftId + "&from=productDraftList";
return KJDHttpResponse.PostResponse2(shop, url, body, refere);
}
private string AddProduct(ShopLoginInfo shop, string draftId, TemuProductParam prodParam)
{
string url = "https://seller.kuajingmaihuo.com/bg-visage-mms/product/add";