优化商品查询功能

This commit is contained in:
wule committed 2026-09-04 15:02:08 +08:00
1 parent e4a38ce1f7
commit 1514916d69
3 files changed
+59 -9

No files matched your search

+57 -8
View File
@@ -72,6 +72,8 @@ namespace KJD_Web.BLL.BXX
string product_get_type = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "product_get_type"))?.Replace("'", "\\'");
int? sale_count = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sale_count"))?.ParseToNullableInt();
string sale_count_text = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sale_count_text"))?.Replace("'", "\\'");
if (sale_count_text != null && sale_count == 0)
sale_count = sale_count_text.ParseToInt();
string distribution_set = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "distribution_set"))?.Replace("'", "\\'");
string add_user_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "add_user_name"))?.Replace("'", "\\'");
string special_prod_type = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "special_prod_type"))?.Replace("'", "\\'");
@@ -142,6 +144,8 @@ namespace KJD_Web.BLL.BXX
if (sale_count != null)
{
sql += "sale_count,";
if (int.TryParse(sale_count.ParseToString(), out _))
sql += "sale_count_num,";
}
sql += "sale_count_text,special_prod_type,";
sql += "distribution_set,ban_wx,ban_pdd,add_time,mdy_time,";
@@ -159,6 +163,8 @@ namespace KJD_Web.BLL.BXX
if (sale_count != null)
{
sql += "'" + sale_count + "',";
if (int.TryParse(sale_count.ParseToString(), out _))
sql += "" + sale_count + ",";
}
sql += "'" + sale_count_text + "','" + special_prod_type + "'," + distribution_set.ParseToInt() + "," + ban_wx + "," + ban_pdd + ",";
sql += "'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',";
@@ -243,6 +249,8 @@ namespace KJD_Web.BLL.BXX
string view_uv = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "view_uv"))?.Replace("'", "\\'"); // 产品曝光数量
string product_get_type = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "product_get_type"))?.Replace("'", "\\'");
string add_hot_version = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "add_hot_version"))?.Replace("'", "\\'");
string sale_count_num = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sale_count_num"))?.Replace("'", "\\'");
string mdy_time = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "mdy_time"))?.Replace("'", "\\'");
if (special_prod_type == "爆款数据" && product_get_type == "微信店采" && add_hot_version != "v3")
{
return "{\"code\":666,\"msg\":\"当前版本已失效,请更新软件\"}";
@@ -294,10 +302,20 @@ namespace KJD_Web.BLL.BXX
sql += " p.group='" + group + "',";
if (notes != null)
sql += " p.notes='" + notes + "',";
if (sale_count_num != null)
{
sql += " p.sale_count_num=" + sale_count_num + ",";
}
if (sale_count != null)
{
sql += " p.sale_count='" + sale_count + "',";
if (sale_count_num == null && int.TryParse(sale_count.ParseToString(), out _))
sql += " p.sale_count_num=" + sale_count + ",";
}
if (sale_count_text != null)
{
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 != "")
@@ -330,7 +348,10 @@ namespace KJD_Web.BLL.BXX
sql += " p.is_relation=" + is_relation + ",";
if (!string.IsNullOrWhiteSpace(view_uv))
sql += " p.view_uv=" + view_uv + ",";
sql += " p.mdy_time='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',";
if (mdy_time != null)
sql += " p.mdy_time='" + mdy_time + "',";
else
sql += " p.mdy_time='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',";
sql = sql.TrimEnd(',');
sql += " where spu_id='" + spu_id + "';";
@@ -648,6 +669,8 @@ namespace KJD_Web.BLL.BXX
var is_not_count = RegexUtils.GetStringQuery(ref inputData, "is_not_count") == "true"; // 不计数
var no_fission_words = RegexUtils.GetStringQuery(ref inputData, "no_fission_words").ParseToBool(); // 未裂变标题
var fission_words = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "fission_words"))?.Replace("'", "\\'");
var sale_count_num_less = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sale_count_num_less"))?.Replace("'", "\\'");
var sale_count_num_more = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sale_count_num_more"))?.Replace("'", "\\'");
int page = RegexUtils.GetStringQuery(ref inputData, "page").ParseToInt();
int page_size = RegexUtils.GetStringQuery(ref inputData, "page_size").ParseToInt(50);
@@ -684,6 +707,8 @@ namespace KJD_Web.BLL.BXX
forceIndex.Add("index_notes");
if (!start_time.IsNullOrEmpty())
forceIndex.Add("index_mdy_time");
if (!sale_count_num_less.IsNullOrEmpty() || !sale_count_num_more.IsNullOrEmpty())
forceIndex.Add("index_sale_count_num");
if (!forceIndex.Contains("index_view_uv"))
forceIndex.Add("index_sort_add_time");
@@ -869,6 +894,14 @@ namespace KJD_Web.BLL.BXX
{
where += " and fission_words LIKE '" + fission_words + "%'";
}
if (!string.IsNullOrEmpty(sale_count_num_less))
{
where += " and p.sale_count_num<=" + sale_count_num_less;
}
if (!string.IsNullOrEmpty(sale_count_num_more))
{
where += " and p.sale_count_num>=" + sale_count_num_more;
}
sql += where;
var count = 0;
@@ -922,7 +955,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.fission_words,p.head_words,p.end_words,p.group," +
" p.product_get_type,p.wx_safe_status,p.sale_count,p.sale_count_text,p.special_prod_type,p.from_shop_name,p.wx_cat_1,p.wx_cat_2,p.wx_cat_3," +
" p.product_get_type,p.wx_safe_status,p.sale_count_num,p.sale_count,p.sale_count_text,p.special_prod_type,p.from_shop_name,p.wx_cat_1,p.wx_cat_2,p.wx_cat_3," +
" p.wx_cat_leaf,p.send_to_out_server,p.secret_spu_id,p.real_coid,p.real_spu_id,p.is_relation,p.view_uv,p.add_user_name" +
" FROM " + tableName + " p" +
" WHERE p.is_del=0";
@@ -972,6 +1005,7 @@ namespace KJD_Web.BLL.BXX
product_get_type_text = row["product_get_type"].ToString(),
view_uv = row["view_uv"].ParseToNullableInt(),
sale_count = row["sale_count"].ParseToInt(),
sale_count_num = row["sale_count_num"].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(),
@@ -983,6 +1017,7 @@ namespace KJD_Web.BLL.BXX
real_spu_id = row["real_spu_id"].IsNullOrEmpty() ? null : row["real_spu_id"].ParseToString(),
is_relation = row["is_relation"].ParseToInt(),
add_user_name = row["add_user_name"].ParseToString(),
};
if (isDetail)
{
@@ -2027,6 +2062,7 @@ namespace KJD_Web.BLL.BXX
var is_not_count = RegexUtils.GetStringQuery(ref inputData, "is_not_count") == "true"; // 不计数
var prod_count = RegexUtils.GetStringQuery(ref inputData, "prod_count").ParseToInt();
var add_days_less = RegexUtils.GetStringQuery(ref inputData, "add_days_less").ParseToNullableInt();
var add_days_less_type = RegexUtils.GetStringQuery(ref inputData, "add_days_less_type")?.Replace("'", "\\'");
var has_wx_format = RegexUtils.GetStringQuery(ref inputData, "has_wx_format")?.Replace("'", "\\'");
var is_relation = RegexUtils.GetStringQuery(ref inputData, "is_relation").ParseToNullableInt();
var ban_wx = RegexUtils.GetStringQuery(ref inputData, "ban_wx")?.Replace("'", "\\'");
@@ -2041,6 +2077,8 @@ namespace KJD_Web.BLL.BXX
min_view_uv = 100;
if (is学员数据)
min_view_uv = null;
var sale_count_num_less = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sale_count_num_less"))?.Replace("'", "\\'");
var sale_count_num_more = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sale_count_num_more"))?.Replace("'", "\\'");
int page = RegexUtils.GetStringQuery(ref inputData, "page").ParseToInt();
int page_size = RegexUtils.GetStringQuery(ref inputData, "page_size").ParseToInt(50);
@@ -2138,13 +2176,16 @@ namespace KJD_Web.BLL.BXX
{
where += " AND send_to_out_server IN (0,1,127) and distribution_set IN (0,1,2,127)";
}
//if (!add_days_less.IsNullOrZero())
//{
// where += " and add_time > '" + DateTime.Now.AddDays(-add_days_less.ParseToInt()).ToString("yyyy-MM-dd") + "'";
//}
if (!add_days_less.IsNullOrZero())
{
where += " and mdy_time > '" + DateTime.Now.AddDays(-add_days_less.ParseToInt()).ToString("yyyy-MM-dd") + "'";
if (add_days_less_type == "mdy")
{
where += " and mdy_time > '" + DateTime.Now.AddDays(-add_days_less.ParseToInt()).ToString("yyyy-MM-dd") + "'";
}
else
{
where += " and add_time > '" + DateTime.Now.AddDays(-add_days_less.ParseToInt()).ToString("yyyy-MM-dd") + "'";
}
}
if (!has_wx_format.IsNullOrEmpty())
{
@@ -2185,7 +2226,15 @@ namespace KJD_Web.BLL.BXX
}
if (min_view_uv > 0)
{
where += " and view_uv >= " + min_view_uv + "";
where += " and view_uv>= " + min_view_uv + "";
}
if (!string.IsNullOrEmpty(sale_count_num_less))
{
where += " and p.sale_count_num<=" + sale_count_num_less;
}
if (!string.IsNullOrEmpty(sale_count_num_more))
{
where += " and p.sale_count_num>=" + sale_count_num_more;
}
sql += where;
@@ -96,6 +96,7 @@ namespace KJD_Web.Model
public int? view_uv { get; set; }
public int sale_count { get; set; }
public int sale_count_num { get; set; }
public string sale_count_text { get; set; }
public string wx_safe_status { get; set; }
public string special_prod_type { get; set; }
@@ -9,7 +9,7 @@ namespace KJD_Web.Model.WxModel
{
public long id { get; set; }
/// <summary>
/// 变动类型,1:充值,2:采购花费,3:产品退款到账,4:运费退款到账,5:采购收款,6:产品退款扣除,7:运费退款扣除,16:礼物单话费,20:中转运费,23:作废运费返还
/// 变动类型,1:充值,2:采购花费,3:产品退款到账,4:运费退款到账,5:采购收款,6:产品退款扣除,7:运费退款扣除,16:礼物单花费,20:中转运费,23:作废运费返还
/// </summary>
public int? type { get; set; }