421 lines
22 KiB
C#
421 lines
22 KiB
C#
using KJD_Web.Model;
|
||
using KJD_Web.Model.ShopModel;
|
||
using KJD_Web.Utils;
|
||
using MySql.Data.MySqlClient;
|
||
using NaiBa.Util.Extension;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Data;
|
||
using System.Linq;
|
||
using System.Web;
|
||
using System.Web.Security;
|
||
|
||
namespace KJD_Web.BLL.WXXD
|
||
{
|
||
public class WXProductManage
|
||
{
|
||
public string WXGetPDDProductList(string inputData, bool isDetail = false)
|
||
{
|
||
return new BLL.BXX.BXXProductManage().GetProductList(inputData, isDetail);
|
||
|
||
//if (!string.IsNullOrEmpty(inputData))
|
||
//{
|
||
// var time = RegexUtils.GetStringQuery(ref inputData, "time").ParseToInt();
|
||
// string time1 = RegexUtils.GetStringQuery(ref inputData, "code");
|
||
// if (time1 != EncrypUtil.Encryption(time))
|
||
// return "{\"code\":50000,\"msg\":\"校验失败\"}";
|
||
|
||
// var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name")?.Replace("'","\\'");
|
||
// var password = RegexUtils.GetStringQuery(ref inputData, "password")?.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("'", "\\'");
|
||
// var search_ext_code = RegexUtils.GetStringQuery(ref inputData, "search_ext_code")?.Replace("'", "\\'");
|
||
// var search_prod_name = RegexUtils.GetStringQuery(ref inputData, "search_prod_name")?.Replace("'", "\\'");
|
||
// var search_group = RegexUtils.GetStringQuery(ref inputData, "search_group")?.Replace("'", "\\'");
|
||
// var search_notes = RegexUtils.GetStringQuery(ref inputData, "search_notes")?.Replace("'", "\\'");
|
||
// 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();
|
||
// int page_size= RegexUtils.GetStringQuery(ref inputData, "page_size").ParseToInt(50);
|
||
|
||
// string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
||
// MysqlUtils mySql = new MysqlUtils(conn);
|
||
|
||
// string sql = "select count(id) from bxx.product p where p.is_del=0";
|
||
|
||
// string where = "";
|
||
// if (!string.IsNullOrWhiteSpace(search_spu))
|
||
// where += " and p.spu_id like '%" + search_spu + "%'";
|
||
// if (!string.IsNullOrWhiteSpace(search_skc))
|
||
// where += " and p.skc_id like '%" + search_skc + "%'";
|
||
// if (!string.IsNullOrWhiteSpace(search_cat))
|
||
// where += " and p.cat_name like '%" + search_cat + "%'";
|
||
// if (!string.IsNullOrWhiteSpace(search_ext_code))
|
||
// where += " and p.ext_code like '%" + search_ext_code + "%'";
|
||
// if (!string.IsNullOrWhiteSpace(search_prod_name))
|
||
// where += " and p.product_name like '%" + search_prod_name + "%'";
|
||
// if (!string.IsNullOrWhiteSpace(search_group))
|
||
// 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;
|
||
|
||
// var count = mySql.ExecuteRowCount(sql);
|
||
|
||
// DataTable dt;
|
||
// if (count == 0)
|
||
// {
|
||
// dt = new DataTable();
|
||
// }
|
||
// else
|
||
// {
|
||
// if (isDetail)
|
||
// sql = "select p.*,s.img_base64,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 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,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,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" +
|
||
// " WHERE p.is_del=0";
|
||
|
||
// //where子句
|
||
// sql += where;
|
||
|
||
// if (!isDetail && !string.IsNullOrEmpty(get_select_count))
|
||
// sql += " group by p.id";
|
||
// if (sort_field == "select_total_count")
|
||
// sql += " order by p.select_total_count desc, p.id desc";
|
||
// else
|
||
// sql += " order by p.id desc";
|
||
// sql += " limit " + Math.Max(page - 1, 0) * page_size + "," + page_size;
|
||
// dt = mySql.ExecuteDataTable(sql);
|
||
// }
|
||
|
||
// mySql.Close();
|
||
// if (dt != null)
|
||
// {
|
||
// try
|
||
// {
|
||
// List<DBProductResultParam> productLst = new List<DBProductResultParam>();
|
||
// foreach (DataRow row in dt.Rows)
|
||
// {
|
||
// 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(),
|
||
// cat_name = row["cat_name"].ToString(),
|
||
// product_name = row["product_name"].ToString(),
|
||
// main_img = row["main_img"].ToString(),
|
||
// ext_code = row["ext_code"].ToString(),
|
||
// ext_code_price = row["ext_code_price"].IsNullOrEmpty() ? new int?() : row["ext_code_price"].ParseToInt(),
|
||
// price_text = row["price_text"].ToString(),
|
||
// //product_json = row["product_json"].ToString(),
|
||
// //size_json = row["size_json"].ToString(),
|
||
// add_time = Convert.ToDateTime(row["add_time"]),
|
||
// mdy_time = Convert.ToDateTime(row["mdy_time"]),
|
||
// notes = row["notes"].ToString(),
|
||
// group = row["group"].ToString(),
|
||
// select_total_count = row["select_total_count"].ParseToInt(),
|
||
// end_words = row["end_words"].ParseToString(),
|
||
// fission_words = row["fission_words"].ParseToString(),
|
||
// 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)
|
||
// {
|
||
// prod.product_json = row["product_json"].ToString();
|
||
// prod.size_json = row["size_json"].ToString();
|
||
// prod.sku_edit_json = row["sku_edit_json"].ToString();
|
||
// prod.sku_img_replace_base64 = row["img_base64"].ToString();
|
||
// //prod.sku_img_replace_url = row["img_url"].ToString();
|
||
// }
|
||
// if (!string.IsNullOrEmpty(get_select_count))
|
||
// {
|
||
// prod.select_count = row["select_count"].ParseToInt();
|
||
// }
|
||
// productLst.Add(prod);
|
||
// }
|
||
// var data = JsonUtils.SerializerObjectToString(productLst);
|
||
// return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"count\":" + count + "}";
|
||
// }
|
||
// catch (Exception ex)
|
||
// {
|
||
// return "{\"code\":500,\"msg\":\"" + ex.Message + "\",\"data\":[],\"count\":" + 0 + "}";
|
||
// }
|
||
// }
|
||
// else
|
||
// {
|
||
// return "{\"code\":500,\"msg\":\"" + mySql.Message + "\",\"data\":[],\"count\":" + 0 + "}";
|
||
// }
|
||
//}
|
||
//return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
||
}
|
||
|
||
public string WXGetPDDProductGroups(string inputData)
|
||
{
|
||
if (!string.IsNullOrEmpty(inputData))
|
||
{
|
||
var time = RegexUtils.GetStringQuery(ref inputData, "time").ParseToInt();
|
||
string time1 = RegexUtils.GetStringQuery(ref inputData, "code");
|
||
if (time1 != EncrypUtil.Encryption(time))
|
||
return "{\"code\":50000,\"msg\":\"校验失败\"}";
|
||
|
||
var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name")?.Replace("'", "\\'");
|
||
if (string.IsNullOrEmpty(user_name))
|
||
{
|
||
return "{\"code\":50001,\"msg\":\"没有用户名\"}";
|
||
}
|
||
|
||
int page = RegexUtils.GetStringQuery(ref inputData, "page").ParseToInt();
|
||
int page_size = RegexUtils.GetStringQuery(ref inputData, "page_size").ParseToInt(50);
|
||
|
||
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
||
MysqlUtils mySql = new MysqlUtils(conn);
|
||
|
||
string sql = "SELECT DISTINCT p.group FROM `bxx`.`product` p where p.is_del=0";
|
||
|
||
string where = "";
|
||
sql += where;
|
||
|
||
var dt = mySql.ExecuteDataTable(sql);
|
||
mySql.Close();
|
||
|
||
if (dt != null)
|
||
{
|
||
try
|
||
{
|
||
string group_data = "";
|
||
foreach (DataRow row in dt.Rows)
|
||
{
|
||
group_data += row["group"].ToString() + ",";
|
||
}
|
||
var data = group_data.Trim(',');
|
||
return "{\"code\":200,\"msg\":\"success\",\"data\":\"" + data + "\"}";
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
return "{\"code\":50002,\"msg\":\"" + ex.Message + "\",\"data\":\"\"}";
|
||
}
|
||
}
|
||
else
|
||
{
|
||
return "{\"code\":50003,\"msg\":\"" + mySql.Message + "\",\"data\":\"\"}";
|
||
}
|
||
}
|
||
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
||
}
|
||
|
||
public string WXGetPDDProductCates(string inputData)
|
||
{
|
||
if (!string.IsNullOrEmpty(inputData))
|
||
{
|
||
var time = RegexUtils.GetStringQuery(ref inputData, "time").ParseToInt();
|
||
string time1 = RegexUtils.GetStringQuery(ref inputData, "code");
|
||
if (time1 != EncrypUtil.Encryption(time))
|
||
return "{\"code\":50000,\"msg\":\"校验失败\"}";
|
||
|
||
var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name")?.Replace("'", "\\'");
|
||
if (string.IsNullOrEmpty(user_name))
|
||
{
|
||
return "{\"code\":50001,\"msg\":\"没有用户名\"}";
|
||
}
|
||
|
||
int page = RegexUtils.GetStringQuery(ref inputData, "page").ParseToInt();
|
||
int page_size = RegexUtils.GetStringQuery(ref inputData, "page_size").ParseToInt(50);
|
||
|
||
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
||
MysqlUtils mySql = new MysqlUtils(conn);
|
||
|
||
string sql = "SELECT DISTINCT p.cat_name FROM `bxx`.`product` p where p.is_del=0";
|
||
|
||
string where = "";
|
||
sql += where;
|
||
|
||
var dt = mySql.ExecuteDataTable(sql);
|
||
mySql.Close();
|
||
|
||
if (dt != null)
|
||
{
|
||
try
|
||
{
|
||
string group_data = "";
|
||
foreach (DataRow row in dt.Rows)
|
||
{
|
||
group_data += row["cat_name"].ToString() + ",";
|
||
}
|
||
var data = group_data.Trim(',');
|
||
return "{\"code\":200,\"msg\":\"success\",\"data\":\"" + data + "\"}";
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
return "{\"code\":50002,\"msg\":\"" + ex.Message + "\",\"data\":\"\"}";
|
||
}
|
||
}
|
||
else
|
||
{
|
||
return "{\"code\":50003,\"msg\":\"" + mySql.Message + "\",\"data\":\"\"}";
|
||
}
|
||
}
|
||
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
||
}
|
||
|
||
/// <summary>
|
||
/// 随机获取商品(无详情) 随机添加到上传列表所以不需要获取详情
|
||
/// </summary>
|
||
/// <param name="inputData"></param>
|
||
/// <returns></returns>
|
||
public string WXGetPDDProductListRandom(string inputData)
|
||
{
|
||
return new BXX.BXXProductManage().GetProductListRandom(inputData);
|
||
/*
|
||
if (!string.IsNullOrEmpty(inputData))
|
||
{
|
||
var time = RegexUtils.GetStringQuery(ref inputData, "time").ParseToInt();
|
||
string time1 = RegexUtils.GetStringQuery(ref inputData, "code");
|
||
if (time1 != EncrypUtil.Encryption(time))
|
||
return "{\"code\":50000,\"msg\":\"校验失败\"}";
|
||
|
||
var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name")?.Replace("'", "\\'");
|
||
var password = RegexUtils.GetStringQuery(ref inputData, "password")?.Replace("'", "\\'");
|
||
var in_ext_codes = RegexUtils.GetStringQuery(ref inputData, "in_ext_codes")?.Replace("'", "\\'");
|
||
var in_skc_ids = RegexUtils.GetStringQuery(ref inputData, "in_skc_ids")?.Replace("'", "\\'");
|
||
var in_groups = RegexUtils.GetStringQuery(ref inputData, "in_groups")?.Replace("'", "\\'");
|
||
var in_cates = RegexUtils.GetStringQuery(ref inputData, "in_cates")?.Replace("'", "\\'");
|
||
|
||
int page = RegexUtils.GetStringQuery(ref inputData, "page").ParseToInt();
|
||
int page_size = RegexUtils.GetStringQuery(ref inputData, "page_size").ParseToInt(50);
|
||
|
||
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
||
MysqlUtils mySql = new MysqlUtils(conn);
|
||
|
||
string sql = "select count(id) from bxx.product p where p.is_del=0";
|
||
|
||
string where = "";
|
||
if (!string.IsNullOrEmpty(in_ext_codes))
|
||
{
|
||
in_ext_codes = "'" + string.Join("','", in_ext_codes.Split(new string[] { ",", ",", " " }, StringSplitOptions.RemoveEmptyEntries)) + "'";
|
||
where += " and p.ext_code in (" + in_ext_codes + ")";
|
||
}
|
||
if (!string.IsNullOrEmpty(in_skc_ids))
|
||
{
|
||
in_skc_ids = "'" + string.Join("','", in_skc_ids.Split(new string[] { ",", ",", " " }, StringSplitOptions.RemoveEmptyEntries)) + "'";
|
||
where += " and p.skc_id in (" + in_skc_ids + ")";
|
||
}
|
||
if (!string.IsNullOrEmpty(in_groups))
|
||
{
|
||
in_groups = "'" + string.Join("','", in_groups.Split(new string[] { ",", ",", " " }, StringSplitOptions.RemoveEmptyEntries)) + "'";
|
||
where += " and p.group in (" + in_groups + ")";
|
||
}
|
||
if (!string.IsNullOrEmpty(in_cates))
|
||
{
|
||
in_cates = "'" + string.Join("','", in_cates.Split(new string[] { ",", ",", " " }, StringSplitOptions.RemoveEmptyEntries)) + "'";
|
||
where += " and (p.cat_name in (" + in_cates + ") or p.main_cat_name in (" + in_cates + "))";
|
||
}
|
||
|
||
sql += where;
|
||
|
||
var count = mySql.ExecuteRowCount(sql);
|
||
|
||
DataTable dt;
|
||
if (count == 0)
|
||
{
|
||
dt = new DataTable();
|
||
}
|
||
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.group,p.notes,p.add_time,p.mdy_time,p.select_total_count," +
|
||
"p.fission_words,p.head_words,p.end_words from bxx.product p where p.is_del=0";
|
||
|
||
//where子句
|
||
sql += where;
|
||
|
||
sql += " ORDER BY RAND()";
|
||
sql += " limit " + Math.Max(page - 1, 0) * page_size + "," + page_size;
|
||
dt = mySql.ExecuteDataTable(sql);
|
||
}
|
||
|
||
mySql.Close();
|
||
if (dt != null)
|
||
{
|
||
try
|
||
{
|
||
List<DBProductResultParam> productLst = new List<DBProductResultParam>();
|
||
foreach (DataRow row in dt.Rows)
|
||
{
|
||
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(),
|
||
cat_name = row["cat_name"].ToString(),
|
||
main_cat_id = row["main_cat_id"].ToString(),
|
||
main_cat_name = row["main_cat_name"].ToString(),
|
||
price_text = row["price_text"].ToString(),
|
||
product_name = row["product_name"].ToString(),
|
||
main_img = row["main_img"].ToString(),
|
||
ext_code = row["ext_code"].ToString(),
|
||
//product_json = row["product_json"].ToString(),
|
||
//size_json = row["size_json"].ToString(),
|
||
add_time = Convert.ToDateTime(row["add_time"]),
|
||
mdy_time = Convert.ToDateTime(row["mdy_time"]),
|
||
group = row["group"].ToString(),
|
||
notes = row["notes"].ToString(),
|
||
select_total_count = row["select_total_count"].ParseToInt(),
|
||
end_words = row["end_words"].ParseToString(),
|
||
fission_words = row["fission_words"].ParseToString(),
|
||
head_words = row["head_words"].ParseToString(),
|
||
};
|
||
productLst.Add(prod);
|
||
}
|
||
var data = JsonUtils.SerializerObjectToString(productLst);
|
||
return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"count\":" + count + "}";
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
return "{\"code\":500,\"msg\":\"" + ex.Message + "\",\"data\":[],\"count\":" + 0 + "}";
|
||
}
|
||
}
|
||
else
|
||
{
|
||
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\",\"data\":[],\"count\":" + 0 + "}";
|
||
}
|
||
}
|
||
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
||
*/
|
||
}
|
||
|
||
public String WXMdyPDDProduct(string inputData)
|
||
{
|
||
return new BXX.BXXProductManage().MdyProduct(inputData);
|
||
}
|
||
|
||
}
|
||
} |