广告直通车功能 2修复活动勾选问题 3加入发货台功能完成20%

This commit is contained in:
wule committed 2025-11-07 19:38:57 +08:00
1 parent a6b36c64b0
commit e2b37df00b
35 files changed
+6832 -236

No files matched your search

+47 -32
View File
@@ -28,12 +28,14 @@
/// </summary>
private void InitializeComponent()
{
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
this.components = new System.ComponentModel.Container();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle();
this.label1 = new System.Windows.Forms.Label();
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel();
this.panel5 = new System.Windows.Forms.Panel();
this.chkLoginAds = new TemuKJD.UserComponent.UcCheckBox(this.components);
this.btnRefreshShop = new TemuKJD.UserControls.ButtonEx();
this.btnLoginSelect = new TemuKJD.UserControls.ButtonEx();
this.btnCheck = new TemuKJD.UserControls.ButtonEx();
@@ -139,14 +141,25 @@
//
// panel5
//
this.panel5.Controls.Add(this.chkLoginAds);
this.panel5.Controls.Add(this.btnRefreshShop);
this.panel5.Controls.Add(this.btnLoginSelect);
this.panel5.Controls.Add(this.btnCheck);
this.panel5.Location = new System.Drawing.Point(1032, 3);
this.panel5.Location = new System.Drawing.Point(901, 3);
this.panel5.Name = "panel5";
this.panel5.Size = new System.Drawing.Size(229, 40);
this.panel5.Size = new System.Drawing.Size(360, 40);
this.panel5.TabIndex = 1;
//
// chkLoginAds
//
this.chkLoginAds.AutoSize = true;
this.chkLoginAds.Location = new System.Drawing.Point(254, 11);
this.chkLoginAds.Name = "chkLoginAds";
this.chkLoginAds.Size = new System.Drawing.Size(111, 21);
this.chkLoginAds.TabIndex = 376;
this.chkLoginAds.Text = "同时登录直通车";
this.chkLoginAds.UseVisualStyleBackColor = true;
//
// btnRefreshShop
//
this.btnRefreshShop.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
@@ -154,7 +167,7 @@
this.btnRefreshShop.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnRefreshShop.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnRefreshShop.ForeColor = System.Drawing.Color.White;
this.btnRefreshShop.Location = new System.Drawing.Point(21, 9);
this.btnRefreshShop.Location = new System.Drawing.Point(43, 8);
this.btnRefreshShop.Margin = new System.Windows.Forms.Padding(2);
this.btnRefreshShop.Name = "btnRefreshShop";
this.btnRefreshShop.Size = new System.Drawing.Size(66, 26);
@@ -170,7 +183,7 @@
this.btnLoginSelect.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnLoginSelect.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnLoginSelect.ForeColor = System.Drawing.Color.White;
this.btnLoginSelect.Location = new System.Drawing.Point(162, 9);
this.btnLoginSelect.Location = new System.Drawing.Point(184, 8);
this.btnLoginSelect.Margin = new System.Windows.Forms.Padding(2);
this.btnLoginSelect.Name = "btnLoginSelect";
this.btnLoginSelect.Size = new System.Drawing.Size(66, 26);
@@ -186,7 +199,7 @@
this.btnCheck.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnCheck.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnCheck.ForeColor = System.Drawing.Color.White;
this.btnCheck.Location = new System.Drawing.Point(92, 9);
this.btnCheck.Location = new System.Drawing.Point(114, 8);
this.btnCheck.Margin = new System.Windows.Forms.Padding(2);
this.btnCheck.Name = "btnCheck";
this.btnCheck.Size = new System.Drawing.Size(66, 26);
@@ -210,13 +223,13 @@
this.panel4.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel4.Location = new System.Drawing.Point(3, 3);
this.panel4.Name = "panel4";
this.panel4.Size = new System.Drawing.Size(1023, 40);
this.panel4.Size = new System.Drawing.Size(892, 40);
this.panel4.TabIndex = 0;
//
// cmbNotes
//
this.cmbNotes.FormattingEnabled = true;
this.cmbNotes.Location = new System.Drawing.Point(597, 10);
this.cmbNotes.Location = new System.Drawing.Point(597, 9);
this.cmbNotes.Name = "cmbNotes";
this.cmbNotes.Size = new System.Drawing.Size(120, 25);
this.cmbNotes.TabIndex = 413;
@@ -227,7 +240,7 @@
this.pnlEmpty.CanvasColor = System.Drawing.SystemColors.Control;
this.pnlEmpty.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
this.pnlEmpty.DisabledBackColor = System.Drawing.Color.Empty;
this.pnlEmpty.Location = new System.Drawing.Point(799, 9);
this.pnlEmpty.Location = new System.Drawing.Point(799, 8);
this.pnlEmpty.Name = "pnlEmpty";
this.pnlEmpty.Size = new System.Drawing.Size(66, 26);
this.pnlEmpty.Style.Alignment = System.Drawing.StringAlignment.Center;
@@ -253,7 +266,7 @@
this.btnSearch.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnSearch.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnSearch.ForeColor = System.Drawing.Color.White;
this.btnSearch.Location = new System.Drawing.Point(728, 9);
this.btnSearch.Location = new System.Drawing.Point(728, 8);
this.btnSearch.Margin = new System.Windows.Forms.Padding(2);
this.btnSearch.Name = "btnSearch";
this.btnSearch.Size = new System.Drawing.Size(66, 26);
@@ -265,7 +278,7 @@
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(538, 14);
this.label4.Location = new System.Drawing.Point(538, 13);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(68, 17);
this.label4.TabIndex = 377;
@@ -273,7 +286,7 @@
//
// txtShopName
//
this.txtShopName.Location = new System.Drawing.Point(415, 11);
this.txtShopName.Location = new System.Drawing.Point(415, 10);
this.txtShopName.Name = "txtShopName";
this.txtShopName.Size = new System.Drawing.Size(110, 23);
this.txtShopName.TabIndex = 374;
@@ -281,7 +294,7 @@
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(367, 14);
this.label3.Location = new System.Drawing.Point(367, 13);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(56, 17);
this.label3.TabIndex = 375;
@@ -289,7 +302,7 @@
//
// txtShopId
//
this.txtShopId.Location = new System.Drawing.Point(245, 11);
this.txtShopId.Location = new System.Drawing.Point(245, 10);
this.txtShopId.Name = "txtShopId";
this.txtShopId.Size = new System.Drawing.Size(110, 23);
this.txtShopId.TabIndex = 372;
@@ -297,7 +310,7 @@
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(197, 14);
this.label2.Location = new System.Drawing.Point(197, 13);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(55, 17);
this.label2.TabIndex = 373;
@@ -310,7 +323,7 @@
this.btnImport.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnImport.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnImport.ForeColor = System.Drawing.Color.White;
this.btnImport.Location = new System.Drawing.Point(71, 9);
this.btnImport.Location = new System.Drawing.Point(71, 8);
this.btnImport.Margin = new System.Windows.Forms.Padding(2);
this.btnImport.Name = "btnImport";
this.btnImport.Size = new System.Drawing.Size(66, 26);
@@ -326,7 +339,7 @@
this.btnAddShop.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnAddShop.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnAddShop.ForeColor = System.Drawing.Color.White;
this.btnAddShop.Location = new System.Drawing.Point(1, 9);
this.btnAddShop.Location = new System.Drawing.Point(1, 8);
this.btnAddShop.Margin = new System.Windows.Forms.Padding(2);
this.btnAddShop.Name = "btnAddShop";
this.btnAddShop.Size = new System.Drawing.Size(66, 26);
@@ -356,7 +369,7 @@
this.splitContainer2.Panel2.Controls.Add(this.chkAutoDrag);
this.splitContainer2.Panel2.Controls.Add(this.statusBar);
this.splitContainer2.Size = new System.Drawing.Size(1264, 572);
this.splitContainer2.SplitterDistance = 540;
this.splitContainer2.SplitterDistance = 539;
this.splitContainer2.TabIndex = 0;
//
// btnRefreshAuth
@@ -380,7 +393,7 @@
//
this.pbLoading.Anchor = System.Windows.Forms.AnchorStyles.None;
this.pbLoading.Image = global::TemuKJD.Properties.Resources.loading_blue;
this.pbLoading.Location = new System.Drawing.Point(607, 245);
this.pbLoading.Location = new System.Drawing.Point(607, 244);
this.pbLoading.Name = "pbLoading";
this.pbLoading.Size = new System.Drawing.Size(50, 50);
this.pbLoading.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
@@ -391,19 +404,19 @@
//
this.dgvShop.AllowUserToAddRows = false;
this.dgvShop.AllowUserToDeleteRows = false;
dataGridViewCellStyle1.BackColor = System.Drawing.Color.WhiteSmoke;
this.dgvShop.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1;
dataGridViewCellStyle5.BackColor = System.Drawing.Color.WhiteSmoke;
this.dgvShop.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle5;
this.dgvShop.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
this.dgvShop.BackgroundColor = System.Drawing.Color.White;
this.dgvShop.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle2.BackColor = System.Drawing.SystemColors.Control;
dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
dataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.WindowText;
dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight;
dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
this.dgvShop.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle2;
dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle6.BackColor = System.Drawing.SystemColors.Control;
dataGridViewCellStyle6.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
dataGridViewCellStyle6.ForeColor = System.Drawing.SystemColors.WindowText;
dataGridViewCellStyle6.SelectionBackColor = System.Drawing.SystemColors.Highlight;
dataGridViewCellStyle6.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
dataGridViewCellStyle6.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
this.dgvShop.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle6;
this.dgvShop.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dgvShop.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.colSelect,
@@ -434,7 +447,7 @@
this.dgvShop.Name = "dgvShop";
this.dgvShop.ReadOnly = true;
this.dgvShop.RowTemplate.Height = 23;
this.dgvShop.Size = new System.Drawing.Size(1256, 540);
this.dgvShop.Size = new System.Drawing.Size(1256, 539);
this.dgvShop.TabIndex = 5;
this.dgvShop.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgvShop_CellContentClick);
//
@@ -644,7 +657,7 @@
this.statusBar.BackColor = System.Drawing.Color.White;
this.statusBar.Dock = System.Windows.Forms.DockStyle.Bottom;
this.statusBar.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.statusBar.Location = new System.Drawing.Point(0, -1);
this.statusBar.Location = new System.Drawing.Point(0, 0);
this.statusBar.Margin = new System.Windows.Forms.Padding(0);
this.statusBar.Name = "statusBar";
this.statusBar.Size = new System.Drawing.Size(1264, 29);
@@ -669,6 +682,7 @@
this.splitContainer1.ResumeLayout(false);
this.tableLayoutPanel2.ResumeLayout(false);
this.panel5.ResumeLayout(false);
this.panel5.PerformLayout();
this.panel4.ResumeLayout(false);
this.panel4.PerformLayout();
this.splitContainer2.Panel1.ResumeLayout(false);
@@ -732,5 +746,6 @@
private System.Windows.Forms.DataGridViewLinkColumn colEdit;
private System.Windows.Forms.DataGridViewLinkColumn colDelete;
private System.Windows.Forms.ComboBox cmbNotes;
private UserComponent.UcCheckBox chkLoginAds;
}
}
+138 -4
View File
@@ -22,6 +22,7 @@ using NaiBa.Util;
using System.Globalization;
using TemuKJD.KJDForms.AdminForms;
using TemuKJD.BLL;
using TemuKJD.UserControls;
namespace TemuKJD.KJDForms.ShopForms
{
@@ -209,7 +210,7 @@ namespace TemuKJD.KJDForms.ShopForms
#region 服务端店铺Cookie管理
/// <summary>
/// 添加京东店铺Cookies
/// 添加店铺Cookies
/// </summary>
/// <param name="shopName">店铺名称</param>
/// <param name="shopCookies">cookies</param>
@@ -234,6 +235,34 @@ namespace TemuKJD.KJDForms.ShopForms
BaseMsgForm.ShowError("服务端登录状态保存失败!请检查网络连接。");
}
}
/// <summary>
/// 添加店铺直通车Cookies
/// </summary>
/// <param name="shopCookies">cookies</param>
/// <param name="fromTool">工具名称(可不填写)</param>
public static void UpdateServerShopAdsCookies(ShopLoginInfo shop, string fromTool = null)
{
var fTool = string.IsNullOrEmpty(fromTool) ? "" : "&from_tool=" + fromTool;
var url = BaseClass.BuildObjString("shop/mdy_shop_ads_cookie_and_login_status");
var data = UserLogin.GetSignaturex()
//+ "&login_name=" + shop.LoginName
//直通车相同账户的不同店铺之间是隔离的,所以只能填店铺id更新一个店铺
+ "&shop_id=" + shop.ShopId
+ "&ad_url=" + GetHtml.UrlEncodeUtf8(shop.ad_url)
+ "&ad_seller_unique_id=" + shop.ad_seller_unique_id
+ "&ad_login_status=" + shop.ad_login_status
+ "&ad_cookie=" + shop.ad_cookie.Replace("&", "&").Replace("%", "%").Replace("+", "+").Replace("\"", """)
+ fTool;
var result = GetHtml.PostUtf8(url, data);
if (!result.Contains("\"code\":200"))
result = GetHtml.PostUtf8(url, data);
if (!result.Contains("\"code\":200"))
{
BaseMsgForm.ShowError("直通车登录状态保存失败!请检查网络连接。");
}
}
///// <summary>
///// 获取店铺Cookies
///// </summary>
@@ -563,7 +592,7 @@ namespace TemuKJD.KJDForms.ShopForms
{
this.Invoke(new Action(() =>
{
this.pbLoading.Visible = true;
this.pbLoading.Visible = false;
this.statusBar.lblTaskStatus.Text = "检测完毕";
}));
}
@@ -571,7 +600,6 @@ namespace TemuKJD.KJDForms.ShopForms
public void CheckShopLogin(string[] shopNames, bool isShowProgress = true)
{
for (int i = 0; i < shopNames.Length; i++)
{
var campanys = GlobalConfig.ShopLoginList.Where(v => v.LoginName == shopNames[i]).ToList();
@@ -601,7 +629,7 @@ namespace TemuKJD.KJDForms.ShopForms
foreach (var sc in campanys)
{
sc.LoginStatus = "未登录";
shop.Cookies = "empty=true;";
sc.Cookies = "empty=true;";
}
}
else
@@ -609,6 +637,7 @@ namespace TemuKJD.KJDForms.ShopForms
foreach(var sc in campanys)
{
sc.LoginStatus = "登录成功";
sc.Cookies = shop.Cookies;
sc.LastRefreshDate = DateTime.Now.ToString("yyyyMMdd");
}
}
@@ -627,6 +656,7 @@ namespace TemuKJD.KJDForms.ShopForms
foreach (var sc in campanys)
{
sc.LoginStatus2 = "国际版在线";
sc.Cookies2 = shop.Cookies2;
sc.LastRefreshDate = DateTime.Now.ToString("yyyyMMdd");
}
}
@@ -647,6 +677,95 @@ namespace TemuKJD.KJDForms.ShopForms
}
}
public void CheckShopAdsLogin(ShopLoginInfo shop)
{
if (shop == null)
return;
CheckShopAdsLogin(new List<string> { shop.ShopId });
}
public void CheckShopAdsLogin(List<string> shopIdLst, PictureBox _pbLoading = null, StatusBarUserControl _statusBar = null)
{
if (_pbLoading != null)
{
MainForm.instance.Invoke(new Action(() =>
{
_pbLoading.Visible = true;
}));
}
if (_statusBar != null)
{
MainForm.instance.Invoke(new Action(() =>
{
_statusBar.lblTaskStatus.Text = "正在检测...";
_statusBar.pgbTaskProgress.Value = 0;
_statusBar.pgbTaskProgress.Maximum = shopIdLst.Count;
_statusBar.pgbTaskProgress.Text = "0" + "/" + shopIdLst.Count;
}));
}
Task.Run(() =>
{
for (int i = 0; i < shopIdLst.Count; i++)
{
var shopId = shopIdLst[i];
var shop = GlobalConfig.ShopLoginList.FirstOrDefault(v => v.ShopId == shopId);
// 先从服务端取最新直通车cookie
var serverCampanys = ShopBLL.AdminGetServerShopLstByIds(new List<string>() { shop.ShopId });
var serverShop = serverCampanys.FirstOrDefault();
if (shop != null && serverShop != null)
{
shop.ad_cookie = serverShop.ad_cookie;
}
if (shop != null)
{
var loginResult = getSellerCenter(shop);
if (!loginResult.Contains("\"success\":true"))
{
shop.ad_cookie = "empty=true;";
shop.ad_login_status = "离线";
}
else
{
shop.ad_login_status = "在线";
shop.ad_cookie = serverShop.ad_cookie;
}
StartUp.SaveLocalShopLoginInfo();
ShopListForm.UpdateServerShopAdsCookies(shop); // 店铺cookie写入服务端
}
if (_statusBar != null)
{
MainForm.instance.Invoke(new Action(() =>
{
_statusBar.lblTaskStatus.Text = "正在检测...";
_statusBar.pgbTaskProgress.Value = (i + 1);
_statusBar.pgbTaskProgress.Text = (i + 1) + "/" + shopIdLst.Count;
}));
}
}
if (_pbLoading != null)
{
MainForm.instance.Invoke(new Action(() =>
{
_pbLoading.Visible = false;
}));
}
if (_statusBar != null)
{
MainForm.instance.Invoke(new Action(() =>
{
_statusBar.lblTaskStatus.Text = "检测完毕";
}));
}
});
}
public static string GetShopStatus(ShopLoginInfo shop)
{
string url = "https://seller.kuajingmaihuo.com/bg/quiet/api/mms/userInfo";
@@ -684,6 +803,20 @@ namespace TemuKJD.KJDForms.ShopForms
return HttpResponseBLL.PostResponse2(shop, url, body, refere);
}
/// <summary>
/// 获取直通车登录状态
/// </summary>
/// <param name="shop"></param>
/// <returns></returns>
public static string getSellerCenter(ShopLoginInfo shop)
{
string url = "https://ads.temu.com/api/v1/coconut/account/get_seller_center";
string body = "{}";
string refere = shop.ad_url;
return HttpResponseBLL.PostResponseAds(shop, url, body, refere);
}
private void ShopListForm_VisibleChanged(object sender, EventArgs e)
{
if (this.Visible == true)
@@ -846,6 +979,7 @@ namespace TemuKJD.KJDForms.ShopForms
{
ShopLoginForm shopLoginForm = new ShopLoginForm(shop);
shopLoginForm.openType = EnumOpenType.login;
shopLoginForm.IsAdsLogin = this.chkLoginAds.Checked;
shopLoginForm.SaveComplete += shopLoginForm_SaveComplete;
shopLoginForm.ShowDialog();
btnRefreshCookie_Click(null, null);
+2 -1
View File
@@ -83,7 +83,7 @@
this.splitContainer1.Panel2.Controls.Add(this.btnReload);
this.splitContainer1.Panel2.Controls.Add(this.chkCloseAfterLogin);
this.splitContainer1.Size = new System.Drawing.Size(1438, 736);
this.splitContainer1.SplitterDistance = 674;
this.splitContainer1.SplitterDistance = 675;
this.splitContainer1.SplitterWidth = 3;
this.splitContainer1.TabIndex = 4;
//
@@ -345,6 +345,7 @@
this.txtAddress.Name = "txtAddress";
this.txtAddress.Size = new System.Drawing.Size(1432, 23);
this.txtAddress.TabIndex = 7;
this.txtAddress.TextChanged += new System.EventHandler(this.txtAddress_TextChanged);
this.txtAddress.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtAddress_KeyDown);
//
// ShopLoginForm
+136
View File
@@ -33,18 +33,24 @@ namespace TemuKJD.KJDForms.ShopForms
{
login,
manage,
ads, // 广告登录
}
public partial class ShopLoginForm : LRBaseForm
{
public static ShopLoginForm shopLoginInstance { get; set; } = null;
public int CloseAfterSecond { get; set; }
/// <summary>
/// 推广直通车登录
/// </summary>
public bool IsAdsLogin { get; set; } = false;
public EnumOpenType openType = EnumOpenType.manage;
public bool isMultiLogin = false;
public string MultiLoginCookieName = "";
public string InitUrl = "";
private string shopCookieHead = "kuajingmaihuo.com";
private string shopCookieHead2 = "temu.com";
private string shopCookieHead3 = "ads.temu.com";
private string shopLoginUrl = "http://seller.kuajingmaihuo.com/login";
private string shopMainUrl = "https://seller.kuajingmaihuo.com";
private string shopMainUrl2 = "https://agentseller.temu.com";
@@ -222,10 +228,29 @@ namespace TemuKJD.KJDForms.ShopForms
else
{
var cookie2 = shop.Cookies2;
//var cookie2Lst = cookie2.Split(new string[] { ";", " " }, StringSplitOptions.RemoveEmptyEntries);
//cookie2 = "";
//foreach (var item in cookie2Lst)
//{
// if (item.StartsWith("mallid="))
// cookie2 += "mallid=" + shop.ShopId + ";";
// else
// cookie2 += item + ";";
//}
var t = CEFBrowser.SetCookieAsync(shopCookieHead2, cookie2, cefWebBrowser.GetCookieManager(null));
t.Wait(5000);
cefWebBrowser.Load("https://agentseller.temu.com");
}
Thread.Sleep(500);
if (!string.IsNullOrEmpty(shop.ShopId))
{
var storageJsCode = "window.localStorage.setItem('" + "mall-info-id" + "', '" + shop.ShopId + "');\r\n";
storageJsCode += "window.localStorage.setItem('" + "agentseller-mall-info-id" + "', '" + shop.ShopId + "');\r\n";
while (!cefWebBrowser.IsBrowserInitialized || !cefWebBrowser.GetBrowser().MainFrame.IsValid || cefWebBrowser.IsLoading)
Thread.Sleep(20);
cefWebBrowser.GetBrowser().MainFrame.ExecuteJavaScriptAsync(storageJsCode);
}
}
@@ -299,14 +324,106 @@ namespace TemuKJD.KJDForms.ShopForms
}
StartUp.SaveLocalShopLoginInfo(); // 店铺保存到本地
ShopListForm.UpdateServerShopCookies(shop); // 店铺cookie写入服务端,多店共用一个登录账号一组cookie
if (!IsAdsLogin)
{
OnSaveComplete(shop);
if (this.Created && this.chkCloseAfterLogin.Checked)
Invoke(new Action(() => { this.Close(); }));
else
break;
}
}
if (IsAdsLogin && !string.IsNullOrEmpty(shop.ad_seller_unique_id) && 1==2)
{
var obtainCodeRst = ShopListForm.GetObtainCode(shop);
var obtainCode = BaseRegex.GetStringJson(ref obtainCodeRst, "code");
//https://ads.temu.com/login.html?
//redirectUrl=https%3A%2F%2Fads.temu.com%2Findex.html%3FadAreaOverride%3D2&userType=1&mallType=0
//&ticket=Zjze2NHyZFaGP88ROyjN19a47ae59611391a296ae6403bbbfa39e9046ceba744aafe8227fd6
//&adSellerUniqueId=eyJ1IjoiTVF3NFRGVmN2ZUVyZG1USDdOQ2o5dz09IiwidiI6MX0%3D&source=2&seller_source=11&adAreaOverride=2
string url = "https://ads.temu.com/login.html?" +
"redirectUrl=https%3A%2F%2Fads.temu.com%2Findex.html%3FadAreaOverride%3D2&userType=1&mallType=0&ticket=" + obtainCode +
"&adSellerUniqueId=" + shop.ad_seller_unique_id + "&source=2&seller_source=11&adAreaOverride=2";
cefWebBrowser.Load(url);
}
else if (IsAdsLogin)
{
cefWebBrowser.GetBrowser().MainFrame.EvaluateScriptAsync(sGetElementWithText);
//点击商品推广按钮
var adsJsStr = "window.scrollTo(0, document.body.scrollHeight);";
var adsResponse = cefWebBrowser.GetBrowser().MainFrame.EvaluateScriptAsync(adsJsStr);
adsResponse.Wait(1000);
Thread.Sleep(Randomx.GetId(500, 1000));
adsJsStr = "var clickItem = getElementWithText('商品推广'); " +
"clickItem.click()";
adsResponse = cefWebBrowser.GetBrowser().MainFrame.EvaluateScriptAsync(adsJsStr);
adsResponse.Wait(1000);
Thread.Sleep(Randomx.GetId(500, 1000));
// 模拟人为点击一次,否则窗口不跳转
var host = cefWebBrowser.GetBrowser().GetHost();
int x = Randomx.GetId(50, 200);
int y = Randomx.GetId(1, 10);
// 按下鼠标左键
host.SendMouseClickEvent(x, y, MouseButtonType.Left, false, 1, CefEventFlags.None);
Thread.Sleep(50 + Randomx.GetId(200));
host.SendMouseClickEvent(x, y, MouseButtonType.Left, true, 1, CefEventFlags.None);
Thread.Sleep(Randomx.GetId(100, 500));
//点击确认授权并前往按钮
adsJsStr = "var clickItem = getElementWithText('确认授权并前往'); " +
"clickItem.parentElement.click();";
adsResponse = cefWebBrowser.GetBrowser().MainFrame.EvaluateScriptAsync(adsJsStr);
adsResponse.Wait(1000);
Thread.Sleep(Randomx.GetId(300, 800));
}
}
if (1 == 1 && this.shop != null && currentUrl.StartsWith("https://ads.temu.com/index.html?adAreaOverride="))
{
if (!cefWebBrowser.GetBrowser().MainFrame.IsValid)
continue;
if (openType != EnumOpenType.login)
continue;
if (!lstShopCompany.Any(c => c.AccountId == shop.ShopId))
continue;
shop.ad_url = txtAddress.Text;
string cookiesAds = "";
List<Cookie> cookieAdsList = CEFBrowser.GetCookieList("ads.temu.com", cefWebBrowser.GetCookieManager(null));
if (cookieAdsList != null && cookieAdsList.Count > 0)
{
for (int i = 0; i < cookieAdsList.Count; i++)
{
var cookie = cookieAdsList[i];
cookiesAds += cookie.Name + "=" + cookie.Value + "; ";
}
cookiesAds = cookiesAds.Trim().TrimEnd(';');
}
if (!string.IsNullOrEmpty(cookiesAds))
{
shop.ad_login_status = "在线";
shop.ad_cookie = cookiesAds;
StartUp.SaveLocalShopLoginInfo(); // 店铺保存到本地
ShopListForm.UpdateServerShopAdsCookies(shop); // 店铺cookie写入服务端,多店共用一个登录账号一组cookie
OnSaveComplete(shop);
if (this.Created && this.chkCloseAfterLogin.Checked)
{
Invoke(new Action(() => { this.Close(); }));
}
else
{
break;
}
}
}
}
});
@@ -443,6 +560,14 @@ namespace TemuKJD.KJDForms.ShopForms
t2.Wait(5000);
}
if (this.openType == EnumOpenType.ads)
{
var cookieAds = shop.ad_cookie;
var t2 = CEFBrowser.SetCookieAsync(shopCookieHead3, cookieAds, cefWebBrowser.GetCookieManager(null));
t2.Wait(5000);
cefWebBrowser.Load(InitUrl);
}
//根据登录的具体店铺设置local storage
if (!string.IsNullOrEmpty(shop.ShopId))
{
@@ -510,11 +635,13 @@ namespace TemuKJD.KJDForms.ShopForms
private void CefWebBrowser_AddressChanged(object sender, CefSharp.AddressChangedEventArgs e)
{
if (this.Created)
{
Invoke(new Action(() =>
{
currentUrl = e.Address;
txtAddress.Text = e.Address;
}));
}
}
private void CefWebBrowser_FrameLoadEnd(object sender, CefSharp.FrameLoadEndEventArgs e)
@@ -1102,5 +1229,14 @@ function getElementWithText(sText)
ReturnPackageDetailForm form = new ReturnPackageDetailForm(this.shop);
form.ShowDialog();
}
private void txtAddress_TextChanged(object sender, EventArgs e)
{
if (txtAddress.Text.Contains("&adSellerUniqueId="))
{
string address = txtAddress.Text.Trim();
shop.ad_seller_unique_id = BaseRegex.GetStringQuery(ref address, "adSellerUniqueId");
}
}
}
}
@@ -627,13 +627,14 @@ namespace TemuKJD.KJDForms.ShopForms.Statistics
}
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
//kjd库,获取商品进货价
var purchasePriceList = GetPurchasePrice(subOrderInfoLstTmp.Select(o => o.productId.ParseToString()).ToList());
foreach (var pPrice in purchasePriceList)
{
pPrice.dbSkuPurchasePriceList = JsonHelper.DeserializeJsonToList<TemuDBSkuPurchasePriceInfo>(pPrice.sku_purchase_price_json);
if (pPrice.dbSkuPurchasePriceList == null)
pPrice.dbSkuPurchasePriceList = new List<TemuDBSkuPurchasePriceInfo>();
}
//foreach (var pPrice in purchasePriceList)
//{
// pPrice.dbSkuPurchasePriceList = JsonHelper.DeserializeJsonToList<TemuDBSkuPurchasePriceInfo>(pPrice.sku_purchase_price_json);
// if (pPrice.dbSkuPurchasePriceList == null)
// pPrice.dbSkuPurchasePriceList = new List<TemuDBSkuPurchasePriceInfo>();
//}
foreach (var purchasePrice in purchasePriceList)
{
var order = subOrderInfoLstTmp.FirstOrDefault(o => o.productId.ParseToString() == purchasePrice.spu_id);
@@ -874,7 +875,19 @@ namespace TemuKJD.KJDForms.ShopForms.Statistics
if (jArr.Count() == 0)
return list;
return JsonHelper.DeserializeJsonToList<TemuDBProductPurchasePriceInfo>(jArr.ToString());
list = JsonHelper.DeserializeJsonToList<TemuDBProductPurchasePriceInfo>(jArr.ToString());
foreach (var pPrice in list)
{
pPrice.dbSkuPurchasePriceList = JsonHelper.DeserializeJsonToList<TemuDBSkuPurchasePriceInfo>(pPrice.sku_purchase_price_json);
if (pPrice.dbSkuPurchasePriceList == null)
pPrice.dbSkuPurchasePriceList = new List<TemuDBSkuPurchasePriceInfo>();
else
{
pPrice.price_text = "¥" + (pPrice.dbSkuPurchasePriceList.Min(s => s.purchasePriceValue) * 0.01).ParseToDecimal().ToString("0.00") + "~"
+ "¥" + (pPrice.dbSkuPurchasePriceList.Max(s => s.purchasePriceValue) * 0.01).ParseToDecimal().ToString("0.00");
}
}
return list;
}
private void btnSetColumn_Click(object sender, EventArgs e)