优化了微店商品上传 优化pdd买手读单

This commit is contained in:
wule committed 2026-04-15 21:04:37 +08:00
1 parent 6c4f16b897
commit f360688c43
62 files changed
+5620 -1432

No files matched your search

File diff suppressed because it is too large. Load diff
@@ -412,6 +412,12 @@ namespace TemuKJD.PDDForms.ProductSelectForms
data += "&problem_prod_data=2";
else if (!string.IsNullOrEmpty(cmbHasReturn.Text.Trim()))
data += "&problem_prod_data=" + cmbHasReturn.Text.Trim();
if (cmbPddRelation.Text == "否")
data += "&is_relation=0";
else if (cmbPddRelation.Text == "是")
data += "&is_relation=1";
}));
var html = GetHtml.PostUtf8(url, data);
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
@@ -526,6 +532,24 @@ namespace TemuKJD.PDDForms.ProductSelectForms
var cate3 = cates3.FirstOrDefault(c => c.level == 3 && c.name == cmbCat1.Text.Trim());
}
private void dgvDbProduct_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex < 0 || e.RowIndex < 0)
return;
string headerText = dgvDbProduct.Columns[e.ColumnIndex].HeaderText;
var dbId = dgvDbProduct.Rows[e.RowIndex].Cells["col_db_id"].Value.ParseToString();
var dbProduct = lstTemuDbProduct.FirstOrDefault(p => p.id.ToString() == dbId);
switch (headerText)
{
case "标题":
dgvDbProduct.Rows[e.RowIndex].Cells["colSelect"].Value = !(bool)dgvDbProduct.Rows[e.RowIndex].Cells["colSelect"].Value;
break;
default:
break;
}
}
private void dgvDbProduct_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex < 0 || e.RowIndex < 0)
@@ -40,6 +40,8 @@ namespace TemuKJD.PDDForms.ProductSelectForms
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle();
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.ucGroupBoxEx2 = new TemuKJD.UserComponent.UcGroupBoxEx(this.components);
this.txtMultiPcsSku4 = new System.Windows.Forms.TextBox();
this.label27 = new System.Windows.Forms.Label();
this.txtMultiPcsSku3 = new System.Windows.Forms.TextBox();
this.txtMultiPcsSku2 = new System.Windows.Forms.TextBox();
this.txtMultiPcsSku1 = new System.Windows.Forms.TextBox();
@@ -96,6 +98,7 @@ namespace TemuKJD.PDDForms.ProductSelectForms
this.line2 = new DevComponents.DotNetBar.Controls.Line();
this.label26 = new System.Windows.Forms.Label();
this.ucGroupBoxEx4 = new TemuKJD.UserComponent.UcGroupBoxEx(this.components);
this.chkRelation = new TemuKJD.UserComponent.UcCheckBox(this.components);
this.cmbCateFilter3 = new TemuKJD.UserComponent.UcComboBoxMutiSelect();
this.label25 = new System.Windows.Forms.Label();
this.cmbCateFilter2 = new TemuKJD.UserComponent.UcComboBoxMutiSelect();
@@ -186,8 +189,6 @@ namespace TemuKJD.PDDForms.ProductSelectForms
this.btnClear = new DevComponents.DotNetBar.PanelEx();
this.panelEx1 = new DevComponents.DotNetBar.PanelEx();
this.panel1 = new System.Windows.Forms.Panel();
this.txtMultiPcsSku4 = new System.Windows.Forms.TextBox();
this.label27 = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
@@ -306,6 +307,27 @@ namespace TemuKJD.PDDForms.ProductSelectForms
this.ucGroupBoxEx2.TabStop = false;
this.ucGroupBoxEx2.Text = "商品上传";
//
// txtMultiPcsSku4
//
this.txtMultiPcsSku4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.txtMultiPcsSku4.Location = new System.Drawing.Point(849, 109);
this.txtMultiPcsSku4.Margin = new System.Windows.Forms.Padding(0, 2, 0, 2);
this.txtMultiPcsSku4.Name = "txtMultiPcsSku4";
this.txtMultiPcsSku4.Size = new System.Drawing.Size(25, 23);
this.txtMultiPcsSku4.TabIndex = 884;
this.txtMultiPcsSku4.Text = "1.1";
//
// label27
//
this.label27.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.label27.AutoSize = true;
this.label27.Location = new System.Drawing.Point(812, 112);
this.label27.Margin = new System.Windows.Forms.Padding(6, 0, 0, 0);
this.label27.Name = "label27";
this.label27.Size = new System.Drawing.Size(41, 17);
this.label27.TabIndex = 883;
this.label27.Text = "价格×";
//
// txtMultiPcsSku3
//
this.txtMultiPcsSku3.Location = new System.Drawing.Point(787, 109);
@@ -486,7 +508,6 @@ namespace TemuKJD.PDDForms.ProductSelectForms
this.btnApiUpload.StyleMouseOver.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(25)))), ((int)(((byte)(102)))), ((int)(((byte)(255)))));
this.btnApiUpload.TabIndex = 742;
this.btnApiUpload.Text = "批量上传";
this.btnApiUpload.Visible = false;
this.btnApiUpload.Click += new System.EventHandler(this.btnApiUpload_Click);
//
// btnUpload
@@ -1027,6 +1048,7 @@ namespace TemuKJD.PDDForms.ProductSelectForms
| System.Windows.Forms.AnchorStyles.Left)));
this.ucGroupBoxEx4.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
this.ucGroupBoxEx4.BorderStyle = TemuKJD.UserComponent.UcGroupBoxEx.GroupBoxBorderStyle.ROUND;
this.ucGroupBoxEx4.Controls.Add(this.chkRelation);
this.ucGroupBoxEx4.Controls.Add(this.cmbCateFilter3);
this.ucGroupBoxEx4.Controls.Add(this.label25);
this.ucGroupBoxEx4.Controls.Add(this.cmbCateFilter2);
@@ -1057,6 +1079,18 @@ namespace TemuKJD.PDDForms.ProductSelectForms
this.ucGroupBoxEx4.TabStop = false;
this.ucGroupBoxEx4.Text = "待传商品";
//
// chkRelation
//
this.chkRelation.Checked = true;
this.chkRelation.CheckState = System.Windows.Forms.CheckState.Checked;
this.chkRelation.Location = new System.Drawing.Point(262, 76);
this.chkRelation.Name = "chkRelation";
this.chkRelation.Size = new System.Drawing.Size(64, 21);
this.chkRelation.TabIndex = 856;
this.chkRelation.Text = "转换数据";
this.chkRelation.UseVisualStyleBackColor = true;
this.chkRelation.Visible = false;
//
// cmbCateFilter3
//
this.cmbCateFilter3.DefaultText = "全部";
@@ -2249,27 +2283,6 @@ namespace TemuKJD.PDDForms.ProductSelectForms
this.panel1.TabIndex = 189;
this.panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.panel1_Paint);
//
// txtMultiPcsSku4
//
this.txtMultiPcsSku4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.txtMultiPcsSku4.Location = new System.Drawing.Point(849, 109);
this.txtMultiPcsSku4.Margin = new System.Windows.Forms.Padding(0, 2, 0, 2);
this.txtMultiPcsSku4.Name = "txtMultiPcsSku4";
this.txtMultiPcsSku4.Size = new System.Drawing.Size(25, 23);
this.txtMultiPcsSku4.TabIndex = 884;
this.txtMultiPcsSku4.Text = "1.1";
//
// label27
//
this.label27.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.label27.AutoSize = true;
this.label27.Location = new System.Drawing.Point(812, 112);
this.label27.Margin = new System.Windows.Forms.Padding(6, 0, 0, 0);
this.label27.Name = "label27";
this.label27.Size = new System.Drawing.Size(41, 17);
this.label27.TabIndex = 883;
this.label27.Text = "价格×";
//
// PDDDBProdUserSelectForm
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
@@ -2474,5 +2487,6 @@ namespace TemuKJD.PDDForms.ProductSelectForms
private System.Windows.Forms.Label label26;
private System.Windows.Forms.TextBox txtMultiPcsSku4;
private System.Windows.Forms.Label label27;
private UserComponent.UcCheckBox chkRelation;
}
}
@@ -71,7 +71,7 @@ namespace TemuKJD.PDDForms.ProductSelectForms
private void UserSelectDbProductForm_Load(object sender, EventArgs e)
{
//Task.Run(() => { InitPddToken(); });
RefreshApi();
//RefreshApi();
this.splitContainer1.Dock = DockStyle.Fill;
this.panel1.Location = new Point(40, 30);
@@ -6275,6 +6275,10 @@ Content-Type: image/jpeg
data += "&is_supplier_prod_ok=" + "已设置";
data += "&wx_safe_status=" + "安全商品,未校验";
}
if (chkRelation.Checked)
{
data += "&is_relation=1";
}
}));
var html = GetHtml.PostUtf8(url, data);
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
@@ -7239,6 +7243,32 @@ Content-Type: image/jpeg
//Thread.Sleep(Randomx.GetId(500, 5000));
//return "{\"success\":true,\"goods_id\":" + 1000000 + ",\"status\":\"已上传\",\"msg\":\"上传成功\"}";
// 获取映射关系
List<PddRelationParam> relationLst = new List<PddRelationParam>();
PddRelationParam relationData = null;
{
var url = BaseClass.BuildPDDObjString("product/get_relation");
var data = UserLogin.GetSignaturex();
data += "&up_spu_id=" + selectProd.spu_id;
data += "&index=" + Math.Abs((selectProd.spu_id).GetHashCode()) % 128;
var result = GetHtml.PostUtf8(url, data);
if (string.IsNullOrEmpty(result) || !result.Contains("\"code\":200"))
result = GetHtml.PostUtf8(url, data);
if (result.Contains("\"data\":[]"))
{
return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"转换数据获取失败\"}";
}
try
{
var jStr = JsonHelper.SerializeObject(JsonHelper.JObjectParse(result)["data"]);
relationLst = JsonHelper.DeserializeJsonToList<PddRelationParam>(jStr);
}
catch (Exception ex)
{
return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"转换数据获取失败" + ex.Message + "\"}";
}
}
KJDDBProduct dbProd = selectProd.kjdDbProduct;
if (dbProd == null)
dbProd = GetProductDetail(selectProd.out_product_Id.ToString());
@@ -7773,6 +7803,14 @@ Content-Type: image/jpeg
// sk.multi_price = maxPrice1;
// sk.price = maxPrice1 + 100;
//}
var addPriceFakeSkuInfoMinPrice = addPriceFakeSkuInfoLst.Min(s => s.price);
var addPriceFakeSkuInfoMaxPrice = addPriceFakeSkuInfoLst.Max(s => s.price);
relationData = relationLst?
.OrderBy(r => r.price_min.ParseToInt())
.FirstOrDefault(r => r.price_min.ParseToInt() * 1.08m > addPriceFakeSkuInfoMinPrice && r.price_max.ParseToInt() * 1.08m > addPriceFakeSkuInfoMaxPrice);
if (relationData == null)
return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"转换数据获取价格失败\"}";
}
#endregion
@@ -7831,6 +7869,17 @@ Content-Type: image/jpeg
addPriceSkuInfoLst.Add(skuInfo);
}
if (relationData == null)
{
var addPriceSkuInfoMinPrice = addPriceSkuInfoLst.Min(s => s.price);
var addPriceSkuInfoMaxPrice = addPriceSkuInfoLst.Max(s => s.price);
relationData = relationLst?
.OrderBy(r => r.price_min.ParseToInt())
.FirstOrDefault(r => r.price_min.ParseToInt() * 1.08m > addPriceSkuInfoMinPrice && r.price_max.ParseToInt() * 1.08m > addPriceSkuInfoMaxPrice);
if (relationData == null)
return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"转换数据获取价格失败\"}";
}
}
#endregion
@@ -8024,6 +8073,25 @@ Content-Type: image/jpeg
}
var goods_id = BaseRegex.GetStringJson(ref upLoadRst, "goods_id");
if (!string.IsNullOrEmpty(goods_id))
{
var pddRelationApi = new PddApi(shop);
int sourceType = 8;
if (relationData.from_site == "vd")
sourceType = 8;
var relationRst = pddRelationApi.Relation2603(goods_id.ParseToLong(), relationData.goods_id, relationData.price_min.ParseToInt(), relationData.price_max.ParseToInt(), 0, sourceType);
if (!relationRst.Contains("\"is_success\":true"))
relationRst = pddRelationApi.Relation2603(goods_id.ParseToLong(), relationData.goods_id, relationData.price_min.ParseToInt(), relationData.price_max.ParseToInt(), 0, sourceType);
if (!relationRst.Contains("\"is_success\":true"))
relationRst = pddRelationApi.Relation2603(goods_id.ParseToLong(), relationData.goods_id, relationData.price_min.ParseToInt(), relationData.price_max.ParseToInt(), 0, sourceType);
if (!relationRst.Contains("\"is_success\":true"))
{
return "{\"success\":true,\"goods_id\":" + goods_id + ",\"status\":\"已上传但转换异常\",\"msg\":\"上传成功\"}";
}
}
return "{\"success\":true,\"goods_id\":" + goods_id + ",\"status\":\"已上传\",\"msg\":\"上传成功\"}";
}
@@ -8631,7 +8699,12 @@ Content-Type: image/jpeg
=> row.Cells["colSelect"]?.Value.ParseToBool() == true).Select(r => r.Cells["colShopId"]?.Value.ToString()).ToList();
foreach (var shop in GlobalConfig.ShopLoginList)
{
if (isForceRefresh || (shop.AuthAddTime <= DateTime.Now.AddDays(-1) && shop.AuthExpiresTime <= DateTime.Now))
if (shop.ShopAccount.Contains("阿杰"))
{
}
if (isForceRefresh || (shop.AuthUpdateTime <= DateTime.Now.AddDays(-1) && shop.AuthExpiresTime <= DateTime.Now))
{
Invoke(new Action(() =>
{
@@ -8646,26 +8719,26 @@ Content-Type: image/jpeg
}));
}
}
List<List<AuthInfo>> NewApiInfolsts = JsonHelper.DeserializeJsonToList<List<AuthInfo>>(JsonHelper.SerializeObject(GlobalConfig.ShopLoginList.Select(s => s.ApiAuthInfoList).ToList()));
foreach (var newLst in NewApiInfolsts)
{
if (newLst.FirstOrDefault()!= null)
{
var oldApiAuths = PddApiHelper.LstAuthInfos.FirstOrDefault(oldLst => oldLst.FirstOrDefault()?.ShopId == newLst.FirstOrDefault().ShopId);
if (oldApiAuths != null)
{
oldApiAuths.Clear();
oldApiAuths.AddRange(newLst);
}
else
{
PddApiHelper.LstAuthInfos.Add(newLst);
}
}
}
//List<List<AuthInfo>> NewApiInfolsts = JsonHelper.DeserializeJsonToList<List<AuthInfo>>(JsonHelper.SerializeObject(GlobalConfig.ShopLoginList.Select(s => s.ApiAuthInfoList).ToList()));
//foreach (var newLst in NewApiInfolsts)
//{
// if (newLst.FirstOrDefault()!= null)
// {
// var oldApiAuths = PddApiHelper.LstAuthInfos.FirstOrDefault(oldLst => oldLst.FirstOrDefault()?.ShopId == newLst.FirstOrDefault().ShopId);
// if (oldApiAuths != null)
// {
// oldApiAuths.Clear();
// oldApiAuths.AddRange(newLst);
// }
// else
// {
// PddApiHelper.LstAuthInfos.Add(newLst);
// }
// }
//}
PddApiHelper.LstAuthInfos = PddApiHelper.LstAuthInfos.Where(a => a.OrderBy(o => o.AddTime).LastOrDefault().AddTime > DateTime.Now.AddDays(-30)).ToList();
NaiBa.Util.Helper.ConfigHelper.SaveConfig("pdd_shop_api_auth_info_lists", PddApiHelper.LstAuthInfos);
//PddApiHelper.LstAuthInfos = PddApiHelper.LstAuthInfos.Where(a => a.OrderBy(o => o.UpdateTime).LastOrDefault().UpdateTime > DateTime.Now.AddDays(-30)).ToList();
//NaiBa.Util.Helper.ConfigHelper.SaveConfig("pdd_shop_api_auth_info_lists", PddApiHelper.LstAuthInfos);
Invoke(new Action(() => { pbShopLoading.Visible = false; }));
});
}
@@ -8675,6 +8748,9 @@ Content-Type: image/jpeg
WXUserProdListForm.Instance.lstTemuDBProductSelect = this.lstTemuDBProductSelect;
WXUserProdListForm.Instance.cmbSourceType.Items.Clear();
WXUserProdListForm.Instance.cmbSourceType.Items.AddRange(this.cmbSourceType.Items.Cast<Object>().ToArray());
WXUserProdListForm.Instance.lblRelation.Visible = false;
WXUserProdListForm.Instance.cmbRelation.Visible = false;
WXUserProdListForm.Instance.cmbRelation.Text = "是";
WXUserProdListForm.Instance.SaveComplete -= dbProdList_SaveComplete;
WXUserProdListForm.Instance.SaveComplete += dbProdList_SaveComplete;
WXUserProdListForm.Instance.Show();