书籍类目采集和入库

This commit is contained in:
wule committed 2026-01-17 22:47:41 +08:00
1 parent 6ce238ca01
commit dbc954a200
19 files changed
+664 -1205

No files matched your search

@@ -42,6 +42,10 @@ namespace KJD_Web.BLL.BXX
string product_get_type = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "product_get_type"))?.Replace("'", "\\'");
string sale_count = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sale_count"))?.Replace("'", "\\'");
string sale_count_text = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sale_count_text"))?.Replace("'", "\\'");
string special_prod_type = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "special_prod_type"))?.Replace("'", "\\'");
if (special_prod_type == null)
special_prod_type = "普通商品";
if (string.IsNullOrEmpty(product_get_type))
{
product_get_type = "母店采集";
@@ -55,13 +59,14 @@ namespace KJD_Web.BLL.BXX
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "";
//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,product_get_type,sale_count,sale_count_text,add_time,mdy_time) " +
sql = "insert into ";
sql += "bxx.product ";
sql +="(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_get_type,sale_count,sale_count_text,special_prod_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_get_type + "','" + sale_count + "','" + sale_count_text + "','" +
special_prod_type + "','" +
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','" +
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "');";
var rst = mySql.ExecuteNonQuery(sql);
@@ -107,6 +112,7 @@ namespace KJD_Web.BLL.BXX
string sale_count = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sale_count"))?.Replace("'", "\\'");
string sale_count_text = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sale_count_text"))?.Replace("'", "\\'");
string wx_safe_status = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "wx_safe_status"))?.Replace("'", "\\'");
string special_prod_type = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "special_prod_type"))?.Replace("'", "\\'");
if (string.IsNullOrEmpty(user_name))
{
@@ -150,6 +156,8 @@ namespace KJD_Web.BLL.BXX
sql += " p.sale_count_text='" + sale_count_text + "',";
if (wx_safe_status != null)
sql += " p.wx_safe_status='" + wx_safe_status + "',";
if (special_prod_type != null && special_prod_type != "")
sql += " p.special_prod_type='" + special_prod_type + "',";
sql += " p.mdy_time='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',";
sql = sql.TrimEnd(',');
sql += " where spu_id='" + spu_id + "';";
@@ -169,6 +177,7 @@ namespace KJD_Web.BLL.BXX
public string GetProductList(string inputData, bool isDetail = false)
{
var timeCalc = DateTime.Now;
if (!string.IsNullOrEmpty(inputData))
{
var time = RegexUtils.GetStringQuery(ref inputData, "time").ParseToInt();
@@ -192,6 +201,7 @@ namespace KJD_Web.BLL.BXX
var product_get_type = RegexUtils.GetStringQuery(ref inputData, "product_get_type")?.Replace("'", "\\'");
var sort_field = RegexUtils.GetStringQuery(ref inputData, "sort_field")?.Replace("'", "\\'");
var wx_safe_status = RegexUtils.GetStringQuery(ref inputData, "wx_safe_status")?.Replace("'", "\\'");
var special_prod_type = RegexUtils.GetStringQuery(ref inputData, "special_prod_type")?.Replace("'", "\\'");
int page = RegexUtils.GetStringQuery(ref inputData, "page").ParseToInt();
int page_size= RegexUtils.GetStringQuery(ref inputData, "page_size").ParseToInt(50);
@@ -202,6 +212,17 @@ namespace KJD_Web.BLL.BXX
string sql = "select count(id) from bxx.product p where p.is_del=0";
string where = "";
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 + ")";
if (!string.IsNullOrEmpty(product_get_type))
where += " and p.product_get_type ='" + product_get_type + "'";
if (!string.IsNullOrEmpty(wx_safe_status))
where += " and p.wx_safe_status ='" + wx_safe_status + "'";
if (!string.IsNullOrEmpty(special_prod_type))
where += " and p.special_prod_type ='" + special_prod_type + "'";
if (!string.IsNullOrWhiteSpace(search_spu))
where += " and p.spu_id like '%" + search_spu + "%'";
if (!string.IsNullOrWhiteSpace(search_skc))
@@ -216,14 +237,6 @@ 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(product_get_type))
where += " and p.product_get_type ='" + product_get_type + "'";
if (!string.IsNullOrEmpty(wx_safe_status))
where += " and p.wx_safe_status ='" + wx_safe_status + "'";
if (!string.IsNullOrEmpty(search_db_ids))
where += " and p.id in (" + search_db_ids + ")";
sql += where;
var count = mySql.ExecuteRowCount(sql);
@@ -243,7 +256,7 @@ namespace KJD_Web.BLL.BXX
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,p.product_get_type,p.wx_safe_status," +
" p.sale_count,p.sale_count_text,s.img_url,e.ext_code_price" +
" p.sale_count,p.sale_count_text,p.special_prod_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" +
@@ -251,7 +264,7 @@ namespace KJD_Web.BLL.BXX
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,p.product_get_type,p.wx_safe_status," +
" p.sale_count,p.sale_count_text,s.img_url,COUNT(se.id) AS select_count," +
" p.sale_count,p.sale_count_text,p.special_prod_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" +
@@ -307,6 +320,7 @@ namespace KJD_Web.BLL.BXX
sale_count = row["sale_count"].ParseToInt(),
sale_count_text = row["sale_count_text"].ToString(),
wx_safe_status = row["wx_safe_status"].ToString(),
special_prod_type = row["special_prod_type"].ToString(),
};
if (isDetail)
{
@@ -323,7 +337,8 @@ namespace KJD_Web.BLL.BXX
productLst.Add(prod);
}
var data = JsonUtils.SerializerObjectToString(productLst);
return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"count\":" + count + "}";
var seconds = (DateTime.Now - timeCalc).TotalSeconds.ToString("0.000");
return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"count\":" + count + ",\"seconds\":" + seconds + "}";
}
catch (Exception ex)
{
@@ -545,6 +560,7 @@ namespace KJD_Web.BLL.BXX
/// <returns></returns>
public string GetProductListRandom(string inputData)
{
var timeCalc = DateTime.Now;
if (!string.IsNullOrEmpty(inputData))
{
var time = RegexUtils.GetStringQuery(ref inputData, "time").ParseToInt();
@@ -560,6 +576,7 @@ namespace KJD_Web.BLL.BXX
var in_cates = RegexUtils.GetStringQuery(ref inputData, "in_cates")?.Replace("'", "\\'");
var product_get_type = RegexUtils.GetStringQuery(ref inputData, "product_get_type")?.Replace("'", "\\'");
var wx_safe_status = RegexUtils.GetStringQuery(ref inputData, "wx_safe_status")?.Replace("'", "\\'");
var special_prod_type = RegexUtils.GetStringQuery(ref inputData, "special_prod_type")?.Replace("'", "\\'");
int page = RegexUtils.GetStringQuery(ref inputData, "page").ParseToInt();
int page_size = RegexUtils.GetStringQuery(ref inputData, "page_size").ParseToInt(50);
@@ -594,6 +611,8 @@ namespace KJD_Web.BLL.BXX
where += " and p.product_get_type ='" + product_get_type + "'";
if (!string.IsNullOrEmpty(wx_safe_status))
where += " and p.wx_safe_status ='" + wx_safe_status + "'";
if (!string.IsNullOrEmpty(special_prod_type))
where += " and p.special_prod_type ='" + special_prod_type + "'";
sql += where;
@@ -608,7 +627,7 @@ namespace KJD_Web.BLL.BXX
{
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.group,p.notes,p.add_time,p.mdy_time,p.select_total_count,p.product_get_type,p.sale_count,p.sale_count_text," +
"p.fission_words,p.head_words,p.end_words,p.wx_safe_status from bxx.product p where p.is_del=0";
"p.fission_words,p.head_words,p.end_words,p.wx_safe_status,p.special_prod_type from bxx.product p where p.is_del=0";
//where子句
sql += where;
@@ -654,11 +673,13 @@ namespace KJD_Web.BLL.BXX
sale_count = row["sale_count"].ParseToInt(),
sale_count_text = row["sale_count_text"].ToString(),
wx_safe_status = row["wx_safe_status"].ToString(),
special_prod_type = row["special_prod_type"].ToString(),
};
productLst.Add(prod);
}
var data = JsonUtils.SerializerObjectToString(productLst);
return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"count\":" + count + "}";
var seconds = (DateTime.Now - timeCalc).TotalSeconds.ToString("0.000");
return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"count\":" + count + ",\"seconds\":" + seconds + "}";
}
catch (Exception ex)
{
@@ -870,6 +891,7 @@ namespace KJD_Web.BLL.BXX
string end_words = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "end_words"))?.Replace("'", "\\'");
string sku_edit_json = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sku_edit_json"))?.Replace("'", "\\'");
string wx_safe_status = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "wx_safe_status"))?.Replace("'", "\\'");
string special_prod_type = RegexUtils.GetStringQuery(ref inputData, "special_prod_type")?.Replace("'", "\\'");
if (string.IsNullOrEmpty(user_name))
{
@@ -897,6 +919,8 @@ namespace KJD_Web.BLL.BXX
sql += " p.sku_edit_json='" + sku_edit_json + "',";
if (wx_safe_status != null)
sql += " p.wx_safe_status='" + wx_safe_status + "',";
if (special_prod_type != null && special_prod_type != "")
sql += " p.special_prod_type='" + special_prod_type + "',";
sql = sql.TrimEnd(',');
if (in_db_ids != null)
{
@@ -970,33 +970,32 @@ namespace KJD_Web.BLL
if (search_year >= 2026)
tableName += "_" + search_year;
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," +
"u.nick_name as operate_sub_sa_nick " +
"FROM " + tableName + " s LEFT JOIN kjd.third_product p ON s.out_product_id=p.id " +
"LEFT JOIN kjd.user u ON u.user_name=s.operate_sub_sa_name " +
"WHERE 1=1";
sql += where; // where子句
sql += " order by s.add_time desc";
sql += " limit " + Math.Max(page - 1, 0) * page_size + "," + page_size;
//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," +
// "u.nick_name as operate_sub_sa_nick " +
// "FROM " + tableName + " s LEFT JOIN kjd.third_product p ON s.out_product_id=p.id " +
// "LEFT JOIN kjd.user u ON u.user_name=s.operate_sub_sa_name " +
// "WHERE 1=1";
//sql += where; // where子句
//sql += " order by s.add_time desc";
//sql += " limit " + Math.Max(page - 1, 0) * page_size + "," + page_size;
//--------------------------------------------------------------------------------------------------------
sql = "SELECT s1.id,s1.out_product_id,s1.shop_id,s1.shop_account,s1.user_name," +
"s1.sub_user_name,s1.notes,s1.user_notes,s1.status,s1.draft_id,s1.add_times,s1.add_time,s1.mdy_time," +
"s1.fission_product_name,s1.operate_sub_sa_name,s1.add_sub_sa_time," +
"s2.spu_id,s2.skc_id,s2.cat_id,s2.cat_name,s2.change_cat_id,s2.change_cat_name,s2.ext_code,s2.product_name,s2.main_img ";
if (operate_sub_sa_name != null || 1 == 2)
if (operate_sub_sa_name != null || 1 == 1)
sql += ",s2.operate_sub_sa_nick";
sql += " FROM " + tableName + " s1";
// 子查询
sql += " JOIN (SELECT s.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 ";
if (operate_sub_sa_name != null || 1 == 2)
if (operate_sub_sa_name != null || 1 == 1)
sql += ",u.nick_name as operate_sub_sa_nick ";
sql += " FROM " + tableName + " s LEFT JOIN kjd.third_product p ON s.out_product_id=p.id ";
if (operate_sub_sa_name != null || 1 == 2)
if (operate_sub_sa_name != null || 1 == 1)
sql += "LEFT JOIN kjd.user u ON u.user_name=s.operate_sub_sa_name ";
sql += "WHERE 1=1";
sql += where; // where子句
@@ -1077,7 +1076,7 @@ namespace KJD_Web.BLL
//product_json = row["product_json"].ToString(),
//size_json = row["size_json"].ToString(),
};
if (operate_sub_sa_name != null || 1 == 2)
if (operate_sub_sa_name != null || 1 == 1)
{
prodSelect.operate_sub_sa_nick = row["operate_sub_sa_nick"].ToString();
}
@@ -76,5 +76,6 @@ namespace KJD_Web.Model
public int sale_count { get; set; }
public string sale_count_text { get; set; }
public string wx_safe_status { get; set; }
public string special_prod_type { get; set; }
}
}