机会商品采集功能

This commit is contained in:
wule committed 2025-12-29 19:56:10 +08:00
1 parent dae2bea6ef
commit c0b3583fef
18 files changed
+913 -157

No files matched your search

+1 -1
View File
@@ -27,7 +27,7 @@ namespace AllBase
/// <summary>
/// 版本ID
/// </summary>
public static int VersionCount = 763;
public static int VersionCount = 766;
//public static int VersionCount = 613;
/// <summary>
@@ -158,6 +158,9 @@ namespace AllBase.Model.Param.PDDProdParam
public string market_price_in_yuan { get; set; }
public int? market_price { get; set; }
/// <summary>
/// 货号
/// </summary>
public string out_goods_sn { get; set; } = "";
public int? dead_line_seconds { get; set; } = 86399;
public int? two_pieces_discount { get; set; } = 95;
@@ -187,7 +190,7 @@ namespace AllBase.Model.Param.PDDProdParam
public long? template_module_id { get; set; }
public int? ref_pid { get; set; }
public int? pid { get; set; }
public int? vid { get; set; }
public long? vid { get; set; }
public string value { get; set; }
public string value_unit { get; set; }
public string content { get; set; }
+2 -1
View File
@@ -51,7 +51,8 @@ namespace AllBase.Model.Result
/// <summary>
/// Temu 采集来源 0母店采集 1前端直采
/// </summary>
public int product_get_type { get; set; }
public int product_get_type { get; set; }
public string product_get_type_text { get; set; }
public string head_words { get; set; }
public string end_words { get; set; }
public string fission_words { get; set; }
@@ -20,7 +20,7 @@ namespace AllBase.Model.Result.PDDResult
}
public class value_item
{
public int? vid { get; set; }
public long? vid { get; set; }
public string value { get; set; }
public string unit { get; set; }
public string raw_value { get; set; }
@@ -106,7 +106,7 @@ namespace AllBase.Model.Result.PDDResult
public class spec_module_property_value_item
{
public int? id { get; set; } // 0
public int? vid { get; set; } // 59500
public long? vid { get; set; } // 59500
public string value { get; set; } // "白色"
public value_group_item group { get; set; }
public string extend_info { get; set; } // "(255,255,255,1)"
@@ -148,12 +148,13 @@ namespace AllBase.Model.Result.PDDResult
public int? show_type { get; set; }
public pdd_property_value_item values { get; set; }
public List<int?> value_ids { get; set; }
public List<goods_propertie> goods_properties { get; set; }
public int? control_type { get; set; }
public int? value_type { get; set; }
public int? choose_max_num { get; set; }
public int? parent_template_pid { get; set; }
public int? ref_pid { get; set; }
public object rule { get; set; }
public object rule { get; set; } = new object();
public int? auto_compute_type { get; set; }
public bool? is_key { get; set; }
@@ -168,6 +169,15 @@ namespace AllBase.Model.Result.PDDResult
public bool? is_ref_only { get; set; }
}
public class goods_propertie
{
public string p_unit { get; set; } // "",
public long? vid { get; set; } // 24044,
public string v_value { get; set; } // "中国大陆",
public object group_vo { get; set; } // {}
}
public class pdd_property_value_item
{
public List<pdd_property_value_content_item> content { get; set; }
@@ -190,7 +200,7 @@ namespace AllBase.Model.Result.PDDResult
}
public class pdd_property_value_content_item
{
public int? vid { get; set; }
public long? vid { get; set; }
public string value { get; set; }
}
@@ -39,6 +39,11 @@ namespace KJD_Web.BLL.BXX
string size_json = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "size_json"))?.Replace("'", "\\'");
string main_img = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "main_img"))?.Replace("'", "\\'");
string notes = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "notes"))?.Replace("'", "\\'");
string product_get_type = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "product_get_type"))?.Replace("'", "\\'");
if (string.IsNullOrEmpty(product_get_type))
{
product_get_type = "母店采集";
}
if (string.IsNullOrEmpty(user_name))
{
@@ -51,10 +56,10 @@ namespace KJD_Web.BLL.BXX
//UPDATE `bxx`.`product` set sku_img_replace_id=18 where prod_type = '拖鞋' and sku_img_replace_id<12 order by rand() limit 50;
sql = "insert into bxx.product (from_shop_id,spu_id,skc_id,main_cat_id,main_cat_name,cat_id,cat_name,price_text," +
"product_name,ext_code,main_img,product_json,size_json,notes,add_time,mdy_time) " +
"product_name,ext_code,main_img,product_json,size_json,notes,product_get_type,add_time,mdy_time) " +
"values ('" + from_shop_id + "','" + spu_id + "','" + skc_id + "','" + main_cat_id + "','" + main_cat_name + "','" +
cat_id + "','" + cat_name + "','" + price_text + "','" + product_name + "','" + ext_code + "','" + main_img + "','" +
product_json + "','" + size_json + "','" + notes + "','" +
product_json + "','" + size_json + "','" + notes + "','" + product_get_type + "','" +
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','" +
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "');";
var rst = mySql.ExecuteNonQuery(sql);
@@ -172,6 +177,7 @@ namespace KJD_Web.BLL.BXX
var search_db_ids = RegexUtils.GetStringQuery(ref inputData, "search_db_ids")?.Replace("'", "\\'");
var get_select_count = RegexUtils.GetStringQuery(ref inputData, "get_select_count")?.Replace("'", "\\'");
var select_shop_id = RegexUtils.GetStringQuery(ref inputData, "select_shop_id")?.Replace("'", "\\'");
var from_shop_id = RegexUtils.GetStringQuery(ref inputData, "from_shop_id")?.Replace("'", "\\'");
var sort_field = RegexUtils.GetStringQuery(ref inputData, "sort_field")?.Replace("'", "\\'");
int page = RegexUtils.GetStringQuery(ref inputData, "page").ParseToInt();
@@ -197,6 +203,8 @@ namespace KJD_Web.BLL.BXX
where += " and p.group like '%" + search_group + "%'";
if (!string.IsNullOrWhiteSpace(search_notes))
where += " and p.notes like '%" + search_notes + "%'";
if (!string.IsNullOrEmpty(from_shop_id))
where += " and p.from_shop_id ='" + from_shop_id + "'";
if (!string.IsNullOrEmpty(search_db_ids))
where += " and p.id in (" + search_db_ids + ")";
sql += where;
@@ -217,14 +225,14 @@ namespace KJD_Web.BLL.BXX
" where p.is_del=0";
else if (string.IsNullOrEmpty(get_select_count))
sql = "select p.id,p.from_shop_id,p.spu_id,p.skc_id,p.main_cat_id,p.main_cat_name,p.cat_id,p.cat_name,p.price_text,p.ext_code,p.product_name,p.main_img,p.notes," +
" p.add_time,p.mdy_time,p.select_total_count,p.fission_words,p.head_words,p.end_words,p.sku_img_replace_id,p.group,s.img_url,e.ext_code_price" +
" p.add_time,p.mdy_time,p.select_total_count,p.fission_words,p.head_words,p.end_words,p.sku_img_replace_id,p.group,p.product_get_type,s.img_url,e.ext_code_price" +
" FROM bxx.product p " +
" left join bxx.sku_img_replace s ON p.sku_img_replace_id=s.id" +
" LEFT JOIN bxx.ext_code_price e ON p.ext_code=e.ext_code" +
" where p.is_del=0";
else
sql = "SELECT p.id,p.from_shop_id,p.spu_id,p.skc_id,p.main_cat_id,p.main_cat_name,p.cat_id,p.cat_name,p.price_text,p.ext_code,p.product_name,p.main_img,p.notes," +
" p.add_time,p.mdy_time,p.select_total_count,p.fission_words,p.head_words,p.end_words,p.sku_img_replace_id,p.group,s.img_url,COUNT(se.id) AS select_count," +
" p.add_time,p.mdy_time,p.select_total_count,p.fission_words,p.head_words,p.end_words,p.sku_img_replace_id,p.group,p.product_get_type,s.img_url,COUNT(se.id) AS select_count," +
" e.ext_code_price" +
" FROM bxx.product p left join bxx.sku_img_replace s ON p.sku_img_replace_id=s.id LEFT JOIN bxx.product_select se ON p.id=se.out_product_id AND se.shop_id='" + select_shop_id + "' " +
" LEFT JOIN bxx.ext_code_price e ON p.ext_code=e.ext_code" +
@@ -276,6 +284,7 @@ namespace KJD_Web.BLL.BXX
head_words = row["head_words"].ParseToString(),
sku_img_replace_id = row["sku_img_replace_id"].ParseToInt(),
sku_img_replace_url = row["img_url"].ToString(),
product_get_type_text = row["product_get_type"].ToString(),
};
if (isDetail)
{
@@ -8,7 +8,7 @@
<IISExpressWindowsAuthentication />
<IISExpressUseClassicPipelineMode />
<UseGlobalApplicationHostFile />
<LastActiveSolutionConfig>Debug|Any CPU</LastActiveSolutionConfig>
<LastActiveSolutionConfig>Release|Any CPU</LastActiveSolutionConfig>
<ProjectView>ShowAllFiles</ProjectView>
</PropertyGroup>
<ProjectExtensions>
@@ -71,5 +71,6 @@ namespace KJD_Web.Model
public string head_words { get; set; }
public string end_words { get; set; }
public int product_get_type { get; set; }
public string product_get_type_text { get; set; }
}
}
@@ -71,6 +71,8 @@ namespace TemuKJD.PDDForms.ProductSelectForms
this.txtSKC = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.dgvDbProduct = new TemuKJD.UserComponent.DataGridViewEx();
this.ucSplitPage1 = new TemuKJD.UserControls.UcSplitPage();
this.statusBar = new TemuKJD.UserControls.StatusBarUserControl();
this.colSelect = new System.Windows.Forms.DataGridViewCheckBoxColumn();
this.col_db_id = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.colFromShopId = new System.Windows.Forms.DataGridViewTextBoxColumn();
@@ -93,13 +95,12 @@ namespace TemuKJD.PDDForms.ProductSelectForms
this.colHeadWords = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.colEndWords = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.colFissionWords = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.colGetType = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.colAddTime = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.colMdyTime = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.col_edit = new System.Windows.Forms.DataGridViewLinkColumn();
this.col_delete = new System.Windows.Forms.DataGridViewLinkColumn();
this.col_select_product = new System.Windows.Forms.DataGridViewLinkColumn();
this.ucSplitPage1 = new TemuKJD.UserControls.UcSplitPage();
this.statusBar = new TemuKJD.UserControls.StatusBarUserControl();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
@@ -619,6 +620,7 @@ namespace TemuKJD.PDDForms.ProductSelectForms
this.colHeadWords,
this.colEndWords,
this.colFissionWords,
this.colGetType,
this.colAddTime,
this.colMdyTime,
this.col_edit,
@@ -634,6 +636,31 @@ namespace TemuKJD.PDDForms.ProductSelectForms
this.dgvDbProduct.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgvDbProduct_CellContentClick);
this.dgvDbProduct.Scroll += new System.Windows.Forms.ScrollEventHandler(this.dgvDbProduct_Scroll);
//
// ucSplitPage1
//
this.ucSplitPage1.CurrentPage = 1;
this.ucSplitPage1.Dock = System.Windows.Forms.DockStyle.Right;
this.ucSplitPage1.IsShowPageSize = true;
this.ucSplitPage1.Location = new System.Drawing.Point(1024, 0);
this.ucSplitPage1.Margin = new System.Windows.Forms.Padding(0);
this.ucSplitPage1.Name = "ucSplitPage1";
this.ucSplitPage1.Padding = new System.Windows.Forms.Padding(0, 0, 1, 0);
this.ucSplitPage1.PageSize = 50;
this.ucSplitPage1.Size = new System.Drawing.Size(414, 25);
this.ucSplitPage1.TabIndex = 6;
this.ucSplitPage1.TotalPage = 1;
//
// statusBar
//
this.statusBar.BackColor = System.Drawing.Color.White;
this.statusBar.Dock = System.Windows.Forms.DockStyle.Fill;
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, 0);
this.statusBar.Margin = new System.Windows.Forms.Padding(0);
this.statusBar.Name = "statusBar";
this.statusBar.Size = new System.Drawing.Size(1438, 25);
this.statusBar.TabIndex = 5;
//
// colSelect
//
this.colSelect.FillWeight = 26F;
@@ -806,6 +833,13 @@ namespace TemuKJD.PDDForms.ProductSelectForms
this.colFissionWords.ReadOnly = true;
this.colFissionWords.Visible = false;
//
// colGetType
//
this.colGetType.FillWeight = 70F;
this.colGetType.HeaderText = "采集来源";
this.colGetType.Name = "colGetType";
this.colGetType.ReadOnly = true;
//
// colAddTime
//
this.colAddTime.FillWeight = 80F;
@@ -845,31 +879,6 @@ namespace TemuKJD.PDDForms.ProductSelectForms
this.col_select_product.Resizable = System.Windows.Forms.DataGridViewTriState.True;
this.col_select_product.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
//
// ucSplitPage1
//
this.ucSplitPage1.CurrentPage = 1;
this.ucSplitPage1.Dock = System.Windows.Forms.DockStyle.Right;
this.ucSplitPage1.IsShowPageSize = true;
this.ucSplitPage1.Location = new System.Drawing.Point(1024, 0);
this.ucSplitPage1.Margin = new System.Windows.Forms.Padding(0);
this.ucSplitPage1.Name = "ucSplitPage1";
this.ucSplitPage1.Padding = new System.Windows.Forms.Padding(0, 0, 1, 0);
this.ucSplitPage1.PageSize = 50;
this.ucSplitPage1.Size = new System.Drawing.Size(414, 25);
this.ucSplitPage1.TabIndex = 6;
this.ucSplitPage1.TotalPage = 1;
//
// statusBar
//
this.statusBar.BackColor = System.Drawing.Color.White;
this.statusBar.Dock = System.Windows.Forms.DockStyle.Fill;
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, 0);
this.statusBar.Margin = new System.Windows.Forms.Padding(0);
this.statusBar.Name = "statusBar";
this.statusBar.Size = new System.Drawing.Size(1438, 25);
this.statusBar.TabIndex = 5;
//
// PDDDBProdListForm
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
@@ -940,6 +949,7 @@ namespace TemuKJD.PDDForms.ProductSelectForms
private DevComponents.DotNetBar.PanelEx btnEditExtCodePriceOK;
private System.Windows.Forms.Label lblExtCodePrice;
private System.Windows.Forms.TextBox txtExtCodePrice;
private DevComponents.DotNetBar.PanelEx btnExportTxt;
private System.Windows.Forms.DataGridViewCheckBoxColumn colSelect;
private System.Windows.Forms.DataGridViewTextBoxColumn col_db_id;
private System.Windows.Forms.DataGridViewTextBoxColumn colFromShopId;
@@ -962,11 +972,11 @@ namespace TemuKJD.PDDForms.ProductSelectForms
private System.Windows.Forms.DataGridViewTextBoxColumn colHeadWords;
private System.Windows.Forms.DataGridViewTextBoxColumn colEndWords;
private System.Windows.Forms.DataGridViewTextBoxColumn colFissionWords;
private System.Windows.Forms.DataGridViewTextBoxColumn colGetType;
private System.Windows.Forms.DataGridViewTextBoxColumn colAddTime;
private System.Windows.Forms.DataGridViewTextBoxColumn colMdyTime;
private System.Windows.Forms.DataGridViewLinkColumn col_edit;
private System.Windows.Forms.DataGridViewLinkColumn col_delete;
private System.Windows.Forms.DataGridViewLinkColumn col_select_product;
private DevComponents.DotNetBar.PanelEx btnExportTxt;
}
}
@@ -1,5 +1,6 @@
using AllBase;
using AllBase.Model.Result;
using AllBase.Model.Result.PDDResult;
using NaiBa.Util.Extension;
using Newtonsoft.Json.Linq;
using System;
@@ -169,6 +170,7 @@ namespace TemuKJD.PDDForms.ProductSelectForms
prod.head_words,
prod.end_words,
prod.fission_words,
prod.product_get_type_text,
prod.add_time.ToString("yy-MM-dd HH:mm"),
prod.mdy_time.ToString("yy-MM-dd HH:mm"),
"编辑",
@@ -751,7 +753,15 @@ namespace TemuKJD.PDDForms.ProductSelectForms
}
StreamWriter sw = new StreamWriter(Path.Combine(path, prod.spu_id + ".txt"), true, Encoding.UTF8);
sw.Write(prod.product_json);
JObject jObj = JObject.Parse(prod.product_json);
if (!string.IsNullOrEmpty(prod.ext_code))
jObj["out_goods_sn"] = prod.ext_code;
if (!string.IsNullOrEmpty(prod.sku_edit_json))
jObj["sku"] = JsonHelper.SerializeObject(JsonHelper.DeserializeJsonToList<sku_item>(prod.sku_edit_json));
string exportData = JsonHelper.SerializeObject(jObj);
//sw.Write(prod.product_json);
sw.Write(exportData);
sw.Close();
Invoke(new Action(() =>
@@ -183,6 +183,9 @@
<metadata name="colFissionWords.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="colAddTime.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
@@ -1115,8 +1115,6 @@ namespace TemuKJD.PDDForms.ProductSelectForms
}
}
var xxx = new PDDShopBrowserObject().getPDDProductWidthEdit(shop, prodParam.goods_id.ToString(), prodParam.goods_commit_id, true, true);
Thread.Sleep(Randomx.GetId(10, 50));
rst = QueryChanceCommitDetail(shop, goods_id.ToString(), draftId, prodInfo.chance_tab);
if (!rst.Contains("\"success\":true"))
@@ -1395,11 +1393,37 @@ namespace TemuKJD.PDDForms.ProductSelectForms
prodParam.goods_name = prodInfo.detail.goods_name;
prodParam.goods_name_prefix = prodInfo.detail.goods_name_prefix;
prodParam.goods_pattern = prodInfo.detail.goods_pattern;
sleepTime = Randomx.GetId(500, 1399);
sleepTimeTotal += sleepTime;
Thread.Sleep(sleepTime);
if (!isChanceApi)
{
sleepTime = Randomx.GetId(500, 3500);
sleepTimeTotal += sleepTime;
Thread.Sleep(sleepTime);
var rand = Randomx.GetId(10);
if (rand <= 2)
{
sleepTime = Randomx.GetId(1000, 5000);
sleepTimeTotal += sleepTime;
Thread.Sleep(sleepTime);
}
if (rand <= 1)
{
sleepTime = Randomx.GetId(1000, 5000);
sleepTimeTotal += sleepTime;
Thread.Sleep(sleepTime);
}
}
prodParam.goods_properties = new List<goods_spec_property_param>(); // 商品属性,通过接口获取商品模板并做匹配
var goods_properties = new List<goods_spec_property_param>(); // 商品属性,暂存
//step1(共3个step)通过商品属性获取二级必填属性
foreach (var propInfo in prodInfo.property.goods_properties)
for (int i = 0; i < prodInfo.property.goods_properties.Count; i++)
{
var propInfo = prodInfo.property.goods_properties[i];
var propTemp = prodCatTemplateInfo.modules.FirstOrDefault()?.propertys.FirstOrDefault(p => p.ref_pid == propInfo.ref_pid);
if (propTemp == null)
continue;
@@ -1410,35 +1434,12 @@ namespace TemuKJD.PDDForms.ProductSelectForms
template_module_id = prodCatTemplateInfo.modules.FirstOrDefault().id,
ref_pid = propInfo.ref_pid,
pid = propTemp.pid,
vid = (propInfo.values.FirstOrDefault()?.vid).ParseToInt(),
vid = propInfo.values.FirstOrDefault()?.vid,
value = "",
value_unit = "",
content = (propInfo.values.FirstOrDefault()?.value).ParseToString(),
};
sleepTime = Randomx.GetId(500, 1399);
sleepTimeTotal += sleepTime;
Thread.Sleep(sleepTime);
if (!isChanceApi)
{
sleepTime = Randomx.GetId(500, 3500);
sleepTimeTotal += sleepTime;
Thread.Sleep(sleepTime);
var rand = Randomx.GetId(10);
if (rand <= 2)
{
sleepTime = Randomx.GetId(1000, 5000);
sleepTimeTotal += sleepTime;
Thread.Sleep(sleepTime);
}
if (rand <= 1)
{
sleepTime = Randomx.GetId(1000, 5000);
sleepTimeTotal += sleepTime;
Thread.Sleep(sleepTime);
}
}
if (cell != null)
{
Invoke(new Action(() =>
@@ -1446,19 +1447,66 @@ namespace TemuKJD.PDDForms.ProductSelectForms
cell.Value = "正在编辑商品属性";
}));
}
string prop_sub_template_html = get_sub_property_template(shop, prodInfo.detail.cat_id.ParseToString(),
prop.template_pid.ParseToString(), prop.vid.ParseToString(), prodParam.goods_id.ToString(), prodParam.goods_commit_id, prodInfo.chance_tab);
if (prop_sub_template_html.Contains("\"success\":true"))
List<goods_property_param> goods_property_param_lst = new List<goods_property_param>();
goods_property_param_lst.Add(prop);
while (goods_property_param_lst.Count > 0)
{
//template_module_vos
var prop1 = goods_property_param_lst[0];
string catId = prodParam.cat_id.ParseToString();
string template_pid = prop1.template_pid.ParseToString();
string vid = prop1.vid.ParseToString();
string goodsId = prodParam.goods_id.ToString();
string prop_sub_template_html = get_sub_property_template(shop, catId, template_pid, vid, goodsId, prodParam.goods_commit_id, prodInfo.chance_tab);
goods_property_param_lst.Remove(prop1);
if (!prop_sub_template_html.Contains("\"success\":true"))
continue;
try
{
//template_module_vos
prop_sub_template_html = GetHtml.Unicode2String(prop_sub_template_html);
JObject prop_sub_template_obj = JObject.Parse(prop_sub_template_html);
string prop_sub_template_json = JsonHelper.SerializeObject(prop_sub_template_obj["result"]["template_module_vos"]);
var subTempLst = JsonHelper.DeserializeJsonToList<pdd_module_item>(prop_sub_template_json);
if (subTempLst.Count > 0)
if (subTempLst.Count > 0 && subTempLst.FirstOrDefault().propertys.Count > 0)
{
foreach (var subProperty in subTempLst.FirstOrDefault().propertys)
{
//if (!prodInfo.property.goods_properties.Any(p => p.ref_pid == subProperty.ref_pid) && subProperty.required && subProperty.values.content.Count == 1)
//{
// prodInfo.property.goods_properties.Add(new goods_propertie_item()
// {
// });
//}
prodCatTemplateInfo.modules.FirstOrDefault()?.propertys.RemoveAll(p => p.ref_pid == subProperty.ref_pid); // 如果有二级属性,先要把原来的一级属性删掉
if (subProperty.values.content.Count > 1)
{
}
if (subProperty.required && subProperty.values.content.Count == 1)
{
var propNew = new goods_property_param()
{
template_pid = subProperty.id,
template_module_id = prodCatTemplateInfo.modules.FirstOrDefault().id,
ref_pid = subProperty.ref_pid,
pid = subProperty.pid,
vid = subProperty.values.content[0].vid,
value = "",
value_unit = "",
content = "",
};
goods_property_param_lst.Add(propNew);
}
}
prodCatTemplateInfo.modules.FirstOrDefault()?.propertys.AddRange(subTempLst.FirstOrDefault()?.propertys);
}
else
{
continue;
}
//if (subTempLst == null)
//{
// return "商品获取失败!商品属性格式模板获取失败!";
@@ -1468,6 +1516,7 @@ namespace TemuKJD.PDDForms.ProductSelectForms
{
//转换失败也不要取消,会上传到草稿箱
//return "编辑失败 " + ex.Message;
continue;
}
}
}
@@ -1494,7 +1543,7 @@ namespace TemuKJD.PDDForms.ProductSelectForms
template_module_id = prodCatTemplateInfo.modules.FirstOrDefault().id,
ref_pid = propInfo.ref_pid,
pid = propTemp.pid,
vid = (propInfo.values.FirstOrDefault()?.vid).ParseToInt(),
vid = propInfo.values.FirstOrDefault()?.vid,
value = "",
value_unit = "",
content = (propInfo.values.FirstOrDefault()?.value).ParseToString(),
@@ -1504,7 +1553,7 @@ namespace TemuKJD.PDDForms.ProductSelectForms
//step3(共3个step)如果有遗漏的必填(required)商品属性,按默认值填写
foreach (var propTemp in prodCatTemplateInfo.modules.FirstOrDefault()?.propertys)
{
if (propTemp.required && !prodParam.goods_properties.Any(p=>p.ref_pid == propTemp.ref_pid))
if (propTemp.required && !goods_properties.Any(p=>p.ref_pid == propTemp.ref_pid))
{
var contentOther = propTemp.values.content.FirstOrDefault(c => c.value == "其他");
if (contentOther != null)
@@ -1523,6 +1572,40 @@ namespace TemuKJD.PDDForms.ProductSelectForms
};
goods_properties.Add(prop);
}
else if (propTemp.name_alias == "成分含量")
{
var contentValue = propTemp.values.content.FirstOrDefault(v => v.value.Contains("以下"));
if (contentValue != null)
{
var prop = new goods_spec_property_param()
{
template_pid = propTemp.id,
template_module_id = prodCatTemplateInfo.modules.FirstOrDefault().id,
ref_pid = propTemp.ref_pid,
pid = propTemp.pid,
vid = contentValue.vid,
value = "",
value_unit = "",
content = contentValue.value,
};
goods_properties.Add(prop);
}
}
else if (propTemp.show_type == 1 && propTemp.values.content.Count == 1) // 二级关联属性
{
var prop = new goods_spec_property_param()
{
template_pid = propTemp.id,
template_module_id = prodCatTemplateInfo.modules.FirstOrDefault().id,
ref_pid = propTemp.ref_pid,
pid = propTemp.pid,
vid = propTemp.values.content.FirstOrDefault().vid,
value = "",
value_unit = "",
content = propTemp.values.content.FirstOrDefault().value,
};
goods_properties.Add(prop);
}
}
}
foreach (var prodTempInfo in prodCatTemplateInfo.modules.FirstOrDefault()?.propertys)
@@ -2082,6 +2165,28 @@ namespace TemuKJD.PDDForms.ProductSelectForms
text_module_details = null,
width = c.width,
};
if (decorationContentParam.width > 1200 || decorationContentParam.height > 1500)
{
if (decorationContentParam.width > 1200)
{
decorationContentParam.height = (1.0m * decorationContentParam.height * (1200 / decorationContentParam.width)).ParseToInt();
decorationContentParam.width = 1200;
}
if (decorationContentParam.height > 1500)
{
decorationContentParam.width = (1.0m * decorationContentParam.width * (1200 / decorationContentParam.height)).ParseToInt();
decorationContentParam.height = 1200;
}
var resizeRst = ResizeImagePro(shop, prodParam.goods_id.ParseToString(), prodParam.goods_commit_id, decorationContentParam.img_url);
if (!resizeRst.Contains("\"success\":true"))
{
var error = BaseRegex.GetStringJson(ref resizeRst, "error_msg");
if (string.IsNullOrEmpty(error))
error = resizeRst;
return "详情装修失败 " + error;
}
decorationContentParam.img_url = BaseRegex.GetStringJson(ref resizeRst, "url");
}
try { decorationContentParam.text_module_details = JsonHelper.DeserializeJsonToObject<text_module_detail_param>(JsonHelper.SerializeObject(c.text_module_details)); }
catch (Exception ex) { }
floor_param.content_list.Add(decorationContentParam);
@@ -2208,7 +2313,7 @@ namespace TemuKJD.PDDForms.ProductSelectForms
template_pid = specProp.id,
value = skuSpec.spec_name,
value_unit = "",
vid = (specPropValue?.vid).ParseToInt(),
vid = specPropValue?.vid,
parent_spec_id = skuSpec.parent_id,
spec_id = skuSpec.spec_id,
note = "",
@@ -2244,7 +2349,7 @@ namespace TemuKJD.PDDForms.ProductSelectForms
template_pid = specProp.id,
value = skuSpec.spec_name,
value_unit = "",
vid = (specPropValue?.vid).ParseToInt(),
vid = specPropValue?.vid,
parent_spec_id = skuSpec.parent_id,
spec_id = skuSpec.spec_id,
note = "",
@@ -4346,6 +4451,37 @@ Content-Disposition: form-data; name=""pic_operations""
}
private string ResizeImagePro(ShopLoginInfo shop, string goodsId, string commitId, string imgUrl, string chanceTab = "")
{
var anti = shop.AntiContents.LastOrDefault().ParseToString();
if (shop.AntiContents.Count > 0)
anti = shop.AntiContents[Randomx.GetId(shop.AntiContents.Count)];
string url = "https://mms.pinduoduo.com/garner/mms/file/getImagePro";
string body = @"{""url"":""" + imgUrl + @"?imageMogr2/gravity/center/thumbnail/1200x1200""}";
string refere = "https://mms.pinduoduo.com/goods/goods_add/index?type=add&from=category&id=" + commitId +
"&goods_id=" + goodsId + "&sourcePage=goodsList";
if (isChanceApi)
refere = "https://mms.pinduoduo.com/goods/goods_add/index?type=add&from=chance&id=" + commitId +
"&goods_id=" + goodsId + "&chance_tab=search&sourcePage=goodsListTopButton_CHANCE";
if (!string.IsNullOrEmpty(chanceTab))
refere = refere.Replace("chance_tab=search", "chance_tab=" + chanceTab);
var result = HttpResponseBLL.PDDPostResponse(shop, url, body, refere, anti);
for (int i = 0; i < 5 && result.Contains("网络繁忙,请不要频繁操作"); i++)
{
shop.AntiContents.Remove(anti);
anti = shop.AntiContents.FirstOrDefault().ParseToString();
if (shop.AntiContents.Count > 0)
{
Thread.Sleep(Randomx.GetId(300, 500));
anti = shop.AntiContents[Randomx.GetId(shop.AntiContents.Count)];
result = HttpResponseBLL.PDDPostResponse(shop, url, body, refere, anti);
}
}
return result;
}
/// <summary>
/// 保存商品详情图装修列表
/// gorse/mms/goods/decoration/commit/save
@@ -4734,7 +4870,7 @@ Content-Disposition: form-data; name=""pic_operations""
rst = GoodsSubmit(shop, goods_id.ToString(), draftId, "");
}
public static string GetChanceGoodsList(ShopLoginInfo shop, string searchWord, List<string> labels = null, int page = 1)
public static string GetChanceGoodsList(ShopLoginInfo shop, string searchWord, List<string> labels = null, string desc="", int page = 1)
{
//labels
//newinfashion_new 当季新品
@@ -4765,6 +4901,10 @@ Content-Disposition: form-data; name=""pic_operations""
{
jObj["search_word"] = searchWord;
}
if (!string.IsNullOrWhiteSpace(desc))
{
jObj["desc"] = desc;
}
//全网热销/不搜索 string body = @"{""size"":35,""page"":1,""labels"":[""wide_popular""],""banner_type"":0}";
//不限/搜索 string body = @"{""size"":35,""page"":1,""search_word"":""" + searchWord + @"""}";
string body = JsonHelper.SerializeObject(jObj);
@@ -4796,6 +4936,8 @@ Content-Disposition: form-data; name=""pic_operations""
string body = @"{""chance_id"":""" + chanceId + @"""}";
string refere = "https://mms.pinduoduo.com/goods/goods_list/chance/chance_list?search_word=" + GetHtml.UrlEncodeUtf8(searchWord) +
"&sourcePage=goodsListTopButton";
if (string.IsNullOrWhiteSpace(searchWord))
refere = "https://mms.pinduoduo.com/goods/goods_list/chance?sourcePage=goodsListTopButton";
if (!string.IsNullOrEmpty(_refere))
refere = _refere;
@@ -35,8 +35,13 @@ namespace TemuKJD.PDDForms.ProductSelectForms
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle();
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.ucGroupBoxEx1 = new TemuKJD.UserComponent.UcGroupBoxEx(this.components);
this.btnStopStop = new DevComponents.DotNetBar.PanelEx();
this.btnSelectSuccess = new DevComponents.DotNetBar.PanelEx();
this.btnStop = new DevComponents.DotNetBar.PanelEx();
this.txtSearchCount = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.cmbSearchLabel = new System.Windows.Forms.ComboBox();
@@ -55,6 +60,7 @@ namespace TemuKJD.PDDForms.ProductSelectForms
this.btnRefreshShop = new DevComponents.DotNetBar.PanelEx();
this.label4 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.chkOverride = new TemuKJD.UserComponent.UcCheckBox(this.components);
this.splitContainer2 = new System.Windows.Forms.SplitContainer();
this.splitContainer3 = new System.Windows.Forms.SplitContainer();
this.pbShopLoading = new System.Windows.Forms.PictureBox();
@@ -75,8 +81,8 @@ namespace TemuKJD.PDDForms.ProductSelectForms
this.colChanceId = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.colImgUrl = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.colImg = new System.Windows.Forms.DataGridViewImageColumn();
this.colImgType = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.colGroup = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.colGoodsName = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.colHotValue = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.colCate = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.colPrice = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.colMsg = new System.Windows.Forms.DataGridViewTextBoxColumn();
@@ -129,6 +135,9 @@ namespace TemuKJD.PDDForms.ProductSelectForms
| System.Windows.Forms.AnchorStyles.Right)));
this.ucGroupBoxEx1.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
this.ucGroupBoxEx1.BorderStyle = TemuKJD.UserComponent.UcGroupBoxEx.GroupBoxBorderStyle.ROUND;
this.ucGroupBoxEx1.Controls.Add(this.btnStopStop);
this.ucGroupBoxEx1.Controls.Add(this.btnSelectSuccess);
this.ucGroupBoxEx1.Controls.Add(this.btnStop);
this.ucGroupBoxEx1.Controls.Add(this.txtSearchCount);
this.ucGroupBoxEx1.Controls.Add(this.label5);
this.ucGroupBoxEx1.Controls.Add(this.cmbSearchLabel);
@@ -147,6 +156,7 @@ namespace TemuKJD.PDDForms.ProductSelectForms
this.ucGroupBoxEx1.Controls.Add(this.btnRefreshShop);
this.ucGroupBoxEx1.Controls.Add(this.label4);
this.ucGroupBoxEx1.Controls.Add(this.label3);
this.ucGroupBoxEx1.Controls.Add(this.chkOverride);
this.ucGroupBoxEx1.Location = new System.Drawing.Point(3, 2);
this.ucGroupBoxEx1.Name = "ucGroupBoxEx1";
this.ucGroupBoxEx1.Size = new System.Drawing.Size(1114, 118);
@@ -154,6 +164,79 @@ namespace TemuKJD.PDDForms.ProductSelectForms
this.ucGroupBoxEx1.TabStop = false;
this.ucGroupBoxEx1.Text = "操作";
//
// btnStopStop
//
this.btnStopStop.CanvasColor = System.Drawing.SystemColors.Control;
this.btnStopStop.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
this.btnStopStop.DisabledBackColor = System.Drawing.Color.Empty;
this.btnStopStop.Location = new System.Drawing.Point(452, 75);
this.btnStopStop.Name = "btnStopStop";
this.btnStopStop.Size = new System.Drawing.Size(100, 25);
this.btnStopStop.Style.Alignment = System.Drawing.StringAlignment.Center;
this.btnStopStop.Style.BackColor1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(185)))), ((int)(((byte)(215)))), ((int)(((byte)(255)))));
this.btnStopStop.Style.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(185)))), ((int)(((byte)(215)))), ((int)(((byte)(255)))));
this.btnStopStop.Style.Border = DevComponents.DotNetBar.eBorderType.SingleLine;
this.btnStopStop.Style.BorderColor.Color = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
this.btnStopStop.Style.ForeColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelText;
this.btnStopStop.Style.GradientAngle = 90;
this.btnStopStop.StyleMouseDown.Alignment = System.Drawing.StringAlignment.Center;
this.btnStopStop.StyleMouseOver.Alignment = System.Drawing.StringAlignment.Center;
this.btnStopStop.StyleMouseOver.BackColor1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
this.btnStopStop.StyleMouseOver.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
this.btnStopStop.StyleMouseOver.ForeColor.Color = System.Drawing.Color.White;
this.btnStopStop.TabIndex = 814;
this.btnStopStop.Text = "强制解除查询";
this.btnStopStop.Click += new System.EventHandler(this.btnStopStop_Click);
//
// btnSelectSuccess
//
this.btnSelectSuccess.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btnSelectSuccess.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
this.btnSelectSuccess.Cursor = System.Windows.Forms.Cursors.Hand;
this.btnSelectSuccess.DisabledBackColor = System.Drawing.Color.Empty;
this.btnSelectSuccess.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnSelectSuccess.Location = new System.Drawing.Point(716, 75);
this.btnSelectSuccess.Name = "btnSelectSuccess";
this.btnSelectSuccess.Size = new System.Drawing.Size(170, 25);
this.btnSelectSuccess.Style.Alignment = System.Drawing.StringAlignment.Center;
this.btnSelectSuccess.Style.BackColor1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
this.btnSelectSuccess.Style.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
this.btnSelectSuccess.Style.BorderColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBorder;
this.btnSelectSuccess.Style.BorderDashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
this.btnSelectSuccess.Style.BorderSide = DevComponents.DotNetBar.eBorderSide.None;
this.btnSelectSuccess.Style.ForeColor.Color = System.Drawing.Color.White;
this.btnSelectSuccess.Style.GradientAngle = 90;
this.btnSelectSuccess.StyleMouseOver.Alignment = System.Drawing.StringAlignment.Center;
this.btnSelectSuccess.StyleMouseOver.BackColor1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(25)))), ((int)(((byte)(102)))), ((int)(((byte)(255)))));
this.btnSelectSuccess.StyleMouseOver.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(25)))), ((int)(((byte)(102)))), ((int)(((byte)(255)))));
this.btnSelectSuccess.TabIndex = 786;
this.btnSelectSuccess.Text = "一键勾选已采集详情商品";
this.btnSelectSuccess.Click += new System.EventHandler(this.btnSelectSuccess_Click);
//
// btnStop
//
this.btnStop.CanvasColor = System.Drawing.SystemColors.Control;
this.btnStop.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
this.btnStop.DisabledBackColor = System.Drawing.Color.Empty;
this.btnStop.Location = new System.Drawing.Point(343, 75);
this.btnStop.Name = "btnStop";
this.btnStop.Size = new System.Drawing.Size(100, 25);
this.btnStop.Style.Alignment = System.Drawing.StringAlignment.Center;
this.btnStop.Style.BackColor1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(185)))), ((int)(((byte)(215)))), ((int)(((byte)(255)))));
this.btnStop.Style.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(185)))), ((int)(((byte)(215)))), ((int)(((byte)(255)))));
this.btnStop.Style.Border = DevComponents.DotNetBar.eBorderType.SingleLine;
this.btnStop.Style.BorderColor.Color = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
this.btnStop.Style.ForeColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelText;
this.btnStop.Style.GradientAngle = 90;
this.btnStop.StyleMouseDown.Alignment = System.Drawing.StringAlignment.Center;
this.btnStop.StyleMouseOver.Alignment = System.Drawing.StringAlignment.Center;
this.btnStop.StyleMouseOver.BackColor1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
this.btnStop.StyleMouseOver.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
this.btnStop.StyleMouseOver.ForeColor.Color = System.Drawing.Color.White;
this.btnStop.TabIndex = 761;
this.btnStop.Text = "停止当前操作";
this.btnStop.Click += new System.EventHandler(this.btnStop_Click);
//
// txtSearchCount
//
this.txtSearchCount.Location = new System.Drawing.Point(665, 23);
@@ -194,9 +277,9 @@ namespace TemuKJD.PDDForms.ProductSelectForms
this.btnAddToDb.Cursor = System.Windows.Forms.Cursors.Hand;
this.btnAddToDb.DisabledBackColor = System.Drawing.Color.Empty;
this.btnAddToDb.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnAddToDb.Location = new System.Drawing.Point(973, 62);
this.btnAddToDb.Location = new System.Drawing.Point(973, 75);
this.btnAddToDb.Name = "btnAddToDb";
this.btnAddToDb.Size = new System.Drawing.Size(106, 25);
this.btnAddToDb.Size = new System.Drawing.Size(116, 25);
this.btnAddToDb.Style.Alignment = System.Drawing.StringAlignment.Center;
this.btnAddToDb.Style.BackColor1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
this.btnAddToDb.Style.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
@@ -210,6 +293,7 @@ namespace TemuKJD.PDDForms.ProductSelectForms
this.btnAddToDb.StyleMouseOver.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(25)))), ((int)(((byte)(102)))), ((int)(((byte)(255)))));
this.btnAddToDb.TabIndex = 718;
this.btnAddToDb.Text = "机会商品入库";
this.btnAddToDb.Click += new System.EventHandler(this.btnAddToDb_Click);
//
// btnGetDetail
//
@@ -220,7 +304,7 @@ namespace TemuKJD.PDDForms.ProductSelectForms
this.btnGetDetail.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnGetDetail.Location = new System.Drawing.Point(973, 22);
this.btnGetDetail.Name = "btnGetDetail";
this.btnGetDetail.Size = new System.Drawing.Size(106, 25);
this.btnGetDetail.Size = new System.Drawing.Size(116, 25);
this.btnGetDetail.Style.Alignment = System.Drawing.StringAlignment.Center;
this.btnGetDetail.Style.BackColor1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
this.btnGetDetail.Style.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
@@ -234,6 +318,7 @@ namespace TemuKJD.PDDForms.ProductSelectForms
this.btnGetDetail.StyleMouseOver.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(25)))), ((int)(((byte)(102)))), ((int)(((byte)(255)))));
this.btnGetDetail.TabIndex = 683;
this.btnGetDetail.Text = "获取机会商品详情";
this.btnGetDetail.Click += new System.EventHandler(this.btnGetDetail_Click);
//
// txtShopId
//
@@ -404,6 +489,17 @@ namespace TemuKJD.PDDForms.ProductSelectForms
this.label3.TabIndex = 707;
this.label3.Text = "店铺名称:";
//
// chkOverride
//
this.chkOverride.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.chkOverride.AutoSize = true;
this.chkOverride.Location = new System.Drawing.Point(892, 77);
this.chkOverride.Name = "chkOverride";
this.chkOverride.Size = new System.Drawing.Size(87, 21);
this.chkOverride.TabIndex = 757;
this.chkOverride.Text = "覆盖已存在";
this.chkOverride.UseVisualStyleBackColor = true;
//
// splitContainer2
//
this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill;
@@ -578,6 +674,7 @@ namespace TemuKJD.PDDForms.ProductSelectForms
this.pbLoading.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pbLoading.TabIndex = 7;
this.pbLoading.TabStop = false;
this.pbLoading.Visible = false;
//
// panel2
//
@@ -613,8 +710,8 @@ namespace TemuKJD.PDDForms.ProductSelectForms
this.colChanceId,
this.colImgUrl,
this.colImg,
this.colImgType,
this.colGroup,
this.colGoodsName,
this.colHotValue,
this.colCate,
this.colPrice,
this.colMsg});
@@ -625,6 +722,7 @@ namespace TemuKJD.PDDForms.ProductSelectForms
this.dgvChanceProduct.RowTemplate.Height = 23;
this.dgvChanceProduct.Size = new System.Drawing.Size(817, 482);
this.dgvChanceProduct.TabIndex = 6;
this.dgvChanceProduct.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgvChanceProduct_CellContentClick);
//
// colCheck
//
@@ -660,29 +758,32 @@ namespace TemuKJD.PDDForms.ProductSelectForms
this.colImg.Resizable = System.Windows.Forms.DataGridViewTriState.True;
this.colImg.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
//
// colImgType
// colGoodsName
//
this.colImgType.FillWeight = 120F;
this.colImgType.HeaderText = "商品名称";
this.colImgType.Name = "colImgType";
this.colImgType.ReadOnly = true;
dataGridViewCellStyle5.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.colGoodsName.DefaultCellStyle = dataGridViewCellStyle5;
this.colGoodsName.FillWeight = 120F;
this.colGoodsName.HeaderText = "商品名称";
this.colGoodsName.Name = "colGoodsName";
this.colGoodsName.ReadOnly = true;
//
// colGroup
// colHotValue
//
this.colGroup.FillWeight = 60F;
this.colGroup.HeaderText = "热度";
this.colGroup.Name = "colGroup";
this.colGroup.ReadOnly = true;
this.colHotValue.FillWeight = 60F;
this.colHotValue.HeaderText = "热度";
this.colHotValue.Name = "colHotValue";
this.colHotValue.ReadOnly = true;
//
// colCate
//
this.colCate.HeaderText = "类目";
this.colCate.Name = "colCate";
this.colCate.ReadOnly = true;
this.colCate.Visible = false;
//
// colPrice
//
dataGridViewCellStyle6.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.colPrice.DefaultCellStyle = dataGridViewCellStyle6;
this.colPrice.FillWeight = 70F;
this.colPrice.HeaderText = "价格";
this.colPrice.Name = "colPrice";
@@ -690,8 +791,8 @@ namespace TemuKJD.PDDForms.ProductSelectForms
//
// colMsg
//
dataGridViewCellStyle5.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.colMsg.DefaultCellStyle = dataGridViewCellStyle5;
dataGridViewCellStyle7.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.colMsg.DefaultCellStyle = dataGridViewCellStyle7;
this.colMsg.FillWeight = 200F;
this.colMsg.HeaderText = "操作结果";
this.colMsg.Name = "colMsg";
@@ -789,15 +890,6 @@ namespace TemuKJD.PDDForms.ProductSelectForms
private System.Windows.Forms.Label label1;
private DevComponents.DotNetBar.PanelEx btnGetDetail;
private System.Windows.Forms.TextBox txtSearchChance;
private System.Windows.Forms.DataGridViewCheckBoxColumn colCheck;
private System.Windows.Forms.DataGridViewTextBoxColumn colChanceId;
private System.Windows.Forms.DataGridViewTextBoxColumn colImgUrl;
private System.Windows.Forms.DataGridViewImageColumn colImg;
private System.Windows.Forms.DataGridViewTextBoxColumn colImgType;
private System.Windows.Forms.DataGridViewTextBoxColumn colGroup;
private System.Windows.Forms.DataGridViewTextBoxColumn colCate;
private System.Windows.Forms.DataGridViewTextBoxColumn colPrice;
private System.Windows.Forms.DataGridViewTextBoxColumn colMsg;
private DevComponents.DotNetBar.PanelEx btnEmpty;
private System.Windows.Forms.TextBox txtNotes;
private System.Windows.Forms.Label label4;
@@ -820,5 +912,18 @@ namespace TemuKJD.PDDForms.ProductSelectForms
private System.Windows.Forms.DataGridViewTextBoxColumn colMessage;
private System.Windows.Forms.TextBox txtSearchCount;
private System.Windows.Forms.Label label5;
private UserComponent.UcCheckBox chkOverride;
private System.Windows.Forms.DataGridViewCheckBoxColumn colCheck;
private System.Windows.Forms.DataGridViewTextBoxColumn colChanceId;
private System.Windows.Forms.DataGridViewTextBoxColumn colImgUrl;
private System.Windows.Forms.DataGridViewImageColumn colImg;
private System.Windows.Forms.DataGridViewTextBoxColumn colGoodsName;
private System.Windows.Forms.DataGridViewTextBoxColumn colHotValue;
private System.Windows.Forms.DataGridViewTextBoxColumn colCate;
private System.Windows.Forms.DataGridViewTextBoxColumn colPrice;
private System.Windows.Forms.DataGridViewTextBoxColumn colMsg;
private DevComponents.DotNetBar.PanelEx btnStop;
private DevComponents.DotNetBar.PanelEx btnSelectSuccess;
private DevComponents.DotNetBar.PanelEx btnStopStop;
}
}
@@ -1,5 +1,6 @@
using AllBase;
using AllBase.Model.Result;
using AllBase.Model.Result.PDDResult;
using NaiBa.Util;
using NaiBa.Util.Extension;
using Newtonsoft.Json.Linq;
@@ -18,6 +19,7 @@ using TemuKJD.BLL;
using TemuKJD.Extension;
using TemuKJD.PDDForms.AdminForms;
using TemuKJD.PDDForms.ShopForms;
using TemuKJD.ToolForms;
using Work;
namespace TemuKJD.PDDForms.ProductSelectForms
@@ -26,6 +28,7 @@ namespace TemuKJD.PDDForms.ProductSelectForms
{
CheckBox chkSelectAll;
ChanceProductConfig chanceProductConfig;
public CancellationTokenSource cancellationTokenSource { get; set; } = null;
public ConcurrentList<ShopLoginInfo> lstAdminShopInfo { get; set; } = new ConcurrentList<ShopLoginInfo>();
public ConcurrentList<ChanceProductResult> lstChanceProductResult { get; set; } = new ConcurrentList<ChanceProductResult>();
/// <summary>
@@ -106,7 +109,7 @@ namespace TemuKJD.PDDForms.ProductSelectForms
{
List<string> userShopIdList = dgvShop.Rows.Cast<DataGridViewRow>()
.Where(r => r.Cells["colSelect"].Value.ParseToBool())
.Select(r => r.Cells["colShopId"].Value.ParseToString() + r.Cells["colUser"].Value.ParseToString()).ToList();
.Select(r => r.Cells["colShopId"].Value.ParseToString() + r.Cells["colUserName"].Value.ParseToString()).ToList();
if (InvokeRequired)
{
Invoke(new Action(() =>
@@ -122,6 +125,8 @@ namespace TemuKJD.PDDForms.ProductSelectForms
this.dgvShop.Rows.Clear();
lstAdminShopInfo.Clear();
}
if (cancellationTokenSource == null || cancellationTokenSource.IsCancellationRequested)
cancellationTokenSource = new CancellationTokenSource();
Task.Run(() =>
{
int pageCount;
@@ -153,7 +158,7 @@ namespace TemuKJD.PDDForms.ProductSelectForms
{
this.pbShopLoading.Visible = false;
}));
});
}, cancellationTokenSource.Token);
}
void displayShopStatus(ShopLoginInfo shop)
@@ -266,22 +271,27 @@ namespace TemuKJD.PDDForms.ProductSelectForms
private void btnSearch_Click(object sender, EventArgs e)
{
var shopIds = this.dgvShop.Rows.Cast<DataGridViewRow>().Where(r => r.Cells["colSelect"].Value.ParseToBool() == true)
.Select(r => r.Cells["colShopId"].Value.ParseToString()).ToList();
if (shopIds.Count <= 0)
{
BaseMsgForm.ShowError("请选择店铺");
return;
}
dgvChanceProduct.Rows.Clear();
lstChanceProductResult.Clear();
pbLoading.Visible = true;
if (cancellationTokenSource == null || cancellationTokenSource.IsCancellationRequested)
cancellationTokenSource = new CancellationTokenSource();
Task.Run(() =>
{
ShopLoginInfo shop = null;
while (shop == null || shop.LoginStatus != "登录成功")
{
var shopList = lstAdminShopInfo.Where(s => s.LoginStatus == "登录成功").ToList();
if (shopList.Count == 0)
{
BaseMsgForm.ShowError("没有可用的店铺,无法搜索机会商品!");
return;
}
shop = shopList[Randomx.GetId(shopList.Count)];
PDDAdminShopListForm.Instance.CheckShopLogin(new ShopLoginInfo[] { shop }, false);
shop = GetOneShop(shopIds);
if (shop == null)
break;
}
string searchTxt = "";
@@ -309,8 +319,13 @@ namespace TemuKJD.PDDForms.ProductSelectForms
int totalPage = 1;
int getCount = 0;
int total = 2000;
while(getCount < searchCount && getCount < total && page <=totalPage)
while(getCount < searchCount && page <=totalPage)
{
if (shop == null)
break;
if (cancellationTokenSource.IsCancellationRequested)
break;
if ((page - 1) % 10 == 0)
{
PDDShopLoginForm loginForm = null;
@@ -340,24 +355,22 @@ namespace TemuKJD.PDDForms.ProductSelectForms
Thread.Sleep(Randomx.GetId(3000, 8000));
}
var rst = GetChanceGoodsList(shop, searchTxt, searchLabels, page);
var rst = GetChanceGoodsList(shop, searchTxt, searchLabels, "hot_index", page);
if (!rst.Contains("success\":true"))
{
PDDAdminShopListForm.Instance.CheckShopLogin(new ShopLoginInfo[] { shop }, false);
while (shop == null || shop.LoginStatus != "登录成功")
{
var shopList = lstAdminShopInfo.Where(s => s.LoginStatus == "登录成功").ToList();
if (shopList.Count == 0)
shop = GetOneShop(shopIds);
if (cancellationTokenSource.IsCancellationRequested)
{
BaseMsgForm.ShowError("没有可用的店铺,无法搜索机会商品!");
Invoke(new Action(() =>
{
pbLoading.Visible = false;
}));
return;
shop = null;
break;
}
shop = shopList[Randomx.GetId(shopList.Count)];
PDDAdminShopListForm.Instance.CheckShopLogin(new ShopLoginInfo[] { shop }, false);
if (shop == null) break;
}
if (shop == null) break;
continue;
}
@@ -366,8 +379,13 @@ namespace TemuKJD.PDDForms.ProductSelectForms
{
JObject jObj = JObject.Parse(rst);
getResult = JsonHelper.DeserializeJsonToObject<GetChanceProductResult>(JsonHelper.SerializeObject(jObj["result"]));
lstChanceProductResult.AddRange(getResult.list);
foreach (var chanceProd in getResult.list)
{
chanceProd.searchText = searchTxt;
}
getResult.list = getResult.list.Take(searchCount - getCount).ToList();
getCount += getResult.list.Count;
lstChanceProductResult.AddRange(getResult.list.Where(r => !lstChanceProductResult.Any(p => p.chance_id == r.chance_id)));
foreach(var chanceProductResult in getResult.list)
{
Invoke(new Action(() =>
@@ -379,7 +397,8 @@ namespace TemuKJD.PDDForms.ProductSelectForms
DataGridViewExtension.defaultBitmap,
chanceProductResult.keywords,
chanceProductResult.hot_index,
chanceProductResult.cat_id_3.ParseToLong() == 0 ? new long?() : chanceProductResult.cat_id_3.ParseToLong()
chanceProductResult.cat_id_3.ParseToLong() == 0 ? new long?() : chanceProductResult.cat_id_3.ParseToLong(),
"采集详情后显示"
);
dgvChanceProduct.Rows[rowId].Height = 60;
}));
@@ -394,7 +413,6 @@ namespace TemuKJD.PDDForms.ProductSelectForms
}));
return;
}
getCount = lstChanceProductResult.Count;
total = BaseRegex.GetIntJson(ref rst, "total");
totalPage = total / getResult.list.Count;
page++;
@@ -403,14 +421,53 @@ namespace TemuKJD.PDDForms.ProductSelectForms
Invoke(new Action(() =>
{
pbLoading.Visible = false;
BaseMsgForm.ShowInfo("列表获取完毕!");
if (cancellationTokenSource?.IsCancellationRequested == true)
{
BaseMsgForm.ShowInfo("列表获取停止!");
}
else
BaseMsgForm.ShowInfo("列表获取完毕!");
}));
});
}, cancellationTokenSource.Token);
}
private string GetChanceGoodsList(ShopLoginInfo shop, string searchWord, List<string> labels = null, int page = 1)
private void dgvChanceProduct_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
return PDDDBProdUserSelectForm.GetChanceGoodsList(shop, searchWord, labels, page);
if (e.ColumnIndex < 0 || e.RowIndex < 0)
return;
string headerText = dgvChanceProduct.Columns[e.ColumnIndex].HeaderText;
var chanceId = dgvChanceProduct.Rows[e.RowIndex].Cells["colChanceId"].Value.ParseToString();
var chanceProd = lstChanceProductResult.FirstOrDefault(p => p.chance_id == chanceId);
switch (headerText)
{
case "删除":
//if (BaseMsgForm.ShowConfirm("确定删除商品吗?删除后不可恢复!").DialogResult == DialogResult.Cancel)
// return;
//DeleteProduct(dbId);
break;
case "图片":
var imgUrl = dgvChanceProduct.Rows[e.RowIndex].Cells["colImgUrl"].Value.ParseToString().Replace("?imageView2/2/w/90/h/90", "");
Dictionary<string, string> dic = new Dictionary<string, string>();
dic[imgUrl] = imgUrl;
foreach (var imgPath in chanceProd.gallery_img_url_list)
{
dic[imgPath.Replace("https", "http")] = imgPath.Replace("https", "http");
}
ShowImgForm imgFrom = new ShowImgForm(imgUrl, dic);
imgFrom.ShowDialog();
break;
case "":
dgvChanceProduct.Rows[e.RowIndex].Cells["colCheck"].Value = !(bool)dgvChanceProduct.Rows[e.RowIndex].Cells["colCheck"].Value;
break;
default:
break;
}
}
private string GetChanceGoodsList(ShopLoginInfo shop, string searchWord, List<string> labels = null, string desc="", int page = 1)
{
return PDDDBProdUserSelectForm.GetChanceGoodsList(shop, searchWord, labels, desc, page);
}
private void pnlEmpty_Click(object sender, EventArgs e)
@@ -419,6 +476,304 @@ namespace TemuKJD.PDDForms.ProductSelectForms
txtSearchChance.Text = "";
txtSearchCount.Text = "500";
}
private void btnGetDetail_Click(object sender, EventArgs e)
{
var shopIds = this.dgvShop.Rows.Cast<DataGridViewRow>().Where(r => r.Cells["colSelect"].Value.ParseToBool() == true)
.Select(r => r.Cells["colShopId"].Value.ParseToString()).ToList();
if (shopIds.Count <= 0)
{
BaseMsgForm.ShowError("请选择店铺");
return;
}
this.pbLoading.Visible = true;
if (cancellationTokenSource == null || cancellationTokenSource.IsCancellationRequested)
cancellationTokenSource = new CancellationTokenSource();
Dictionary<ShopLoginInfo, int> dicGetId = new Dictionary<ShopLoginInfo, int>();
Task.Run(() => {
ConcurrentList<DataGridViewRow> rowLst = new ConcurrentList<DataGridViewRow>();
rowLst.AddRange(dgvChanceProduct.Rows.Cast<DataGridViewRow>());
ShopLoginInfo shop = null;
int getId = 0;
foreach (DataGridViewRow row in rowLst)
{
if (row.Cells["colCheck"].Value.ParseToBool() != true)
continue;
var chanceId = row.Cells["colChanceId"].Value.ParseToString();
var chanceProd = lstChanceProductResult.FirstOrDefault(c => c.chance_id == chanceId);
if (chanceProd == null || chanceProd.dbProduct != null)
continue;
if (cancellationTokenSource.IsCancellationRequested)
break;
if (getId % 10 == 0)
{
shop = GetOneShop(shopIds);
while (shop == null || shop.LoginStatus != "登录成功")
{
shop = GetOneShop(shopIds);
if (cancellationTokenSource.IsCancellationRequested)
{
shop = null;
break;
}
if (shop == null) break;
}
if (shop == null) break;
PDDShopLoginForm loginForm = null;
Invoke(new Action(() =>
{
this.panel2.SendToBack();
//this.panel2.BringToFront();
loginForm = new PDDShopLoginForm(shop);
loginForm.TopLevel = false;
loginForm.openType = EnumOpenType.manage;
loginForm.WindowState = FormWindowState.Maximized;
loginForm.InitUrl = "https://mms.pinduoduo.com/goods/goods_list/chance?sourcePage=goodsListTopButton";
loginForm.Dock = DockStyle.Fill;
this.panel2.Controls.Add(loginForm);
loginForm.Show();
}));
Thread.Sleep(Randomx.GetId(3000, 5000));
Invoke(new Action(() =>
{
this.panel2.SendToBack();
if (loginForm != null)
loginForm.Close();
}));
}
else
{
Thread.Sleep(Randomx.GetId(1000, 3500));
}
getId++;
var rst = PDDDBProdUserSelectForm.GetChanceGoodsId(shop, chanceProd.searchText, chanceProd.chance_id);
if (rst.Contains("操作太过频繁,请稍后再试!"))
{
Thread.Sleep(Randomx.GetId(10000, 20000));
rst = PDDDBProdUserSelectForm.GetChanceGoodsId(shop, chanceProd.searchText, chanceProd.chance_id);
}
if (!rst.Contains("\"success\":true"))
{
var error = BaseRegex.GetStringJson(ref rst, "error_msg");
if (string.IsNullOrEmpty(error))
error = rst;
Invoke(new Action(() =>
{
chanceProd.getProductMsg = "获取失败 " + error;
row.Cells["colMsg"].Value = chanceProd.getProductMsg;
}));
continue;
}
var commitId = BaseRegex.GetStringJson(ref rst, "draft_id");
var goodsId = BaseRegex.GetLongJson(ref rst, "goods_id");
var catid = chanceProd.cat_id_3.ParseToLong() > 0 ? chanceProd.cat_id_3 : chanceProd.cat_id_2;
rst = new PDDShopBrowserObject().getPDDProductWidthEdit(shop, goodsId.ParseToString(), commitId, catid.ParseToString(), true, true);
if (rst.StartsWith("success"))
{
try
{
var dbProd = JsonHelper.DeserializeJsonToObject<KJDDBProduct>(rst.Substring(7));
chanceProd.dbProduct = dbProd;
Invoke(new Action(() =>
{
chanceProd.getProductMsg = "获取成功";
row.Cells["colMsg"].Value = chanceProd.getProductMsg;
row.Cells["colGoodsName"].Value = dbProd.product_name;
row.Cells["colCate"].Value = dbProd.cat_name;
row.Cells["colPrice"].Value = dbProd.price_text;
}));
}
catch (Exception ex)
{
Invoke(new Action(() =>
{
chanceProd.getProductMsg = "获取失败 " + ex.Message;
row.Cells["colMsg"].Value = chanceProd.getProductMsg;
}));
}
}
else
{
Invoke(new Action(() =>
{
chanceProd.getProductMsg = "获取失败 " + rst;
row.Cells["colMsg"].Value = chanceProd.getProductMsg;
}));
}
}
Invoke(new Action(() =>
{
this.pbLoading.Visible = false;
if (cancellationTokenSource?.IsCancellationRequested == true)
{
BaseMsgForm.ShowInfo("机会商品详情获取停止!");
}
else
BaseMsgForm.ShowInfo("机会商品详情获取完毕!");
}));
});
}
private ShopLoginInfo GetOneShop(List<string> shopIds)
{
try
{
var shopList = lstAdminShopInfo.Where(s => shopIds.Contains(s.ShopId) && s.LoginStatus == "登录成功").ToList();
if (shopList.Count == 0)
{
Invoke(new Action(() =>
{
BaseMsgForm.ShowError("没有可用的店铺,无法搜索机会商品!");
}));
return null;
}
var shop = shopList[Randomx.GetId(shopList.Count)];
PDDAdminShopListForm.Instance.CheckShopLogin(new ShopLoginInfo[] { shop }, false);
return shop;
}
catch (Exception ex)
{
return null;
}
}
private void btnAddToDb_Click(object sender, EventArgs e)
{
ConcurrentList<DataGridViewRow> rowLst = new ConcurrentList<DataGridViewRow>();
rowLst.AddRange(dgvChanceProduct.Rows.Cast<DataGridViewRow>().Where(r => r.Cells["colCheck"].Value.ParseToBool() == true));
this.pbLoading.Visible = true;
Task.Run(() =>
{
foreach (var row in rowLst)
{
var chanceId = row.Cells["colChanceId"].Value.ParseToString();
var chanceProd = lstChanceProductResult.FirstOrDefault(c => c.chance_id == chanceId);
if (chanceProd == null || chanceProd.dbProduct == null)
continue;
var dbProd = chanceProd.dbProduct;
var product = JsonHelper.DeserializeJsonToObject<PDDProductInfo>(dbProd.product_json).detail;
bool isExist = false;
var existUrl = BaseClass.BuildObjString("product/get_product_list");
string existData = UserLogin.GetSignaturex() + "&from_shop_id=" + chanceId;
string html = GetHtml.PostUtf8(existUrl, existData);
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
html = GetHtml.PostUtf8(existUrl, existData);
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
html = GetHtml.PostUtf8(existUrl, existData);
if (!string.IsNullOrEmpty(html) && html.Contains("\"code\":200"))
{
if (html.Contains("\"data\":[") && !html.Contains("\"data\":[]"))
isExist = true;
}
var url = BaseClass.BuildObjString("product/add_product");
if (isExist)
{
if (chkOverride.Checked)
url = BaseClass.BuildObjString("product/mdy_product");
else
{
Invoke(new Action(() =>
{
row.Cells["colMsg"].Value = "已存在相同id商品,跳过";
}));
continue;
}
}
var data = Work.UserLogin.GetSignaturex() +
"&from_shop_id=" + chanceId +
"&spu_id=" + product.goods_id.ParseToString() +
"&skc_id=" + product.goods_id.ParseToString() +
"&price_text=" + product.sku.Min(s => s.multi_price).ParseToInt() * 0.01m + "-" + product.sku.Max(s => s.multi_price).ParseToInt() * 0.01m +
"&main_cat_id=" + (product.cat_ids?.FirstOrDefault(c => c != null)).ParseToString() +
"&main_cat_name=" + HttpUtility.UrlEncode((product.cats?.FirstOrDefault(c => !string.IsNullOrEmpty(c))).ParseToString(), Encoding.UTF8) +
"&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(dbProd.product_json, Encoding.UTF8) +
"&size_json=" + HttpUtility.UrlEncode(dbProd.size_json, Encoding.UTF8) +
"&main_img=" + HttpUtility.UrlEncode(dbProd.main_img, Encoding.UTF8) +
"&product_get_type=" + HttpUtility.UrlEncode("机会商品", 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"))
{
string msg = "商品采集保存失败!请检查网络连接:" + BaseRegex.GetStringJson(ref html, "msg");
Invoke(new Action(() =>
{
row.Cells["colMsg"].Value = msg;
}));
}
else
{
string msg = "商品采集保存成功!";
Invoke(new Action(() =>
{
row.Cells["colMsg"].Value = msg;
}));
}
}
Invoke(new Action(() =>
{
this.pbLoading.Visible = false;
BaseMsgForm.ShowInfo("商品入库完毕!");
}));
});
}
private void btnStop_Click(object sender, EventArgs e)
{
if (cancellationTokenSource != null)
cancellationTokenSource.Cancel();
}
private void btnStopStop_Click(object sender, EventArgs e)
{
if (cancellationTokenSource != null)
cancellationTokenSource.Cancel();
pbLoading.Visible = false;
pbShopLoading.Visible = false;
}
private void btnSelectSuccess_Click(object sender, EventArgs e)
{
foreach (DataGridViewRow row in dgvChanceProduct.Rows)
{
var chanceId = row.Cells["colChanceId"].Value.ParseToString();
var chanceProd = lstChanceProductResult.FirstOrDefault(p => p.chance_id == chanceId);
if (chanceProd != null && chanceProd.dbProduct != null)
{
row.Cells["colCheck"].Value = true;
}
else
{
row.Cells["colCheck"].Value = false;
}
}
}
}
public class ChanceProductConfig
@@ -454,6 +809,12 @@ namespace TemuKJD.PDDForms.ProductSelectForms
public long? cat_id_2 { get; set; } // 8544,
public long? cat_id_3 { get; set; } // 25141
/// <summary>
/// 暂存一下数据库商品格式,以备入库
/// </summary>
public KJDDBProduct dbProduct { get; set; }
public string getProductMsg { get; set; }
public string searchText { get; set; }
}
public class ChanceProductLabelResult
@@ -153,10 +153,10 @@
<metadata name="colImg.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="colImgType.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<metadata name="colGoodsName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="colGroup.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<metadata name="colHotValue.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="colCate.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
@@ -43,7 +43,7 @@ namespace TemuKJD.PDDForms.ShopForms
Task.Run(() =>
{
var msg = getPDDProductWidthEdit(shop, sProdId, "", false, notSaveDb);
var msg = getPDDProductWidthEdit(shop, sProdId);
if (!string.IsNullOrEmpty(msg))
{
if (!msg.StartsWith("success") && !msg.StartsWith("商品采集保存成功"))
@@ -66,7 +66,7 @@ namespace TemuKJD.PDDForms.ShopForms
return "success";
}
public string getPDDProductWidthEdit(ShopLoginInfo shop, string prodId, string commitId = "", bool isChance = false, bool notSaveDb = false)
public string getPDDProductWidthEdit(ShopLoginInfo shop, string prodId, string commitId = "", string catId = "", bool isChance = false, bool notSaveDb = false)
{
try
{
@@ -140,17 +140,17 @@ namespace TemuKJD.PDDForms.ShopForms
}
Thread.Sleep(Randomx.GetId(10, 50));
var property_json = "{}";
var property_template_json = "{}";
PDDProductPropertyInfo property = null;
if (!isChance)
if (!isChance) // 非机会商品编辑可以直接获取属性
{
try
{
var prod_property_rst = GetPddProdProperty(sourceShop, sourceProdId.ToString(), commitId);
prod_property_rst = GetHtml.Unicode2String(prod_property_rst);
JObject prod_property_obj = JObject.Parse(prod_property_rst);
property_json = JsonHelper.SerializeObject(prod_property_obj["result"]);
property = JsonHelper.DeserializeJsonToObject<PDDProductPropertyInfo>(property_json);
property_template_json = JsonHelper.SerializeObject(prod_property_obj["result"]);
property = JsonHelper.DeserializeJsonToObject<PDDProductPropertyInfo>(property_template_json);
}
catch (Exception ex) { }
if (property == null)
@@ -159,22 +159,47 @@ namespace TemuKJD.PDDForms.ShopForms
return "商品获取失败!商品属性获取失败!";
}
}
else
else // 机会商品通过类目id获取属性
{
try
{
var prod_property_rst = get_chance_cat_prop_template(sourceShop, "", sourceProdId.ToString(), commitId);
prod_property_rst = GetHtml.Unicode2String(prod_property_rst);
JObject prod_property_obj = JObject.Parse(prod_property_rst);
property_json = JsonHelper.SerializeObject(prod_property_obj["result"]);
property = JsonHelper.DeserializeJsonToObject<PDDProductPropertyInfo>(property_json);
var prod_property_template_rst = get_chance_cat_prop_template(sourceShop, catId, sourceProdId.ToString(), commitId);
prod_property_template_rst = GetHtml.Unicode2String(prod_property_template_rst);
JObject prod_property_template_obj = JObject.Parse(prod_property_template_rst);
var prod_property_template_json = JsonHelper.SerializeObject(prod_property_template_obj["result"]["modules"][0]);
var temp_module_info = JsonHelper.DeserializeJsonToObject<pdd_module_item>(prod_property_template_json);
property = new PDDProductPropertyInfo() { goods_properties = new List<goods_propertie_item>(), sku_properties = new object() };
foreach (var propInfo in temp_module_info.propertys)
{
if (propInfo.goods_properties != null)
{
goods_propertie_item propParam = new goods_propertie_item() { values = new List<value_item>() };
property.goods_properties.Add(propParam);
propParam.name = propInfo.name_alias;
propParam.ref_pid = propInfo.ref_pid;
foreach (var goodsPropInfo in propInfo.goods_properties)
{
propParam.values.Add(new value_item()
{
raw_value = goodsPropInfo.v_value,
unit = goodsPropInfo.p_unit,
value = goodsPropInfo.v_value,
vid = goodsPropInfo.vid,
});
}
}
}
}
catch (Exception ex) { }
if (property == null)
catch (Exception ex)
{
return "商品获取失败!商品属性获取失败!" + ex.Message;
}
if (property == null || property.goods_properties == null || property.goods_properties.Count == 0)
{
//OnInfoReceived("商品获取失败!商品属性获取失败!");
return "商品获取失败!商品属性获取失败!";
}
property_template_json = JsonHelper.SerializeObject(property);
}
@@ -378,7 +403,7 @@ namespace TemuKJD.PDDForms.ShopForms
}
string product_json = "{\"detail\":" + detail_json + ",\"size\":" + size_json + ",\"decoration\":" + decoration_json +
",\"material3\":" + material3_json + ",\"material1\":" + material1_json + ",\"property\":" + property_json + "}";
",\"material3\":" + material3_json + ",\"material1\":" + material1_json + ",\"property\":" + property_template_json + "}";
if (notSaveDb)
{
@@ -395,6 +420,7 @@ namespace TemuKJD.PDDForms.ShopForms
dbProd.from_shop_id = shop.ShopId;
dbProd.spu_id = product.goods_id.ParseToString();
dbProd.skc_id = product.goods_id.ParseToString();
dbProd.price_text = product.sku.Min(s => s.multi_price).ParseToInt() * 0.01m + "-" + product.sku.Max(s => s.multi_price).ParseToInt() * 0.01m;
dbProd.main_cat_id = (product.cat_ids?.FirstOrDefault(c => c != null)).ParseToString();
dbProd.main_cat_name = (product.cats?.FirstOrDefault(c => !string.IsNullOrEmpty(c))).ParseToString();
dbProd.cat_id = (product.cat_id).ParseToString();
+19 -3
View File
@@ -36,6 +36,7 @@ namespace TemuKJD.ToolForms
this.btnCopy = new DevComponents.DotNetBar.PanelEx();
this.btnCopyUrl = new DevComponents.DotNetBar.PanelEx();
this.btnClose = new DevComponents.DotNetBar.PanelEx();
this.label1 = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
@@ -58,6 +59,7 @@ namespace TemuKJD.ToolForms
//
// splitContainer1.Panel2
//
this.splitContainer1.Panel2.Controls.Add(this.label1);
this.splitContainer1.Panel2.Controls.Add(this.btnSave);
this.splitContainer1.Panel2.Controls.Add(this.btnCopy);
this.splitContainer1.Panel2.Controls.Add(this.btnCopyUrl);
@@ -76,6 +78,7 @@ namespace TemuKJD.ToolForms
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
this.pictureBox1.Click += new System.EventHandler(this.pictureBox1_Click);
//
// btnSave
//
@@ -84,7 +87,7 @@ namespace TemuKJD.ToolForms
this.btnSave.Cursor = System.Windows.Forms.Cursors.Hand;
this.btnSave.DisabledBackColor = System.Drawing.Color.Empty;
this.btnSave.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnSave.Location = new System.Drawing.Point(366, 4);
this.btnSave.Location = new System.Drawing.Point(180, 4);
this.btnSave.Name = "btnSave";
this.btnSave.Size = new System.Drawing.Size(65, 26);
this.btnSave.Style.Alignment = System.Drawing.StringAlignment.Center;
@@ -109,7 +112,7 @@ namespace TemuKJD.ToolForms
this.btnCopy.Cursor = System.Windows.Forms.Cursors.Hand;
this.btnCopy.DisabledBackColor = System.Drawing.Color.Empty;
this.btnCopy.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnCopy.Location = new System.Drawing.Point(295, 4);
this.btnCopy.Location = new System.Drawing.Point(109, 4);
this.btnCopy.Name = "btnCopy";
this.btnCopy.Size = new System.Drawing.Size(65, 26);
this.btnCopy.Style.Alignment = System.Drawing.StringAlignment.Center;
@@ -134,7 +137,7 @@ namespace TemuKJD.ToolForms
this.btnCopyUrl.Cursor = System.Windows.Forms.Cursors.Hand;
this.btnCopyUrl.DisabledBackColor = System.Drawing.Color.Empty;
this.btnCopyUrl.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnCopyUrl.Location = new System.Drawing.Point(194, 4);
this.btnCopyUrl.Location = new System.Drawing.Point(8, 4);
this.btnCopyUrl.Name = "btnCopyUrl";
this.btnCopyUrl.Size = new System.Drawing.Size(94, 26);
this.btnCopyUrl.Style.Alignment = System.Drawing.StringAlignment.Center;
@@ -177,6 +180,16 @@ namespace TemuKJD.ToolForms
this.btnClose.Text = "关闭";
this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(265, 9);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(188, 17);
this.label1.TabIndex = 518;
this.label1.Text = "点击图片或按空格键切换列表图片";
this.label1.Visible = false;
//
// ShowImgForm
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
@@ -189,10 +202,12 @@ namespace TemuKJD.ToolForms
this.ShowMaximizeBox = true;
this.Text = "图片查看";
this.TitleText = "图片查看";
this.Load += new System.EventHandler(this.ShowImgForm_Load);
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ShowImgForm_KeyDown);
this.Controls.SetChildIndex(this.splitContainer1, 0);
this.splitContainer1.Panel1.ResumeLayout(false);
this.splitContainer1.Panel2.ResumeLayout(false);
this.splitContainer1.Panel2.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
this.splitContainer1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
@@ -208,5 +223,6 @@ namespace TemuKJD.ToolForms
private DevComponents.DotNetBar.PanelEx btnCopy;
private DevComponents.DotNetBar.PanelEx btnCopyUrl;
private DevComponents.DotNetBar.PanelEx btnSave;
private System.Windows.Forms.Label label1;
}
}
+59
View File
@@ -52,6 +52,32 @@ namespace TemuKJD.ToolForms
//case Keys.B: MessageBox.Show("您按下的是B"); break;
case Keys.Enter: break;
case Keys.Escape: this.Close(); break;
case Keys.Space:
if (imgDic != null && imgDic.Keys.Count > 0)
{
for (int i = 0; i < imgDic.Keys.ToList().Count; i++)
{
if (imgDic.Keys.ToList()[i] == currentImgUrl)
{
int index = i + 1;
if (index == imgDic.Keys.Count)
index = 0;
currentImgUrl = imgDic.Keys.ToList()[index];
this.pictureBox1.ImageLocation = currentImgUrl.Replace("https", "http");
break;
}
if (imgDic[imgDic.Keys.ToList()[i]] == currentImgUrl)
{
int index = i + 1;
if (index == imgDic.Keys.Count)
index = 0;
currentImgUrl = imgDic[imgDic.Keys.ToList()[index]];
this.pictureBox1.ImageLocation = currentImgUrl.Replace("https", "http");
break;
}
}
}
break;
}
}
@@ -110,5 +136,38 @@ namespace TemuKJD.ToolForms
}
}
}
private void pictureBox1_Click(object sender, EventArgs e)
{
if (imgDic != null && imgDic.Keys.Count > 0)
{
for (int i = 0; i < imgDic.Keys.ToList().Count; i++)
{
if (imgDic.Keys.ToList()[i] == currentImgUrl)
{
int index = i + 1;
if (index == imgDic.Keys.Count)
index = 0;
currentImgUrl = imgDic.Keys.ToList()[index];
this.pictureBox1.ImageLocation = currentImgUrl.Replace("https", "http");
break;
}
if (imgDic[imgDic.Keys.ToList()[i]] == currentImgUrl)
{
int index = i + 1;
if (index == imgDic.Keys.Count)
index = 0;
currentImgUrl = imgDic[imgDic.Keys.ToList()[index]];
this.pictureBox1.ImageLocation = currentImgUrl.Replace("https", "http");
break;
}
}
}
}
private void ShowImgForm_Load(object sender, EventArgs e)
{
label1.Visible = this.imgDic != null && this.imgDic.Keys.Count > 0;
}
}
}