第三方库存上传功能

This commit is contained in:
wule committed 2025-07-22 16:57:02 +08:00
1 parent 0740da277c
commit 7e71b08863
29 files changed
+5391 -178

No files matched your search

@@ -13,17 +13,26 @@ using System.Windows.Forms;
using AllBase;
using NaiBa.Util.Extension;
using Newtonsoft.Json.Linq;
using Work;
using TemuKJD.KJDForms.AdminForms;
namespace TemuKJD.KJDForms.ShopForms
{
public enum SetCookieFromEnum
{
normal_user,
sa,
}
public partial class ShopUpdateCookieForm : LRBaseForm
{
ShopLoginInfo shopLoginInfo = null;
SetCookieFromEnum updateFrom;
public ShopUpdateCookieForm(ShopLoginInfo shop = null)
public ShopUpdateCookieForm(ShopLoginInfo shop = null, SetCookieFromEnum from = SetCookieFromEnum.normal_user)
{
InitializeComponent();
shopLoginInfo = shop;
updateFrom = from;
}
private void ShopUpdateCookieForm_Load(object sender, EventArgs e)
@@ -32,32 +41,32 @@ namespace TemuKJD.KJDForms.ShopForms
txtLoginName.Text = shopLoginInfo.LoginName + " " + shopLoginInfo.ShopAccount + " " + shopLoginInfo.Notes;
}
/*
localStorage.clear();
sessionStorage.clear();
var cookieDate = new Date(2037, 01, 01);
var cookieDateEnd = new Date(2000, 01, 01);
document.cookie = "SUB_PASS_ID=; path='/'; expires=" + cookieDateEnd.toUTCString();
document.cookie = "_nano_fp=; path='/'; expires=" + cookieDateEnd.toUTCString();
document.cookie = "api_uid=; path='/'; domain=.kuajingmaihuo.com; expires=" + cookieDateEnd.toUTCString();
document.cookie = "_bee=; path='/'; domain=.kuajingmaihuo.com; expires=" + cookieDateEnd.toUTCString();
document.cookie = "ru2k=; path='/'; domain=.kuajingmaihuo.com; expires=" + cookieDateEnd.toUTCString();
document.cookie = "_f77=; path='/'; domain=.kuajingmaihuo.com; expires=" + cookieDateEnd.toUTCString();
document.cookie = "_a42=; path='/'; domain=.kuajingmaihuo.com; expires=" + cookieDateEnd.toUTCString();
document.cookie = "rckk=; path='/'; domain=.kuajingmaihuo.com; expires=" + cookieDateEnd.toUTCString();
document.cookie = "ru1k=; path='/'; domain=.kuajingmaihuo.com; expires=" + cookieDateEnd.toUTCString();
document.cookie = "api_uid=CmP1wGhwa64RUwBSBILCAg==; path='/'; expires=" + cookieDate.toUTCString();
document.cookie = "_nano_fp=XpmyX5gbl09jlpdoXo_mijphq7nL0UmRaA77jyt3; domain=.kuajingmaihuo.com; path='/'; expires=" + cookieDate.toUTCString();
document.cookie = "_bee=NkjhfozSFfDuGSJ2zBlOqjOh3KVvJam3; path='/'; expires=" + cookieDate.toUTCString();
document.cookie = "_f77=2f854ce8-8d0f-4a78-84a1-04e19842a1cb; path='/'; expires=" + cookieDate.toUTCString();
document.cookie = "_a42=1e97ae4a-c357-4c22-a53f-db43655371e3; path='/'; expires=" + cookieDate.toUTCString();
document.cookie = "rckk=NkjhfozSFfDuGSJ2zBlOqjOh3KVvJam3; path='/'; expires=" + cookieDate.toUTCString();
document.cookie = "ru1k=2f854ce8-8d0f-4a78-84a1-04e19842a1cb; path='/'; expires=" + cookieDate.toUTCString();
document.cookie = "ru2k=1e97ae4a-c357-4c22-a53f-db43655371e3; path='/'; expires=" + cookieDate.toUTCString();
document.cookie = "SUB_PASS_ID=eyJ0IjoiRDZZY1F2N2JjMnZNK1E0eEZjTm1GVmxsN20yN3N3Ymg2dnVjdmxiclZPQW5uRkJlendUOUtKTHRoWHJyZWlNUCIsInYiOjEsInMiOjEwMDAwLCJ1IjoyMzAxMjcwOTkwNDI5OH0=; domain=.kuajingmaihuo.com; path='/'; expires=" + cookieDate.toUTCString();
location.reload();
window.location.href = 'https://seller.kuajingmaihuo.com/goods/product/list';
*/
/*
localStorage.clear();
sessionStorage.clear();
var cookieDate = new Date(2037, 01, 01);
var cookieDateEnd = new Date(2000, 01, 01);
document.cookie = "SUB_PASS_ID=; path='/'; expires=" + cookieDateEnd.toUTCString();
document.cookie = "_nano_fp=; path='/'; expires=" + cookieDateEnd.toUTCString();
document.cookie = "api_uid=; path='/'; domain=.kuajingmaihuo.com; expires=" + cookieDateEnd.toUTCString();
document.cookie = "_bee=; path='/'; domain=.kuajingmaihuo.com; expires=" + cookieDateEnd.toUTCString();
document.cookie = "ru2k=; path='/'; domain=.kuajingmaihuo.com; expires=" + cookieDateEnd.toUTCString();
document.cookie = "_f77=; path='/'; domain=.kuajingmaihuo.com; expires=" + cookieDateEnd.toUTCString();
document.cookie = "_a42=; path='/'; domain=.kuajingmaihuo.com; expires=" + cookieDateEnd.toUTCString();
document.cookie = "rckk=; path='/'; domain=.kuajingmaihuo.com; expires=" + cookieDateEnd.toUTCString();
document.cookie = "ru1k=; path='/'; domain=.kuajingmaihuo.com; expires=" + cookieDateEnd.toUTCString();
document.cookie = "api_uid=CmP1wGhwa64RUwBSBILCAg==; path='/'; expires=" + cookieDate.toUTCString();
document.cookie = "_nano_fp=XpmyX5gbl09jlpdoXo_mijphq7nL0UmRaA77jyt3; domain=.kuajingmaihuo.com; path='/'; expires=" + cookieDate.toUTCString();
document.cookie = "_bee=NkjhfozSFfDuGSJ2zBlOqjOh3KVvJam3; path='/'; expires=" + cookieDate.toUTCString();
document.cookie = "_f77=2f854ce8-8d0f-4a78-84a1-04e19842a1cb; path='/'; expires=" + cookieDate.toUTCString();
document.cookie = "_a42=1e97ae4a-c357-4c22-a53f-db43655371e3; path='/'; expires=" + cookieDate.toUTCString();
document.cookie = "rckk=NkjhfozSFfDuGSJ2zBlOqjOh3KVvJam3; path='/'; expires=" + cookieDate.toUTCString();
document.cookie = "ru1k=2f854ce8-8d0f-4a78-84a1-04e19842a1cb; path='/'; expires=" + cookieDate.toUTCString();
document.cookie = "ru2k=1e97ae4a-c357-4c22-a53f-db43655371e3; path='/'; expires=" + cookieDate.toUTCString();
document.cookie = "SUB_PASS_ID=eyJ0IjoiRDZZY1F2N2JjMnZNK1E0eEZjTm1GVmxsN20yN3N3Ymg2dnVjdmxiclZPQW5uRkJlendUOUtKTHRoWHJyZWlNUCIsInYiOjEsInMiOjEwMDAwLCJ1IjoyMzAxMjcwOTkwNDI5OH0=; domain=.kuajingmaihuo.com; path='/'; expires=" + cookieDate.toUTCString();
location.reload();
window.location.href = 'https://seller.kuajingmaihuo.com/goods/product/list';
*/
private void btnOk_Click(object sender, EventArgs e)
{
@@ -68,7 +77,7 @@ window.location.href = 'https://seller.kuajingmaihuo.com/goods/product/list';
}
string txt = this.txtCookieJs.Text;
txt = txt.Replace("SUB_PASS_ID=;", "").Replace("_nano_fp=;", "").Replace("api_uid=;","")
txt = txt.Replace("SUB_PASS_ID=;", "").Replace("_nano_fp=;", "").Replace("api_uid=;", "")
.Replace("_bee=;", "").Replace("ru2k=;", "").Replace("_f77=;", "")
.Replace("_a42=;", "").Replace("rckk=;", "").Replace("ru1k=;", "");
@@ -95,53 +104,64 @@ window.location.href = 'https://seller.kuajingmaihuo.com/goods/product/list';
{
BaseMsgForm.ShowError("Cookie缺少关键字段,请检查!");
return;
}
}
var cookieShop = new ShopLoginInfo();
cookieShop.Cookies = cookie;
var data = ShopListForm.GetShopStatus(cookieShop);
if ( data.Contains("\"success\":true"))
{
var maskMobile = BaseRegex.GetStringJson(ref data, "maskOwnerMobile");
if (shopLoginInfo.LoginName.EndsWith(maskMobile))
{
//如果店铺没有cookie登录过,处理店铺第一次登录(分裂cookie下的所有店铺)
GetShopFirstLogin(data);
shopLoginInfo.Cookies = cookie;
var campanys = GlobalConfig.ShopLoginList.Where(v => v.LoginName == shopLoginInfo.LoginName).ToList();
foreach (var sc in campanys)
{
sc.Cookies = cookie;
sc.LoginStatus = "登录成功";
}
ShopListForm.UpdateServerShopCookies(shopLoginInfo, shopLoginInfo.Cookies); // 店铺cookie写入服务端,多店共用一个登录账号一组cookie
this.OnSaveComplete(shopLoginInfo);
this.Close();
}
else
{
BaseMsgForm.ShowError("cookie与店铺不匹配,请核对店铺!");
return;
}
}
else
if (!data.Contains("\"success\":true"))
{
BaseMsgForm.ShowError("cookie已失效!");
return;
}
var maskMobile = BaseRegex.GetStringJson(ref data, "maskOwnerMobile");
if (!shopLoginInfo.LoginName.EndsWith(maskMobile))
{
BaseMsgForm.ShowError("cookie与店铺不匹配,请核对店铺!");
return;
}
List<ShopLoginInfo> serverShopLst = new List<ShopLoginInfo>();
var rst = AdminGetServerShopListForSetCookie(shopLoginInfo, serverShopLst);
if (rst != "success")
{
BaseMsgForm.ShowError(rst);
return;
}
//如果店铺没有cookie登录过,处理店铺第一次登录(分裂cookie下的所有店铺)
GetShopFirstLogin(data, serverShopLst);
if (updateFrom == SetCookieFromEnum.normal_user) // 普通用户更新本地店铺
{
var localShop = GlobalConfig.ShopLoginList.Where(v => v.LoginName == shopLoginInfo.LoginName).ToList();
foreach (var sc in localShop)
{
sc.Cookies = cookie;
sc.LoginStatus = "登录成功";
}
}
shopLoginInfo.Cookies = cookie;
shopLoginInfo.LoginStatus = "登录成功";
ShopListForm.UpdateServerShopCookies(shopLoginInfo, shopLoginInfo.Cookies); // 店铺cookie写入服务端,多店共用一个登录账号一组cookie
this.OnSaveComplete(shopLoginInfo);
this.Close();
}
/// <summary>
/// 如果店铺没有cookie登录过,处理店铺第一次登录(分裂cookie下的所有店铺)
/// </summary>
/// <param name="loginData"></param>
void GetShopFirstLogin(string loginData)
void GetShopFirstLogin(string loginData, List<ShopLoginInfo> lstServerShop)
{
if (this.shopLoginInfo == null)
return;
if (lstServerShop == null)
lstServerShop = new List<ShopLoginInfo>();
List<ShopCompany> lstShopCompany = new List<ShopCompany>();
var jObj = JObject.Parse(loginData);
@@ -168,6 +188,7 @@ window.location.href = 'https://seller.kuajingmaihuo.com/goods/product/list';
{
ShopLoginInfo newShop = new ShopLoginInfo()
{
UserName = shopLoginInfo.UserName,
LoginName = shopLoginInfo.LoginName,
Password = shopLoginInfo.Password,
GroupName = shopLoginInfo.GroupName,
@@ -177,14 +198,67 @@ window.location.href = 'https://seller.kuajingmaihuo.com/goods/product/list';
Notes = shopLoginInfo.Notes,
};
var oldShop = GlobalConfig.ShopLoginList.FirstOrDefault(l =>
l.LoginName == newShop.LoginName && l.ShopId == newShop.ShopId);
if (oldShop == null)
var oldServerShop = lstServerShop.FirstOrDefault(s =>
s.LoginName == newShop.LoginName && s.ShopId == newShop.ShopId);
if (oldServerShop == null)
{
GlobalConfig.ShopLoginList.Add(newShop);
ShopListForm.AddServerDouShop(newShop); // 店铺写入到服务端
if (updateFrom != SetCookieFromEnum.normal_user)
AdminShopForm.AdminAddServerShop(newShop); // 店铺写入到服务端
else
ShopListForm.AddServerDouShop(newShop); // 店铺写入到服务端
}
}
}
public static string AdminGetServerShopListForSetCookie(ShopLoginInfo loginShop, List<ShopLoginInfo> lstRst)
{
if (lstRst == null)
lstRst = new List<ShopLoginInfo>();
var url = BaseClass.BuildObjString("shop/admin_get_shop_list");
var data = UserLogin.GetSignaturex() +
"&search_user_name=" + loginShop.UserName +
"&search_login_name=" + loginShop.LoginName;
var 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("shop_id") || !html.Contains("shop_account") || !html.Contains("login_pass"))
{
return "获取失败:" + BaseRegex.GetStringJson(ref html, "msg");
}
var jArr = JObject.Parse(html)["data"];
if (jArr.Count() == 0)
return "获取失败:未获取到data数据";
foreach (JObject jObj in jArr)
{
string shopStr = jObj.ToString();
ShopLoginInfo shop = new ShopLoginInfo();
shop.DbId = BaseRegex.GetStringJson(ref shopStr, "id");
if (shop.DbId == null)
continue;
shop.LoginName = BaseRegex.GetStringJson(ref shopStr, "login_name");
shop.Password = BaseRegex.GetStringJson(ref shopStr, "login_pass");
shop.ShopId = BaseRegex.GetStringJson(ref shopStr, "shop_id");
shop.ShopAccount = BaseRegex.GetStringJson(ref shopStr, "shop_account");
shop.UserName = BaseRegex.GetStringJson(ref shopStr, "user_name");
shop.SubUserName = BaseRegex.GetStringJson(ref shopStr, "sub_user_name");
shop.GroupName = BaseRegex.GetStringJson(ref shopStr, "shop_group");
shop.Cookies = BaseRegex.GetStringJson(ref shopStr, "cookie");
shop.Cookies = shop.Cookies.Replace("&", "&").Replace("%", "%").Replace("+", "+");
shop.CompanyName = BaseRegex.GetStringJson(ref shopStr, "company_name");
shop.Notes = BaseRegex.GetStringJson(ref shopStr, "notes");
shop.LoginStatus = BaseRegex.GetStringJson(ref shopStr, "login_status");
shop.OperateSubSaName = BaseRegex.GetStringJson(ref shopStr, "operate_sub_sa_name");
lstRst.Add(shop);
}
return "success";
}
}
}