拼多多商品获取逻辑

This commit is contained in:
wule committed 2025-09-11 19:06:16 +08:00
1 parent 840636d5c9
commit 6639224771
68 files changed
+7132 -692

No files matched your search

@@ -7,6 +7,7 @@ using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.Security;
@@ -25,6 +26,7 @@ namespace KJD_Web.BLL.BXX
return "{\"code\":50000,\"msg\":\"校验失败\"}";
string user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
string from_shop_id = RegexUtils.GetStringQuery(ref inputData, "from_shop_id");
string spu_id = RegexUtils.GetStringQuery(ref inputData, "spu_id");
string skc_id = RegexUtils.GetStringQuery(ref inputData, "skc_id");
string cat_id = RegexUtils.GetStringQuery(ref inputData, "cat_id");
@@ -44,28 +46,33 @@ namespace KJD_Web.BLL.BXX
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "";
var json_sign = RegexUtils.GetStringJson(ref product_json, "signedImageUrl"); // 取商品json数据里不同签名的部分
var product_md5 = EncrypUtil.GetMd5(product_json?.Replace(json_sign, "") + size_json);
var product_md5_2 = EncrypUtil.GetMd5(product_json?.Replace("'", "\\'").Replace(json_sign, "") + size_json);
sql = "select id from bxx.third_product where product_md5='" + product_md5 + "' or product_md5='" + product_md5_2 + "';";
var json_ids = RegexUtils.GetMatchRegex(ref product_json, "(\"id\":\\d{8,14})"); // 取商品json数据里不同签名的部分
var product_json_replace = product_json;
foreach (Match json_id in json_ids)
{
product_json_replace = product_json_replace.Replace(json_id.Value, "\"id\":0");
}
var product_md5 = EncrypUtil.GetMd5(product_json_replace + size_json);
sql = "select id from bxx.third_product where product_md5='" + product_md5 + "';";
var rst = mySql.ExecuteFirstInt(sql).ParseToLong();
if (rst <= 0)
{
//sql = "insert into bxx.third_product (spu_id,skc_id,cat_id,cat_name,product_name,ext_code,main_img,product_json,size_json,notes,product_md5,add_time,mdy_time) " +
// "values ('" + spu_id + "','" + skc_id + "','" + cat_id + "','" + cat_name + "','" + product_name + "','" +
//sql = "insert into bxx.third_product (from_shop_id,spu_id,skc_id,cat_id,cat_name,product_name,ext_code,main_img,product_json,size_json,notes,product_md5,add_time,mdy_time) " +
// "values ('" + from_shop_id + "','" + spu_id + "','" + skc_id + "','" + cat_id + "','" + cat_name + "','" + product_name + "','" +
// ext_code + "','" + main_img + "','" + product_json + "','" + size_json + "','" + notes + "','" + product_md5 + "','" +
// DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','" +
// DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "');";
//rst = mySql.ExecuteInsertId(sql);
sql = "insert into bxx.third_product (spu_id,skc_id,cat_id,cat_name,product_name," +
sql = "insert into bxx.third_product (from_shop_id,spu_id,skc_id,cat_id,cat_name,product_name," +
"ext_code,main_img,product_json,size_json,notes,product_md5,add_time,mdy_time) " +
"values (@spu_id,@skc_id,@cat_id,@cat_name,@product_name," +
"values (@from_shop_id,@spu_id,@skc_id,@cat_id,@cat_name,@product_name," +
"@ext_code,@main_img,@product_json,@size_json,@notes,@product_md5," +
"@add_time,@mdy_time);";
string add_time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
string mdy_time = add_time;
List<MySqlParameter> paramLst = new List<MySqlParameter>();
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@from_shop_id", Value = from_shop_id, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@spu_id", Value = spu_id, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@skc_id", Value = skc_id, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@cat_id", Value = cat_id, });
@@ -105,6 +112,7 @@ namespace KJD_Web.BLL.BXX
var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name")?.Replace("'","\\'");
var password = RegexUtils.GetStringQuery(ref inputData, "password")?.Replace("'", "\\'");
var from_shop_id = RegexUtils.GetStringQuery(ref inputData, "from_shop_id")?.Replace("'", "\\'");
var search_spu = RegexUtils.GetStringQuery(ref inputData, "search_spu")?.Replace("'", "\\'");
var search_skc = RegexUtils.GetStringQuery(ref inputData, "search_skc")?.Replace("'", "\\'");
var search_cat = RegexUtils.GetStringQuery(ref inputData, "search_cat")?.Replace("'", "\\'");
@@ -150,7 +158,7 @@ namespace KJD_Web.BLL.BXX
if (isDetail)
sql = "select * from bxx.third_product where 1=1";
else
sql = "select id,spu_id,skc_id,cat_id,cat_name,change_cat_id,change_cat_name,ext_code,product_name,main_img,notes," +
sql = "select id,from_shop_id,spu_id,skc_id,cat_id,cat_name,change_cat_id,change_cat_name,ext_code,product_name,main_img,notes," +
"add_time,mdy_time from bxx.third_product where 1=1";
sql += where;
@@ -171,6 +179,7 @@ namespace KJD_Web.BLL.BXX
DBProductResultParam prod = new DBProductResultParam
{
id = Convert.ToInt32(row["id"]),
from_shop_id = row["from_shop_id"].ToString(),
skc_id = row["skc_id"].ToString(),
spu_id = row["spu_id"].ToString(),
cat_id = row["cat_id"].ToString(),
@@ -361,7 +370,7 @@ namespace KJD_Web.BLL.BXX
{
add_product_remaining = add_product_remaining - 1;
sql += "\r\n";
sql += "update bxx.shop set add_product_remaining=" + add_product_remaining + " where shop_id=" + shop_id + ";";
sql += "update bxx.shop set add_product_remaining=" + add_product_remaining + " where shop_id='" + shop_id + "';";
//sql += "update bxx.shop_add_prod_count set add_product_remaining=" + add_product_remaining + " where shop_id=" + shop_id + ";";
sql += "INSERT INTO bxx.shop_add_prod_count(shop_id, add_product_remaining) VALUES('" + shop_id + "'," + add_product_remaining + ")" +
"ON DUPLICATE KEY UPDATE add_product_remaining=VALUES(add_product_remaining)";
@@ -558,7 +567,7 @@ namespace KJD_Web.BLL.BXX
sql = "select s.id,s.out_product_id,s.shop_id,s.shop_account,s.user_name," +
"s.sub_user_name,s.notes,s.user_notes,s.status,s.draft_id,s.add_times,s.add_time,s.mdy_time," +
"s.fission_product_name,s.operate_sub_sa_name,s.add_sub_sa_time," +
"p.spu_id,p.skc_id,p.cat_id,p.cat_name,p.change_cat_id,p.change_cat_name,p.ext_code,p.product_name,p.main_img," +
"p.from_shop_id,p.spu_id,p.skc_id,p.cat_id,p.cat_name,p.change_cat_id,p.change_cat_name,p.ext_code,p.product_name,p.main_img," +
"u.nick_name as operate_sub_sa_nick " +
"from bxx.third_product_select s left join bxx.third_product p on s.out_product_id=p.id " +
"left join bxx.user u on u.user_name=s.operate_sub_sa_name " +
@@ -606,6 +615,7 @@ namespace KJD_Web.BLL.BXX
operate_sub_sa_nick = row["operate_sub_sa_nick"].ToString(),
fission_product_name = row["fission_product_name"].ToString(),
user_notes = row["user_notes"].ToString(),
from_shop_id = row["from_shop_id"].ToString(),
//product_json = row["product_json"].ToString(),
//size_json = row["size_json"].ToString(),
};