优化web查询 新增学员数据 尝试64位软件

This commit is contained in:
wule committed 2026-07-01 20:24:18 +08:00
1 parent 30beb00fc4
commit caba307ed1
44 files changed
+738 -1769

No files matched your search

@@ -49,16 +49,8 @@
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.label8 = new System.Windows.Forms.Label();
this.txtNotes = new DevComponents.DotNetBar.Controls.TextBoxX();
this.pnlSkuOption = new System.Windows.Forms.Panel();
this.label9 = new System.Windows.Forms.Label();
this.btnBookImg = new DevComponents.DotNetBar.PanelEx();
this.pictureBox2 = new System.Windows.Forms.PictureBox();
this.buttonEx1 = new TemuKJD.UserControls.ButtonEx();
this.btnSelect = new TemuKJD.UserControls.ButtonEx();
this.panel2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.pnlSkuOption.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit();
this.SuspendLayout();
//
// panel2
@@ -83,7 +75,6 @@
this.panel2.Controls.Add(this.pictureBox1);
this.panel2.Controls.Add(this.label8);
this.panel2.Controls.Add(this.txtNotes);
this.panel2.Controls.Add(this.pnlSkuOption);
this.panel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel2.Location = new System.Drawing.Point(1, 33);
this.panel2.Name = "panel2";
@@ -137,7 +128,7 @@
this.txtFissionWords.Multiline = true;
this.txtFissionWords.Name = "txtFissionWords";
this.txtFissionWords.ScrollBars = System.Windows.Forms.ScrollBars.Both;
this.txtFissionWords.Size = new System.Drawing.Size(337, 93);
this.txtFissionWords.Size = new System.Drawing.Size(337, 211);
this.txtFissionWords.TabIndex = 402;
this.txtFissionWords.WatermarkText = "一行一个";
//
@@ -315,95 +306,6 @@
this.txtNotes.Size = new System.Drawing.Size(337, 47);
this.txtNotes.TabIndex = 385;
//
// pnlSkuOption
//
this.pnlSkuOption.Controls.Add(this.label9);
this.pnlSkuOption.Controls.Add(this.btnBookImg);
this.pnlSkuOption.Controls.Add(this.pictureBox2);
this.pnlSkuOption.Controls.Add(this.buttonEx1);
this.pnlSkuOption.Controls.Add(this.btnSelect);
this.pnlSkuOption.Location = new System.Drawing.Point(10, 483);
this.pnlSkuOption.Name = "pnlSkuOption";
this.pnlSkuOption.Size = new System.Drawing.Size(417, 147);
this.pnlSkuOption.TabIndex = 661;
//
// label9
//
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(8, 10);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(68, 17);
this.label9.TabIndex = 404;
this.label9.Text = "SKU替换图";
//
// btnBookImg
//
this.btnBookImg.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
this.btnBookImg.Cursor = System.Windows.Forms.Cursors.Hand;
this.btnBookImg.DisabledBackColor = System.Drawing.Color.Empty;
this.btnBookImg.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnBookImg.Location = new System.Drawing.Point(332, 5);
this.btnBookImg.Name = "btnBookImg";
this.btnBookImg.Size = new System.Drawing.Size(85, 26);
this.btnBookImg.Style.Alignment = System.Drawing.StringAlignment.Center;
this.btnBookImg.Style.BackColor1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
this.btnBookImg.Style.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
this.btnBookImg.Style.BorderColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBorder;
this.btnBookImg.Style.BorderDashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
this.btnBookImg.Style.BorderSide = DevComponents.DotNetBar.eBorderSide.None;
this.btnBookImg.Style.ForeColor.Color = System.Drawing.Color.White;
this.btnBookImg.Style.GradientAngle = 90;
this.btnBookImg.StyleMouseOver.Alignment = System.Drawing.StringAlignment.Center;
this.btnBookImg.StyleMouseOver.BackColor1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(25)))), ((int)(((byte)(102)))), ((int)(((byte)(255)))));
this.btnBookImg.StyleMouseOver.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(25)))), ((int)(((byte)(102)))), ((int)(((byte)(255)))));
this.btnBookImg.TabIndex = 654;
this.btnBookImg.Text = "生成书籍图片";
this.btnBookImg.Visible = false;
this.btnBookImg.Click += new System.EventHandler(this.btnBookImg_Click);
//
// pictureBox2
//
this.pictureBox2.Location = new System.Drawing.Point(154, 5);
this.pictureBox2.Name = "pictureBox2";
this.pictureBox2.Size = new System.Drawing.Size(136, 136);
this.pictureBox2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox2.TabIndex = 405;
this.pictureBox2.TabStop = false;
this.pictureBox2.Click += new System.EventHandler(this.pictureBox2_Click);
//
// buttonEx1
//
this.buttonEx1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
this.buttonEx1.Cursor = System.Windows.Forms.Cursors.Hand;
this.buttonEx1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.buttonEx1.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.buttonEx1.ForeColor = System.Drawing.Color.White;
this.buttonEx1.Location = new System.Drawing.Point(79, 114);
this.buttonEx1.Margin = new System.Windows.Forms.Padding(2);
this.buttonEx1.Name = "buttonEx1";
this.buttonEx1.Size = new System.Drawing.Size(70, 26);
this.buttonEx1.TabIndex = 406;
this.buttonEx1.Text = "上传图片";
this.buttonEx1.UseVisualStyleBackColor = false;
this.buttonEx1.Visible = false;
this.buttonEx1.Click += new System.EventHandler(this.buttonEx1_Click);
//
// btnSelect
//
this.btnSelect.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
this.btnSelect.Cursor = System.Windows.Forms.Cursors.Hand;
this.btnSelect.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnSelect.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnSelect.ForeColor = System.Drawing.Color.White;
this.btnSelect.Location = new System.Drawing.Point(79, 5);
this.btnSelect.Margin = new System.Windows.Forms.Padding(2);
this.btnSelect.Name = "btnSelect";
this.btnSelect.Size = new System.Drawing.Size(70, 26);
this.btnSelect.TabIndex = 407;
this.btnSelect.Text = "选择图片";
this.btnSelect.UseVisualStyleBackColor = false;
this.btnSelect.Click += new System.EventHandler(this.btnSelect_Click);
//
// PDDDBProdEditForm
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
@@ -419,9 +321,6 @@
this.panel2.ResumeLayout(false);
this.panel2.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.pnlSkuOption.ResumeLayout(false);
this.pnlSkuOption.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit();
this.ResumeLayout(false);
}
@@ -444,13 +343,7 @@
private System.Windows.Forms.Label label6;
private System.Windows.Forms.TextBox txtHeadWords;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.PictureBox pictureBox2;
private System.Windows.Forms.Label label9;
private UserControls.ButtonEx buttonEx1;
private UserControls.ButtonEx btnSelect;
private DevComponents.DotNetBar.PanelEx btnEditDetail;
private DevComponents.DotNetBar.PanelEx btnBookImg;
public System.Windows.Forms.Panel pnlSkuOption;
public System.Windows.Forms.TextBox txtExtCode;
public System.Windows.Forms.TextBox txtProductName;
public System.Windows.Forms.Label lblSkcId;
@@ -53,16 +53,6 @@ namespace TemuKJD.PDDForms.ProductSelectForms
if (prodTmp != null)
dbProd = prodTmp;
}
//var prodTmp = GetProductDetail(dbProd.id.ToString());
//dbProd.sku_img_replace_base64 = prodTmp.sku_img_replace_base64;
//dbProd.sku_img_replace_url = prodTmp.sku_img_replace_url;
if (!string.IsNullOrWhiteSpace(dbProd.sku_img_replace_url))
this.pictureBox2.ImageLocation = dbProd.sku_img_replace_url;
else if (!string.IsNullOrWhiteSpace(dbProd.sku_img_replace_base64))
this.pictureBox2.Image = Base64ChangeImgUrl.Base64ToImage(dbProd.sku_img_replace_base64); // Convert.FromBase64String(dbProd.sku_img_replace_base64);
//if (dbProd.product_get_type_text == "厂商直采" || dbProd.product_get_type_text == "微信店采")
//btnEditDetail.Text = "查看商品SKU";
}
}
@@ -153,100 +143,6 @@ namespace TemuKJD.PDDForms.ProductSelectForms
}
}
private void buttonEx1_Click(object sender, EventArgs e)
{
string text = "";
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Multiselect = false;
// 设置过滤条件,只显示文本文件
openFileDialog.Filter = "图片文件 (*.jpeg;*.jpg;*.png)|*.jpeg;*.jpg;*.png|All files (*.*)|*.*";
// 显示对话框并获取结果
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
try
{
string filePath = openFileDialog.FileName;
//using (Image image = Image.FromFile(filePath))
//{
// // 现在你可以使用image对象进行各种操作,比如绘制、保存等
// //Console.WriteLine("Image loaded successfully.");
// this.pictureBox2.Image = image;
//}
Image image = Image.FromFile(filePath);
this.pictureBox2.Image = image;
string imgBase64 = "";
using (MemoryStream memoryStream = new MemoryStream())
{
image.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Jpeg);
byte[] imageBytes = memoryStream.ToArray();
imgBase64 = Convert.ToBase64String(imageBytes);
}
string img_md5 = BaseClass.GetMd5(imgBase64);
var url = BaseClass.BuildPDDObjString("product/add_sku_img_replace");
var data = UserLogin.GetSignaturex() +
"&product_db_id=" + dbProd.id;
data += "&img_base64=" + imgBase64;
data += "&img_md5=" + img_md5;
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("\"code\":200"))
{
BaseMsgForm.ShowError("商品图片编辑失败,请重试!" + BaseRegex.GetStringJson(ref html, "msg"));
}
else
{
dbProd.sku_img_replace_base64 = imgBase64;
dbProd.sku_img_replace_id = BaseRegex.GetIntJson(ref html, "sku_img_replace_id");
}
}
catch (Exception ex)
{
//Console.WriteLine("An error occurred: " + ex.Message);
BaseMsgForm.ShowError("打开自定义图片失败 " + ex.Message);
return;
}
}
}
private void pictureBox2_Click(object sender, EventArgs e)
{
ShowImgForm imgFrom = new ShowImgForm(pictureBox2.Image);
imgFrom.ShowDialog();
}
private void btnSelect_Click(object sender, EventArgs e)
{
PDDDBProdImgListForm imgListForm = new PDDDBProdImgListForm("select");
imgListForm.ShowDialog();
if (imgListForm.SelectDbImgId > 0)
{
var url = BaseClass.BuildPDDObjString("product/mdy_prod_sku_img_replace_id");
var data = UserLogin.GetSignaturex() +
"&product_db_id=" + dbProd.id;
data += "&img_db_id=" + imgListForm.SelectDbImgId;
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("\"code\":200"))
{
BaseMsgForm.ShowError("商品图片编辑失败,请重试!" + BaseRegex.GetStringJson(ref html, "msg"));
}
else
{
this.pictureBox2.ImageLocation = imgListForm.SelectDbImgUrl;
dbProd.sku_img_replace_id = imgListForm.SelectDbImgId;
dbProd.sku_img_replace_url = imgListForm.SelectDbImgUrl;
}
}
}
private void btnEditDetail_Click(object sender, EventArgs e)
{
bool canEdit = true;
@@ -322,65 +218,5 @@ namespace TemuKJD.PDDForms.ProductSelectForms
}
editDetailForm.ShowDialog();
}
private void btnBookImg_Click(object sender, EventArgs e)
{
var prodJson = this.dbProd.product_json;
var prodInfo = JsonHelper.DeserializeJsonToObject<AllBase.Model.Result.PDDResult.PDDProductInfo>(prodJson);
if (prodInfo != null)
{
string publisher = "出版社:" + new List<string> () { "技术出版社", "文化出版社", "美术出版社" }[Randomx.GetId(3)];
string isbn = "ISBN:";
string bookName = "书名:";
string bookPrice = "定价:" + prodInfo.detail.sku.Max(s => s.multi_price) * 0.01;
string author = "作者:王老师";
string publishTime = "出版时间:" + DateTime.Now.AddMonths(-3);
string edition = "版次:1";
string binding = "装帧:平装";
foreach (var propInfo in prodInfo.property.goods_properties)
{
if (propInfo.name.Contains("出版社名称"))
publisher = "出版社:" + propInfo.values.FirstOrDefault()?.value;
else if (propInfo.name.Contains("ISBN"))
isbn = "ISBN:" + propInfo.values.FirstOrDefault()?.value;
else if (propInfo.name.Contains("书名"))
bookName = "书名:" + propInfo.values.FirstOrDefault()?.value;
else if (propInfo.name.Contains("定价"))
bookPrice = "定价:" + propInfo.values.FirstOrDefault()?.value;
else if (propInfo.name.Contains("作者"))
author = "作者:" + propInfo.values.FirstOrDefault()?.value;
else if (propInfo.name.Contains("出版时间"))
publishTime = "出版时间:" + propInfo.values.FirstOrDefault()?.value;
else if (propInfo.name.Contains("版次"))
edition = "版次:" + propInfo.values.FirstOrDefault()?.value;
else if (propInfo.name.Contains("装帧"))
binding = "装帧:" + propInfo.values.FirstOrDefault()?.value;
}
var bookStr = publisher + "\r\n" + "\r\n" +
isbn + "\r\n" + "\r\n" +
bookName + "\r\n" + "\r\n" +
bookPrice + "\r\n" + "\r\n" +
author + "\r\n" + "\r\n" +
publishTime + "\r\n" + "\r\n" +
edition + "\r\n" + "\r\n" +
binding;
var imageBg = new Bitmap(800, 800);
using (Graphics g = Graphics.FromImage(imageBg))
{
g.Clear(Color.White);
//Font font = new Font("宋体", 15, FontStyle.Bold);
Font font = new Font("微软雅黑", 15, FontStyle.Regular);
Brush textBrush = Brushes.Black;
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
RectangleF rectF = new RectangleF(80, 80, 800 - 80, 800 - 80);
g.DrawString(bookStr, font, textBrush, rectF);
}
ShowImgForm imgFrom = new ShowImgForm(imageBg);
imgFrom.ShowDialog();
}
}
}
}
@@ -414,7 +414,6 @@ namespace TemuKJD.PDDForms.ProductSelectForms
if (!string.IsNullOrEmpty(cmbExportToOutServer.Text))
{
//data += "&has_send_to_out_server=" + (cmbExportToOutServer.Text.Trim() == "是").ParseToString().ToLower();
if (cmbExportToOutServer.Text.Trim() == "是")
data += "&send_to_out_server=1";
else if (cmbExportToOutServer.Text.Trim() == "否")
@@ -422,6 +421,10 @@ namespace TemuKJD.PDDForms.ProductSelectForms
else if (cmbExportToOutServer.Text.Trim() == "导出未拉回")
data += "&send_to_out_server=2";
}
else
{
data += "&send_to_out_server=0,1,2";
}
if (cmbSourceType.Text.Trim() != "全部")
{
@@ -627,7 +630,6 @@ namespace TemuKJD.PDDForms.ProductSelectForms
PDDDBProdEditForm editForm = new PDDDBProdEditForm(dbProduct);
if (BaseClass.MainPath != "29pdd")
{
editForm.pnlSkuOption.Visible = false;
editForm.txtProductName.ReadOnly = true;
editForm.txtExtCode.ReadOnly = true;
editForm.lblSkcId.Text = "仓库编码";
@@ -1317,19 +1319,37 @@ namespace TemuKJD.PDDForms.ProductSelectForms
void GetProdWxCat(List<KJDDBProduct> dbProdLst)
{
var taskCount = Math.Min(5, GlobalConfig.ShopLoginList.Count);
List<Task> tList = new List<Task>();
foreach (var prod in dbProdLst)
{
if (cancellationTokenSource.IsCancellationRequested)
break;
Invoke(new Action(() =>
var t = Task.Run(() =>
{
this.statusBar.UpdateProgressBar(this.statusBar.pgbTaskProgress.Value + 1);
this.statusBar.lblTaskStatus.Text = "正在识别微信类目 " + this.statusBar.pgbTaskProgress.Value + "/" + dbProdLst.Count;
}));
if (cancellationTokenSource.IsCancellationRequested)
return;
var row = dgvDbProduct.Rows.Cast<DataGridViewRow>().FirstOrDefault(r => r.Cells["col_spu_id"].Value.ParseToString() == prod.spu_id);
GetProdWxCat(prod, row);
Invoke(new Action(() =>
{
this.statusBar.UpdateProgressBar(this.statusBar.pgbTaskProgress.Value + 1);
this.statusBar.lblTaskStatus.Text = "正在识别微信类目 " + this.statusBar.pgbTaskProgress.Value + "/" + dbProdLst.Count;
}));
var row = dgvDbProduct.Rows.Cast<DataGridViewRow>().FirstOrDefault(r => r.Cells["col_spu_id"].Value.ParseToString() == prod.spu_id);
GetProdWxCat(prod, row);
});
tList.Add(t);
while (tList.Count >= taskCount)
{
Thread.Sleep(50);
tList.RemoveAll(ta => ta.IsFaulted || ta.IsCanceled || ta.IsCompleted);
}
}
while (tList.Count > 0)
{
Thread.Sleep(200);
tList.RemoveAll(ta => ta.IsFaulted || ta.IsCanceled || ta.IsCompleted);
}
}
@@ -1337,27 +1357,41 @@ namespace TemuKJD.PDDForms.ProductSelectForms
{
var shop = GlobalConfig.ShopLoginList.OrderBy(x => Guid.NewGuid()).FirstOrDefault();
WXShopTokenInfo token = WXDBProdUploadForm.lstWXShopTokenInfo.FirstOrDefault(t => t.shopId == shop.ShopId);
if (token == null)
token = new WXShopTokenInfo();
if (token.isExpire || string.IsNullOrEmpty(token.accessToken))
for (int i = 0; i < 5; i++)
{
AuthInfo auth = GlobalConfig.lstWxShopAuthInfo.FirstOrDefault(sa => sa.ShopId == shop.ShopId);
//if (auth != null && auth.ExpiresTime > DateTime.Now.AddMinutes(5))
if (token == null)
token = new WXShopTokenInfo();
if (token.isExpire || string.IsNullOrEmpty(token.accessToken))
{
token = new WxApiBLL().GetShopWxToken(shop);
if (!string.IsNullOrEmpty(token.accessToken))
AuthInfo auth = GlobalConfig.lstWxShopAuthInfo.FirstOrDefault(sa => sa.ShopId == shop.ShopId);
//if (auth != null && auth.ExpiresTime > DateTime.Now.AddMinutes(5))
{
WXDBProdUploadForm.lstWXShopTokenInfo.RemoveAll(t => t.shopId == shop.ShopId);
WXDBProdUploadForm.lstWXShopTokenInfo.Add(token);
NaiBa.Util.Helper.ConfigHelper.SaveConfig("wx_shop_token_list", WXDBProdUploadForm.lstWXShopTokenInfo);
token = new WxApiBLL().GetShopWxToken(shop);
if (!string.IsNullOrEmpty(token.accessToken))
{
WXDBProdUploadForm.lstWXShopTokenInfo.RemoveAll(t => t.shopId == shop.ShopId);
WXDBProdUploadForm.lstWXShopTokenInfo.Add(token);
NaiBa.Util.Helper.ConfigHelper.SaveConfig("wx_shop_token_list", WXDBProdUploadForm.lstWXShopTokenInfo);
}
}
}
// 如果店铺token不可用,随机获取一个上传图片的accessToken
if (token == null || token.isExpire || string.IsNullOrEmpty(token.accessToken))
{
// 获取微信accessToken
//token = new WxApiBLL().GetRandomWxToken();
shop = GlobalConfig.ShopLoginList.OrderBy(x => Guid.NewGuid()).FirstOrDefault();
token = WXDBProdUploadForm.lstWXShopTokenInfo.FirstOrDefault(t => t.shopId == shop.ShopId);
continue;
}
else
{
break;
}
}
// 如果店铺token不可用,随机获取一个上传图片的accessToken
if (token == null || token.isExpire || string.IsNullOrEmpty(token.accessToken))
// 获取微信accessToken
token = new WxApiBLL().GetRandomWxToken();
try
{
JObject obj = new JObject();
@@ -1657,7 +1691,8 @@ namespace TemuKJD.PDDForms.ProductSelectForms
{
row.Cells["colMainCate"].Value = mainCatName;
row.Cells["col_cat_name"].Value = catName;
row.Cells["colCatBound"].Value = GlobalConfig.WxCatBoundList.FirstOrDefault(cb => cb.leaf_id == dbProd.wx_cat_leaf)?.cat_bound;
if (row.Cells.Cast<DataGridViewCell>().FirstOrDefault(c => c.OwningColumn.Name == "colCatBound") is DataGridViewCell boundCell)
boundCell.Value = GlobalConfig.WxCatBoundList.FirstOrDefault(cb => cb.leaf_id == dbProd.wx_cat_leaf)?.cat_bound;
}));
}
}
@@ -874,12 +874,6 @@ namespace TemuKJD.PDDForms.ProductSelectForms
if (kjdDbProd?.id == 0)
{
prod.status = "已清除";
//var empty_url = BaseClass.BuildObjString("product/mdy_user_select_product_status");
//var empty_data = UserLogin.GetSignaturex() +
// "&select_add_time=" + prod.add_time.ToString("yyyy-MM-dd HH:mm:ss") +
// "&db_id=" + prod.id +
// "&status=已清除";
//GetHtml.PostUtf8(empty_url, empty_data);
}
Invoke(new Action(() =>
@@ -39,6 +39,7 @@ namespace TemuKJD.PDDForms.ProductSelectForms
this.dgvSelectProduct = new TemuKJD.UserComponent.DataGridViewEx();
this.colCheck = new System.Windows.Forms.DataGridViewCheckBoxColumn();
this.colId = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.colGetType = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.colSpuId = new System.Windows.Forms.DataGridViewLinkColumn();
this.colImgUrl = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.colProductSkcPic = new System.Windows.Forms.DataGridViewImageColumn();
@@ -143,6 +144,7 @@ namespace TemuKJD.PDDForms.ProductSelectForms
this.dgvSelectProduct.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.colCheck,
this.colId,
this.colGetType,
this.colSpuId,
this.colImgUrl,
this.colProductSkcPic,
@@ -154,6 +156,7 @@ namespace TemuKJD.PDDForms.ProductSelectForms
this.ColDelete});
this.dgvSelectProduct.Dock = System.Windows.Forms.DockStyle.Fill;
this.dgvSelectProduct.Location = new System.Drawing.Point(5, 0);
this.dgvSelectProduct.MultiSelectCheckBox = true;
this.dgvSelectProduct.Name = "dgvSelectProduct";
this.dgvSelectProduct.ReadOnly = true;
this.dgvSelectProduct.RowTemplate.Height = 23;
@@ -178,6 +181,13 @@ namespace TemuKJD.PDDForms.ProductSelectForms
this.colId.ReadOnly = true;
this.colId.Width = 45;
//
// colGetType
//
this.colGetType.HeaderText = "来源";
this.colGetType.Name = "colGetType";
this.colGetType.ReadOnly = true;
this.colGetType.Visible = false;
//
// colSpuId
//
this.colSpuId.HeaderText = "商品ID";
@@ -243,14 +253,15 @@ namespace TemuKJD.PDDForms.ProductSelectForms
this.ColDelete.ReadOnly = true;
this.ColDelete.Width = 75;
//
// PDDDBProdUserSelectCacheForm
// PDDDBProdUploadSelectCacheForm
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.ClientSize = new System.Drawing.Size(1112, 600);
this.Controls.Add(this.splitContainer1);
this.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "PDDDBProdUserSelectCacheForm";
this.KeyPreview = true;
this.Name = "PDDDBProdUploadSelectCacheForm";
this.Text = "待上传商品";
this.TitleText = "待上传商品";
this.Load += new System.EventHandler(this.PDDDBProdUserSelectCacheForm_Load);
@@ -275,6 +286,7 @@ namespace TemuKJD.PDDForms.ProductSelectForms
private DevComponents.DotNetBar.PanelEx btnClearDgv;
private System.Windows.Forms.DataGridViewCheckBoxColumn colCheck;
private System.Windows.Forms.DataGridViewTextBoxColumn colId;
private System.Windows.Forms.DataGridViewTextBoxColumn colGetType;
private System.Windows.Forms.DataGridViewLinkColumn colSpuId;
private System.Windows.Forms.DataGridViewTextBoxColumn colImgUrl;
private System.Windows.Forms.DataGridViewImageColumn colProductSkcPic;
@@ -29,6 +29,10 @@ namespace TemuKJD.PDDForms.ProductSelectForms
private void PDDDBProdUserSelectCacheForm_Load(object sender, EventArgs e)
{
if (BaseClass.UserName == "15288888888")
{
dgvSelectProduct.Columns["colGetType"].Visible = true;
}
if (BaseClass.MainPath == "29pdd")
{
dgvSelectProduct.Columns["colBound"].Visible = false;
@@ -45,6 +49,7 @@ namespace TemuKJD.PDDForms.ProductSelectForms
int rowIndex = this.dgvSelectProduct.Rows.Add(
false,
prodSelect.id,
prodSelect.product_get_type_text,
BaseClass.SaLevel > 0 ? prodSelect.spu_id : prodSelect.spu_id.ParseToString().GetHashCode().ParseToString().Trim('-'),
prodSelect.main_img,
DataGridViewExtension.defaultBitmap,
@@ -123,6 +123,9 @@
<metadata name="colId.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="colGetType.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="colSpuId.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
@@ -565,171 +565,6 @@ namespace TemuKJD.PDDForms.ShopForms
return "";
}
/// <summary>
/// 第三方获取商品并直接提交到第三方待上传列表
/// </summary>
/// <param name="sProdId"></param>
/// <param name="supplierId"></param>
/// <returns></returns>
public string getThirdProduct(string sProdId, string supplierId)
{
var prodId = sProdId.ParseToLong();
if (prodId <= 0)
{
BaseMsgForm.ShowError("商品Id不存在!");
return "failed";
}
var shop = GlobalConfig.ShopLoginList.FirstOrDefault(s => s.ShopId == supplierId.ParseToString());
if (string.IsNullOrEmpty(supplierId) || shop == null)
{
BaseMsgForm.ShowError("店铺不存在!");
return "failed";
}
Task.Run(() =>
{
try
{
var sourceShop = shop;
var sourceProdId = prodId;
string success_err_msg = "";
string errorMsg = "";
var html = GetPddProdCommitId(sourceShop, sourceProdId.ToString());
if (!html.Contains("\"success\":true") || !html.Contains("\"result\""))
{
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 = GetPddProdDetail(sourceShop, sourceProdId.ToString(), commitId);
JObject obj = JObject.Parse(html);
var result = JsonHelper.SerializeObject(obj["result"]);
var sizeRst = "";
PDDProductDetailInfo product = JsonHelper.DeserializeJsonToObject<PDDProductDetailInfo>(result);
if (product == null)
{
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(() =>
{
PDDThirdProdSelectAddShopForm shopForm = new PDDThirdProdSelectAddShopForm();
shopForm.ShowDialog();
shopLst.AddRange(shopForm.lstSelectShop);
}));
if (shopLst.Count == 0)
{
OnInfoReceived("库存上传操作取消或未选择上传店铺!");
return;
}
string main_img = "";
//if (string.IsNullOrEmpty(main_img))
// 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(img => img.type == 1)?.url).ParseToString();
if (string.IsNullOrEmpty(main_img))
main_img = (product.galleries?.FirstOrDefault()?.url).ParseToString();
var url = BaseClass.BuildObjString("product_third/add_product");
var data = UserLogin.GetSignaturex() +
"&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(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"))
{
errorMsg = "库存商品保存失败!请检查网络连接:" +
BaseRegex.GetStringJson(ref html, "msg").ParseToString().Replace("'", "\\'").Replace("\"", "\\\"");
}
var id = BaseRegex.GetLongJson(ref html, "id");
if (id == 0)
goto end;
foreach (var addProdShop in shopLst)
{
url = BaseClass.BuildObjString("product_third/add_user_select_product");
data = UserLogin.GetSignaturex() +
"&out_product_id=" + id +
"&shop_id=" + addProdShop.ShopId +
"&shop_account=" + addProdShop.ShopAccount +
"&main_user_name=" + addProdShop.UserName +
"&sub_user_name=" + addProdShop.SubUserName +
"&add_product_remaining=" + addProdShop.AddProductRemaining +
"&status=待上传";
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 += product?.goods_id + " " + BaseRegex.GetStringJson(ref html, "msg") + "; ";
}
else
{
addProdShop.AddProductRemaining = addProdShop.AddProductRemaining - 1;
}
}
end:;
if (!string.IsNullOrEmpty(errorMsg))
{
OnInfoReceived(errorMsg);
}
else
{
OnInfoReceived("库存上传保存成功!" + success_err_msg);
}
}
catch (Exception ex)
{
OnInfoReceived("发生错误:" + ex.Message);
}
});
return "success";
}
TemuCat GetCat(TemuDetailProductInfo product)
{
if (product == null)
@@ -564,47 +564,6 @@ namespace TemuKJD.PDDForms.ShopForms
sb.Append("CefSharp.BindObjectAsync('shopObj');");
sb.Append("})();");
cefWebBrowser.GetBrowser().MainFrame.EvaluateScriptAsync(sb.ToString());
// 库存上传按钮 pdd不需要
if (1 == 2 && currentUrl.StartsWith("https://mms.pinduoduo.com/goods/goods_list"))
{
Task.Run(() => {
string sAddInputJs = @"
document.addEventListener('wheel', function(event) {
// 检查滚动方向
//if (event.deltaY < 0) {
// console.log('向上滚动');
//} else {
// console.log('向下滚动');
//}
// 或者使用 event.deltaX 来检查水平滚动
//if (event.deltaX < 0) {
// console.log('向左滚动');
//} else if (event.deltaX > 0) {
// console.log('向右滚动');
//}
// 阻止默认的滚动行为(如果有需要)
//event.preventDefault();
addGetProdButton();
});
addGetProdButton();
function addGetProdButton() {
var productLst = document.getElementsByClassName('goods-id');
for(i=0; i<productLst.length; i++) {
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 + @"')\"">"");
}
}
}";
cefWebBrowser.GetBrowser().MainFrame.EvaluateScriptAsync(sAddInputJs);
});
}
}
//public Func<object, string, string, request, bool> BeforeResourceLoadEvent; // sender, requestUrl, postData, request, true(表示取消执行)