1优化cookie登录检测逻辑 2调整标题重组逻辑不再强制前缀 3库存上传、选品上传显示提交时间 4备货管理使用双接口处理
This commit is contained in:
1 parent
c203c161a2
commit
7ea35b6866
22 files changed
+479
-490
No files matched your search
@@ -19,7 +19,7 @@ namespace TemuKJD.KJDForms.AdminForms
|
||||
public partial class AdminForm : BaseForm
|
||||
{
|
||||
public Lazy<AdminAccountForm> adminAccountForm = new Lazy<AdminAccountForm>();
|
||||
public Lazy<AdminShopForm> adminShopForm = new Lazy<AdminShopForm>();
|
||||
public Lazy<AdminShopListForm> adminShopForm = new Lazy<AdminShopListForm>();
|
||||
public Lazy<DbProductListForm> dbProductListForm = new Lazy<DbProductListForm>();
|
||||
public Lazy<DbProductSelectListManageForm> dbProductSelectListManageForm = new Lazy<DbProductSelectListManageForm>();
|
||||
public Lazy<ProductThirdSelectListManageForm> productThirdSelectListManageForm = new Lazy<ProductThirdSelectListManageForm>();
|
||||
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
|
||||
namespace TemuKJD.KJDForms.AdminForms
|
||||
{
|
||||
partial class AdminShopForm
|
||||
partial class AdminShopListForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
@@ -635,7 +635,7 @@ namespace TemuKJD.KJDForms.AdminForms
|
||||
// colImportCookies
|
||||
//
|
||||
this.colImportCookies.FillWeight = 70F;
|
||||
this.colImportCookies.HeaderText = "导入Cookies";
|
||||
this.colImportCookies.HeaderText = "导入Cookie";
|
||||
this.colImportCookies.Name = "colImportCookies";
|
||||
this.colImportCookies.ReadOnly = true;
|
||||
this.colImportCookies.Resizable = System.Windows.Forms.DataGridViewTriState.True;
|
||||
@@ -644,7 +644,7 @@ namespace TemuKJD.KJDForms.AdminForms
|
||||
// colCopyCookies
|
||||
//
|
||||
this.colCopyCookies.FillWeight = 70F;
|
||||
this.colCopyCookies.HeaderText = "复制Cookies";
|
||||
this.colCopyCookies.HeaderText = "复制Cookie";
|
||||
this.colCopyCookies.Name = "colCopyCookies";
|
||||
this.colCopyCookies.ReadOnly = true;
|
||||
this.colCopyCookies.Resizable = System.Windows.Forms.DataGridViewTriState.True;
|
||||
+112
-18
@@ -22,11 +22,11 @@ using Work;
|
||||
|
||||
namespace TemuKJD.KJDForms.AdminForms
|
||||
{
|
||||
public partial class AdminShopForm : BaseForm
|
||||
public partial class AdminShopListForm : BaseForm
|
||||
{
|
||||
public static List<ShopLoginInfo> lstAdminShopInfo = new List<ShopLoginInfo>();
|
||||
public static List<ShopLoginInfo> lstAdminShopInfo { get; set; } = new List<ShopLoginInfo>();
|
||||
|
||||
public AdminShopForm()
|
||||
public AdminShopListForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
@@ -62,6 +62,7 @@ namespace TemuKJD.KJDForms.AdminForms
|
||||
|
||||
public void SearchShop(int page)
|
||||
{
|
||||
List<string> shopIdList = GetCheckedShopIdList();
|
||||
if (InvokeRequired)
|
||||
{
|
||||
Invoke(new Action(() =>
|
||||
@@ -80,7 +81,7 @@ namespace TemuKJD.KJDForms.AdminForms
|
||||
Task.Run(() =>
|
||||
{
|
||||
int pageCount;
|
||||
var list = AdminGetServerShop(out pageCount, page);
|
||||
var list = AdminGetServerShopLst(out pageCount, page);
|
||||
lstAdminShopInfo.AddRange(list);
|
||||
this.ucSplitPage1.TotalPage = pageCount;
|
||||
|
||||
@@ -89,7 +90,7 @@ namespace TemuKJD.KJDForms.AdminForms
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
int rowIndex = this.dgvShop.Rows.Add(
|
||||
false,
|
||||
shopIdList.Contains(shop.ShopId + shop.UserName),
|
||||
shop.LoginName,
|
||||
shop.ShopId,
|
||||
shop.ShopAccount,
|
||||
@@ -109,8 +110,8 @@ namespace TemuKJD.KJDForms.AdminForms
|
||||
"多重登录",
|
||||
shop.ApiAuthStatus,
|
||||
shop.BuyApiAuth.ApiAuthStatus,
|
||||
"导入Cookies",
|
||||
"复制Cookies",
|
||||
"导入Cookie",
|
||||
"复制Cookie",
|
||||
"上传",
|
||||
shop.OperateSubSaName,
|
||||
"编辑",
|
||||
@@ -208,7 +209,7 @@ namespace TemuKJD.KJDForms.AdminForms
|
||||
}
|
||||
IsOperate = false;
|
||||
break;
|
||||
case "复制Cookies":
|
||||
case "复制Cookie":
|
||||
string cook = shop.Cookies;
|
||||
string cookJs = "";
|
||||
var keys = new string[] { "a42", "_bee", "_f77", "_nano_fp", "api_uid", "rckk", "ru1k", "ru2k", "SUB_PASS_ID" };
|
||||
@@ -257,7 +258,7 @@ namespace TemuKJD.KJDForms.AdminForms
|
||||
Clipboard.SetDataObject(cookJs);
|
||||
BaseMsgForm.ShowInfo("复制成功");
|
||||
break;
|
||||
case "导入Cookies":
|
||||
case "导入Cookie":
|
||||
ShopUpdateCookieForm updateCookieForm = new ShopUpdateCookieForm(shop, SetCookieFromEnum.sa);
|
||||
updateCookieForm.SaveComplete += UpdateCookieForm_SaveComplete;
|
||||
updateCookieForm.ShowDialog();
|
||||
@@ -344,7 +345,22 @@ namespace TemuKJD.KJDForms.AdminForms
|
||||
return shopNameList;
|
||||
}
|
||||
|
||||
public List<ShopLoginInfo> AdminGetServerShop(out int pageCount, int page = 1, int pageSize = 50)
|
||||
private List<string> GetCheckedShopIdList()
|
||||
{
|
||||
List<string> shopNameList = new List<string>();
|
||||
for (int i = 0; i < dgvShop.Rows.Count; i++)
|
||||
{
|
||||
if (dgvShop.Rows[i].Cells["colSelect"].Value.ParseToBool())
|
||||
{
|
||||
string shopName = dgvShop.Rows[i].Cells["colShopId"].Value.ParseToString();
|
||||
shopName += dgvShop.Rows[i].Cells["colUser"].Value.ParseToString();
|
||||
shopNameList.Add(shopName);
|
||||
}
|
||||
}
|
||||
return shopNameList;
|
||||
}
|
||||
|
||||
public List<ShopLoginInfo> AdminGetServerShopLst(out int pageCount, int page = 1, int pageSize = 50)
|
||||
{
|
||||
List<ShopLoginInfo> list = new List<ShopLoginInfo>();
|
||||
pageCount = 1;
|
||||
@@ -375,9 +391,67 @@ namespace TemuKJD.KJDForms.AdminForms
|
||||
pageCount = Math.Ceiling(1.0 * count / pageSize).ParseToInt();
|
||||
pageCount = Math.Max(pageCount, 1);
|
||||
|
||||
var jArr = JObject.Parse(html)["data"];
|
||||
return DeserializationShop(html);
|
||||
}
|
||||
|
||||
public static List<ShopLoginInfo> AdminGetServerShopLstByIds(List<string> shop_ids)
|
||||
{
|
||||
List<ShopLoginInfo> list = new List<ShopLoginInfo>();
|
||||
shop_ids = shop_ids.Where(s => !string.IsNullOrEmpty(s)).ToList();
|
||||
|
||||
var url = BaseClass.BuildObjString("shop/admin_get_shop_list");
|
||||
var data = UserLogin.GetSignaturex() +
|
||||
"&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);
|
||||
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 new List<ShopLoginInfo>();
|
||||
}
|
||||
|
||||
return DeserializationShop(html);
|
||||
}
|
||||
|
||||
public static string AdminGetServerShopLstForSetCookie(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");
|
||||
}
|
||||
|
||||
lstRst.AddRange(DeserializationShop(html));
|
||||
|
||||
return "success";
|
||||
}
|
||||
|
||||
public static List<ShopLoginInfo> DeserializationShop(string shopJson)
|
||||
{
|
||||
List<ShopLoginInfo> list = new List<ShopLoginInfo>();
|
||||
if (!shopJson.Contains("data"))
|
||||
return list;
|
||||
|
||||
var jArr = JObject.Parse(shopJson)["data"];
|
||||
if (jArr.Count() == 0)
|
||||
return list;
|
||||
|
||||
foreach (JObject jObj in jArr)
|
||||
{
|
||||
string shopStr = jObj.ToString();
|
||||
@@ -401,6 +475,7 @@ namespace TemuKJD.KJDForms.AdminForms
|
||||
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");
|
||||
shop.AddProductRemaining = BaseRegex.GetIntJson(ref shopStr, "add_product_remaining");
|
||||
|
||||
list.Add(shop);
|
||||
}
|
||||
@@ -514,7 +589,8 @@ namespace TemuKJD.KJDForms.AdminForms
|
||||
}));
|
||||
}
|
||||
|
||||
CheckShopLogin(shopNames, isShowProgress);
|
||||
var shops = lstAdminShopInfo.Where(s => shopNames.Contains(s.LoginName));
|
||||
CheckShopLogin(shops.ToArray(), isShowProgress);
|
||||
|
||||
if (this.Created && isShowProgress)
|
||||
{
|
||||
@@ -526,21 +602,38 @@ namespace TemuKJD.KJDForms.AdminForms
|
||||
}
|
||||
}
|
||||
|
||||
public void CheckShopLogin(string[] shopNames, bool isShowProgress = true)
|
||||
public void CheckShopLogin(ShopLoginInfo[] shops, bool isShowProgress = true)
|
||||
{
|
||||
for (int i = 0; i < shopNames.Length; i++)
|
||||
var shopLoginNames = shops.Select(s => s.LoginName).Distinct().ToArray();
|
||||
for (int i = 0; i < shopLoginNames.Length; i++)
|
||||
{
|
||||
var shop = lstAdminShopInfo.FirstOrDefault(v => v.LoginName == shopNames[i]);
|
||||
var campanys = lstAdminShopInfo.Where(v => v.LoginName == shopNames[i]).ToList();
|
||||
var campanys = shops.Where(v => v.LoginName == shopLoginNames[i]).ToList();
|
||||
var shop = shops.FirstOrDefault(v => v.LoginName == shopLoginNames[i]);
|
||||
|
||||
// 先从服务端取最新cookie
|
||||
var serverCampanys = AdminGetServerShopLstByIds(campanys.Select(c => c.ShopId).ToList());
|
||||
var serverShop = serverCampanys.FirstOrDefault();
|
||||
if (shop != null && serverShop != null)
|
||||
{
|
||||
shop.Cookies = serverShop.Cookies;
|
||||
shop.Cookies2 = serverShop.Cookies2;
|
||||
foreach (var sc in campanys)
|
||||
{
|
||||
sc.Cookies = serverShop.Cookies;
|
||||
sc.Cookies2 = serverShop.Cookies2;
|
||||
}
|
||||
}
|
||||
|
||||
if (shop != null)
|
||||
{
|
||||
//var loginResult = "\"code\":0";//GetShopStatus(shop);
|
||||
var loginResult = ShopListForm.GetShopStatus(shop);
|
||||
if (!loginResult.Contains("\"success\":true"))
|
||||
{
|
||||
shop.Cookies = "empty=true;";
|
||||
foreach (var sc in campanys)
|
||||
{
|
||||
sc.LoginStatus = "未登录";
|
||||
shop.Cookies = "empty=true;";
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -548,6 +641,7 @@ namespace TemuKJD.KJDForms.AdminForms
|
||||
foreach (var sc in campanys)
|
||||
{
|
||||
sc.LoginStatus = "登录成功";
|
||||
sc.LastRefreshDate = DateTime.Now.ToString("yyyyMMdd");
|
||||
}
|
||||
}
|
||||
loginResult = ShopListForm.GetShopStatus2(shop);
|
||||
@@ -575,7 +669,7 @@ namespace TemuKJD.KJDForms.AdminForms
|
||||
{
|
||||
this.statusBar.lblTaskStatus.Text = "正在检测...";
|
||||
this.statusBar.pgbTaskProgress.Value = (i + 1);
|
||||
this.statusBar.pgbTaskProgress.Text = (i + 1) + "/" + shopNames.Length;
|
||||
this.statusBar.pgbTaskProgress.Text = (i + 1) + "/" + shopLoginNames.Length;
|
||||
}));
|
||||
}
|
||||
}
|
||||
File renamed without changes.
@@ -164,7 +164,7 @@ namespace TemuKJD.KJDForms.AdminForms
|
||||
{
|
||||
newShop.LoginStatus = "登录成功";
|
||||
newShop.LastRefreshDate = DateTime.Now.ToString("yyyyMMdd");
|
||||
var html = AdminShopForm.AdminAddServerShop(newShop); // 店铺写入到服务端
|
||||
var html = AdminShopListForm.AdminAddServerShop(newShop); // 店铺写入到服务端
|
||||
if (!html.Contains("\"code\":200"))
|
||||
isSuccess = false;
|
||||
}
|
||||
@@ -261,7 +261,7 @@ namespace TemuKJD.KJDForms.AdminForms
|
||||
{
|
||||
newShop.LoginStatus2 = "国际版在线";
|
||||
newShop.LastRefreshDate = DateTime.Now.ToString("yyyyMMdd");
|
||||
var html = AdminShopForm.AdminAddServerShop(newShop); // 店铺写入到服务端
|
||||
var html = AdminShopListForm.AdminAddServerShop(newShop); // 店铺写入到服务端
|
||||
if (!html.Contains("\"code\":200"))
|
||||
isSuccess = false;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace TemuKJD.KJDForms.AdminForms
|
||||
BaseMsgForm.ShowError("商品Id不存在!");
|
||||
return "failed";
|
||||
}
|
||||
var shop = AdminShopForm.lstAdminShopInfo.FirstOrDefault(s => s.ShopId == supplierId.ToString());
|
||||
var shop = AdminShopListForm.lstAdminShopInfo.FirstOrDefault(s => s.ShopId == supplierId.ToString());
|
||||
if (supplierId <= 0 || shop == null)
|
||||
{
|
||||
BaseMsgForm.ShowError("店铺不存在!");
|
||||
|
||||
Reference in new issue
Block a user