752 lines
41 KiB
C#
752 lines
41 KiB
C#
using StoreHub.KJDWebService.Models;
|
|
using StoreHub.Framework.Repositorys;
|
|
using Microsoft.Extensions.Configuration;
|
|
using StoreHub.KJDWebService.Commons;
|
|
using MySql.Data.MySqlClient;
|
|
using NaiBa.Util.Extension;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text.RegularExpressions;
|
|
|
|
namespace StoreHub.KJDWebService.Services
|
|
{
|
|
public class BXXProductThirdService : ServiceBase
|
|
{
|
|
public BXXProductThirdService(SqlRepository sqlRepository, IConfiguration configuration) : base(sqlRepository, configuration)
|
|
{
|
|
}
|
|
public string AddProduct(string inputData)
|
|
{
|
|
if (!string.IsNullOrEmpty(inputData))
|
|
{
|
|
var time = 0;
|
|
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "time"), out time);
|
|
string time1 = RegexUtils.GetStringQuery(ref inputData, "code");
|
|
if (time1 != EncrypUtil.Encryption(time))
|
|
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");
|
|
string cat_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "cat_name"));
|
|
string ext_code = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "ext_code"));
|
|
string product_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "product_name"));
|
|
string product_json = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "product_json"));
|
|
string size_json = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "size_json"));
|
|
string main_img = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "main_img"));
|
|
string notes = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "notes"));
|
|
|
|
if (string.IsNullOrEmpty(user_name))
|
|
{
|
|
return "{\"code\":500,\"msg\":\"没有用户名\"}";
|
|
}
|
|
|
|
string conn = "ConnKJD";
|
|
MysqlUtils mySql = new MysqlUtils(conn);
|
|
string sql = "";
|
|
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 (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 (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," +
|
|
"@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, });
|
|
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@cat_name", Value = cat_name, });
|
|
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@product_name", Value = product_name, });
|
|
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@ext_code", Value = ext_code, });
|
|
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@main_img", Value = main_img, });
|
|
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@product_json", Value = product_json, });
|
|
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@size_json", Value = size_json, });
|
|
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@notes", Value = notes.ParseToString(), });
|
|
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@product_md5", Value = product_md5, });
|
|
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@add_time", Value = add_time, });
|
|
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@mdy_time", Value = mdy_time, });
|
|
rst = mySql.ExecuteInsertId(sql, paramLst.ToArray());
|
|
mySql.Close();
|
|
}
|
|
if (rst > 0)
|
|
{
|
|
return "{\"code\":200,\"msg\":\"success\",\"id\":" + rst + "}";
|
|
}
|
|
else
|
|
{
|
|
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}";
|
|
}
|
|
}
|
|
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
|
}
|
|
|
|
public string GetProductList(string inputData, bool isDetail = false)
|
|
{
|
|
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 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("'", "\\'");
|
|
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_notes = RegexUtils.GetStringQuery(ref inputData, "search_notes")?.Replace("'", "\\'");
|
|
var search_db_ids = RegexUtils.GetStringQuery(ref inputData, "search_db_ids")?.Replace("'", "\\'");
|
|
|
|
int page = RegexUtils.GetStringQuery(ref inputData, "page").ParseToInt();
|
|
int page_size= RegexUtils.GetStringQuery(ref inputData, "page_size").ParseToInt(50);
|
|
|
|
string conn = "ConnKJD";
|
|
MysqlUtils mySql = new MysqlUtils(conn);
|
|
|
|
string sql = "select count(id) from bxx.third_product where 1=1";
|
|
|
|
string where = "";
|
|
if (!string.IsNullOrWhiteSpace(search_spu))
|
|
where += " and spu_id like '%" + search_spu + "%'";
|
|
if (!string.IsNullOrWhiteSpace(search_skc))
|
|
where += " and skc_id like '%" + search_skc + "%'";
|
|
if (!string.IsNullOrWhiteSpace(search_cat))
|
|
where += " and cat_name like '%" + search_cat + "%'";
|
|
if (!string.IsNullOrWhiteSpace(search_ext_code))
|
|
where += " and ext_code like '%" + search_ext_code + "%'";
|
|
if (!string.IsNullOrWhiteSpace(search_prod_name))
|
|
where += " and product_name like '%" + search_prod_name + "%'";
|
|
if (!string.IsNullOrWhiteSpace(search_notes))
|
|
where += " and notes like '%" + search_notes + "%'";
|
|
if (!string.IsNullOrEmpty(search_db_ids))
|
|
where += " and 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 * from bxx.third_product where 1=1";
|
|
else
|
|
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;
|
|
|
|
sql += " order by 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(),
|
|
change_cat_id = row["change_cat_id"].ToString(),
|
|
change_cat_name = row["change_cat_name"].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"]),
|
|
notes = row["notes"].ToString(),
|
|
};
|
|
if (isDetail)
|
|
{
|
|
prod.product_json = row["product_json"].ToString();
|
|
prod.size_json = row["size_json"].ToString();
|
|
}
|
|
productLst.Add(prod);
|
|
}
|
|
var data = JsonUtils.SerializeObjectToString(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 DelDbProd(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("'", "\\'");
|
|
var id = RegexUtils.GetStringQuery(ref inputData, "db_id")?.Replace("'", "\\'");
|
|
|
|
string conn = "ConnKJD";
|
|
MysqlUtils mySql = new MysqlUtils(conn);
|
|
string sql = "delete from bxx.third_product where id='"
|
|
+ id + "'";
|
|
|
|
var rst = mySql.ExecuteNonQuery(sql);
|
|
mySql.Close();
|
|
if (rst)
|
|
{
|
|
return "{\"code\":200,\"msg\":\"success\"}";
|
|
}
|
|
else
|
|
return "{\"code\":500,\"msg\":\"删除失败:" + mySql.Message + "\"}";
|
|
}
|
|
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
|
}
|
|
|
|
public string MdyProductCategory(string inputData, bool isAdmin = false)
|
|
{
|
|
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 id = RegexUtils.GetStringQuery(ref inputData, "db_id")?.Replace("'", "\\'");
|
|
string change_cat_id = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "change_cat_id"))?.Replace("'", "\\'");
|
|
string change_cat_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "change_cat_name"))?.Replace("'", "\\'");
|
|
|
|
if (string.IsNullOrEmpty(user_name))
|
|
{
|
|
return "{\"code\":500,\"msg\":\"没有用户名\"}";
|
|
}
|
|
|
|
string conn = "ConnKJD";
|
|
MysqlUtils mySql = new MysqlUtils(conn);
|
|
string sql = "update bxx.third_product set";
|
|
if (change_cat_id != null)
|
|
sql += " change_cat_id='" + change_cat_id + "',";
|
|
if (change_cat_name != null)
|
|
sql += " change_cat_name='" + change_cat_name + "',";
|
|
sql = sql.TrimEnd(',');
|
|
sql += " where id=" + id + ";";
|
|
|
|
var rst = mySql.ExecuteNonQuery(sql);
|
|
mySql.Close();
|
|
if (rst)
|
|
{
|
|
return "{\"code\":200,\"msg\":\"success\"}";
|
|
}
|
|
else
|
|
{
|
|
return "{\"code\":500,\"msg\":\"更新失败:" + mySql.Message + "\"}";
|
|
}
|
|
}
|
|
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
|
}
|
|
|
|
|
|
public string AddUserSelectProduct(string inputData, bool isAdmin = false)
|
|
{
|
|
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 out_product_Id = RegexUtils.GetStringQuery(ref inputData, "out_product_id")?.Replace("'", "\\'");
|
|
var shop_id = RegexUtils.GetStringQuery(ref inputData, "shop_id")?.Replace("'", "\\'");
|
|
var shop_account = RegexUtils.GetStringQuery(ref inputData, "shop_account")?.Replace("'", "\\'");
|
|
var user_name = RegexUtils.GetStringQuery(ref inputData, "main_user_name")?.Replace("'", "\\'");
|
|
var sub_user_name = RegexUtils.GetStringQuery(ref inputData, "sub_user_name")?.Replace("'", "\\'");
|
|
var notes = RegexUtils.GetStringQuery(ref inputData, "notes")?.Replace("'", "\\'");
|
|
var status = RegexUtils.GetStringQuery(ref inputData, "status")?.Replace("'", "\\'");
|
|
var add_product_remaining = RegexUtils.GetStringQuery(ref inputData, "add_product_remaining").ParseToInt();
|
|
|
|
if (string.IsNullOrEmpty(user_name))
|
|
{
|
|
return "{\"code\":500,\"msg\":\"没有用户名\"}";
|
|
}
|
|
if (string.IsNullOrEmpty(shop_id))
|
|
{
|
|
return "{\"code\":500,\"msg\":\"没有店铺信息\"}";
|
|
}
|
|
|
|
|
|
string conn = "ConnKJD";
|
|
MysqlUtils mySql = new MysqlUtils(conn);
|
|
string sql = "insert into bxx.third_product_select (out_product_Id,shop_id,shop_account,user_name,sub_user_name,notes,status,add_time,mdy_time) " +
|
|
"values ('" + out_product_Id + "','" + shop_id + "','" + shop_account + "','" + user_name + "','" + sub_user_name + "','" +
|
|
notes + "','" + status + "','" +
|
|
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','" +
|
|
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "');";
|
|
if (add_product_remaining > 0)
|
|
{
|
|
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_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)";
|
|
}
|
|
var rst = mySql.ExecuteNonQuery(sql);
|
|
mySql.Close();
|
|
if (rst)
|
|
{
|
|
return "{\"code\":200,\"msg\":\"success\"}";
|
|
}
|
|
else
|
|
{
|
|
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}";
|
|
}
|
|
}
|
|
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
|
}
|
|
|
|
public string MdyUserSelectProductStatus(string inputData, bool isAdmin = false)
|
|
{
|
|
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 id = RegexUtils.GetStringQuery(ref inputData, "db_id")?.Replace("'", "\\'");
|
|
var draft_id = RegexUtils.GetStringQuery(ref inputData, "draft_id")?.Replace("'", "\\'");
|
|
var up_spu_id = RegexUtils.GetStringQuery(ref inputData, "up_spu_id")?.Replace("'", "\\'");
|
|
var shop_id = RegexUtils.GetStringQuery(ref inputData, "shop_id")?.Replace("'", "\\'");
|
|
var status = RegexUtils.GetStringQuery(ref inputData, "status")?.Replace("'", "\\'");
|
|
var add_times = RegexUtils.GetStringQuery(ref inputData, "add_times")?.Replace("'", "\\'");
|
|
|
|
long l_draft_id = draft_id.ParseToLong();
|
|
long l_spu_map_table_id = l_draft_id % 128;
|
|
long l_select_map_table_id = id.ParseToLong() % 64;
|
|
|
|
string conn = "ConnKJD";
|
|
MysqlUtils mySql = new MysqlUtils(conn);
|
|
string sql = "";
|
|
// 使用事务一次提交多个sql操作
|
|
//sql += "set @@autocommit=0;\r\n";
|
|
sql += "START TRANSACTION;\r\n";
|
|
if (!string.IsNullOrEmpty(up_spu_id) && !string.IsNullOrEmpty(draft_id))
|
|
{
|
|
sql += "insert into kjd_map.spu_map_" + l_spu_map_table_id +
|
|
" (draft_id,from_spu_id,shop_id) values(" + draft_id + "," + up_spu_id + ",'" + shop_id + "');\r\n";
|
|
sql += "insert into kjd_map.product_third_select_map_" + l_select_map_table_id +
|
|
" (product_id,product_select_db_id,shop_id) values(" + draft_id + "," + id + ",'" + shop_id + "');\r\n";
|
|
}
|
|
sql += "update bxx.third_product_select set";
|
|
if (draft_id != null)
|
|
sql += " draft_id='" + draft_id + "',";
|
|
if (status != null)
|
|
sql += " status='" + status + "',";
|
|
if (status == "已上传")
|
|
sql += " add_times=add_times+1,";
|
|
sql += " mdy_time='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',";
|
|
sql = sql.TrimEnd(',');
|
|
sql += " where id=" + id + ";\r\n";
|
|
var rst = mySql.ExecuteNonQuery(sql);
|
|
string errMsg = mySql.Message;
|
|
if (string.IsNullOrEmpty(errMsg))
|
|
sql = "COMMIT;";
|
|
else
|
|
sql = "ROLLBACK;";
|
|
mySql.ExecuteNonQuery(sql);
|
|
mySql.Close();
|
|
if (rst)
|
|
{
|
|
return "{\"code\":200,\"msg\":\"success\"}";
|
|
}
|
|
else
|
|
{
|
|
return "{\"code\":500,\"msg\":\"" + errMsg + "\"}";
|
|
}
|
|
}
|
|
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
|
}
|
|
|
|
public string GetUserSelectProductList(string inputData, bool isAdmin = false)
|
|
{
|
|
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\":500,\"msg\":\"没有用户名\"}";
|
|
}
|
|
|
|
var shop_ids = RegexUtils.GetStringQuery(ref inputData, "shop_ids")?.Replace("'", "\\'");
|
|
var search_shop_id = RegexUtils.GetStringQuery(ref inputData, "search_shop_id")?.Replace("'", "\\'");
|
|
var search_shop_account = RegexUtils.GetStringQuery(ref inputData, "search_shop_account");
|
|
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");
|
|
var search_notes = RegexUtils.GetStringQuery(ref inputData, "search_notes")?.Replace("'", "\\'");
|
|
var search_user_notes = RegexUtils.GetStringQuery(ref inputData, "search_user_notes")?.Replace("'", "\\'");
|
|
var search_db_ids = RegexUtils.GetStringQuery(ref inputData, "search_db_ids")?.Replace("'", "\\'");
|
|
var search_sub_sa_name = RegexUtils.GetStringQuery(ref inputData, "search_sub_sa_name")?.Replace("'", "\\'");
|
|
var status = RegexUtils.GetStringQuery(ref inputData, "status")?.Replace("'", "\\'");
|
|
var operate_sub_sa_name = RegexUtils.GetStringQuery(ref inputData, "operate_sub_sa_name")?.Replace("'", "\\'");
|
|
|
|
var no_sub_sa = RegexUtils.GetStringQuery(ref inputData, "no_sub_sa")?.Replace("'", "\\'");
|
|
|
|
int page = RegexUtils.GetStringQuery(ref inputData, "page").ParseToInt();
|
|
int page_size = RegexUtils.GetStringQuery(ref inputData, "page_size").ParseToInt(50);
|
|
|
|
string conn = "ConnKJD";
|
|
MysqlUtils mySql = new MysqlUtils(conn);
|
|
|
|
string sql = "select count(s.id) 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 s.operate_sub_sa_name=u.user_name " +
|
|
"where 1=1";
|
|
|
|
string where = "";
|
|
if (!isAdmin)
|
|
where += " and (s.user_name='" + user_name + "' or s.sub_user_name like'%" + user_name + "%')";
|
|
if (!string.IsNullOrEmpty(operate_sub_sa_name))
|
|
{
|
|
where += " and s.operate_sub_sa_name = '" + operate_sub_sa_name + "'";
|
|
}
|
|
if (no_sub_sa == "true")
|
|
where += " and s.operate_sub_sa_name is null";
|
|
if (!string.IsNullOrEmpty(search_db_ids))
|
|
where += " and s.id in (" + search_db_ids + ")";
|
|
if (!string.IsNullOrEmpty(shop_ids))
|
|
where += " and s.shop_id in (" + shop_ids + ")";
|
|
if (!string.IsNullOrWhiteSpace(status))
|
|
where += " and s.status = '" + status + "'";
|
|
if (!string.IsNullOrWhiteSpace(search_shop_id))
|
|
where += " and s.shop_id like '%" + search_shop_id + "%'";
|
|
if (!string.IsNullOrWhiteSpace(search_shop_account))
|
|
where += " and s.shop_account like @search_shop_account";
|
|
if (!string.IsNullOrWhiteSpace(search_notes))
|
|
{
|
|
//核价成功 重复 核价成功(重复)
|
|
if (search_notes == "无备注")
|
|
where += " and s.notes = ''";
|
|
else if (search_notes == "重复")
|
|
where += " and s.notes like '%重复%' and s.notes not like '%核价成功%' and s.notes not like '%核价通过%'";
|
|
else if (search_notes == "核价成功")
|
|
where += " and (s.notes like '%核价成功%' or s.notes like '%核价通过%') and s.notes not like '%重复%'";
|
|
else if (search_notes == "核价成功(重复)")
|
|
where += " and (s.notes like '%核价成功%' or s.notes like '%核价通过%') and s.notes like '%重复%'";
|
|
else
|
|
where += " and s.notes like '%" + search_notes + "%'";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(search_user_notes))
|
|
where += " and s.user_notes like '%" + search_user_notes + "%'";
|
|
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.IsNullOrEmpty(search_sub_sa_name))
|
|
{
|
|
where += " and (s.operate_sub_sa_name like '%" + search_sub_sa_name + "%'";
|
|
where += " or u.nick_name like '%" + operate_sub_sa_name + "%')";
|
|
}
|
|
|
|
sql += where;
|
|
|
|
List<MySqlParameter> paramLst = new List<MySqlParameter>();
|
|
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@search_shop_account", Value = "%" + search_shop_account + "%", });
|
|
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@search_prod_name", Value = "%" + search_prod_name + "%", });
|
|
|
|
var count = mySql.ExecuteRowCount(sql, paramLst.ToArray());
|
|
|
|
DataTable dt;
|
|
if (count == 0)
|
|
{
|
|
dt = new DataTable();
|
|
}
|
|
else
|
|
{
|
|
//if (isDetail)
|
|
//sql = "select * from bxx.third_product_select where 1=1";
|
|
//else
|
|
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.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 " +
|
|
"where 1=1";
|
|
|
|
sql += where; // where子句
|
|
|
|
sql += " order by id desc";
|
|
sql += " limit " + Math.Max(page - 1, 0) * page_size + "," + page_size;
|
|
dt = mySql.ExecuteDataTable(sql, paramLst.ToArray());
|
|
}
|
|
|
|
mySql.Close();
|
|
if (dt != null)
|
|
{
|
|
try
|
|
{
|
|
List<ProductSelectResultParam> productLst = new List<ProductSelectResultParam>();
|
|
foreach (DataRow row in dt.Rows)
|
|
{
|
|
ProductSelectResultParam prodSelect = new ProductSelectResultParam()
|
|
{
|
|
id = row["id"].ParseToInt(),
|
|
out_product_Id = row["out_product_Id"].ParseToString(),
|
|
shop_account = row["shop_account"].ParseToString(),
|
|
shop_id = row["shop_id"].ParseToString(),
|
|
status = row["status"].ParseToString(),
|
|
sub_user_name = row["sub_user_name"].ParseToString(),
|
|
user_name = row["user_name"].ParseToString(),
|
|
cat_id = row["cat_id"].ParseToString(),
|
|
cat_name = row["cat_name"].ParseToString(),
|
|
change_cat_id = row["change_cat_id"].ParseToString(),
|
|
change_cat_name = row["change_cat_name"].ParseToString(),
|
|
product_name = row["product_name"].ParseToString(),
|
|
main_img = row["main_img"].ParseToString(),
|
|
ext_code = row["ext_code"].ParseToString(),
|
|
add_time = Convert.ToDateTime(row["add_time"]),
|
|
mdy_time = Convert.ToDateTime(row["mdy_time"]),
|
|
notes = row["notes"].ParseToString(),
|
|
draft_id = row["draft_id"].ParseToString(),
|
|
add_times = row["add_times"].ParseToInt(),
|
|
skc_id = row["skc_id"].ToString(),
|
|
spu_id = row["spu_id"].ToString(),
|
|
operate_sub_sa_name = row["operate_sub_sa_name"].ToString(),
|
|
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(),
|
|
};
|
|
prodSelect.add_sub_sa_time = row["add_sub_sa_time"] as DateTime?;
|
|
productLst.Add(prodSelect);
|
|
}
|
|
var data = JsonUtils.SerializeObjectToString(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 DelSelectProd(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("'", "\\'");
|
|
var id = RegexUtils.GetStringQuery(ref inputData, "db_id")?.Replace("'", "\\'");
|
|
|
|
if (string.IsNullOrEmpty(user_name))
|
|
{
|
|
return "{\"code\":500,\"msg\":\"没有用户名\"}";
|
|
}
|
|
|
|
string conn = "ConnKJD";
|
|
MysqlUtils mySql = new MysqlUtils(conn);
|
|
string sql = "delete from bxx.third_product_select where id='"
|
|
+ id + "'";
|
|
|
|
var rst = mySql.ExecuteNonQuery(sql);
|
|
mySql.Close();
|
|
if (rst)
|
|
{
|
|
return "{\"code\":200,\"msg\":\"success\"}";
|
|
}
|
|
else
|
|
return "{\"code\":500,\"msg\":\"删除失败:" + mySql.Message + "\"}";
|
|
}
|
|
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设置上传商品的二级超管
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public string SetSelectProductSubSa(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\":\"没有用户名\"}";
|
|
}
|
|
|
|
var id = RegexUtils.GetStringQuery(ref inputData, "db_id")?.Replace("'", "\\'");
|
|
var shop_id = RegexUtils.GetStringQuery(ref inputData, "shop_id")?.Replace("'", "\\'");
|
|
var operate_sub_sa_name = RegexUtils.GetStringQuery(ref inputData, "operate_sub_sa_name")?.Replace("'", "\\'");
|
|
var status = RegexUtils.GetStringQuery(ref inputData, "status")?.Replace("'", "\\'");
|
|
|
|
if (string.IsNullOrEmpty(id) && string.IsNullOrEmpty(shop_id))
|
|
{
|
|
return "{\"code\":50002,\"msg\":\"未选择任何待上传\"}";
|
|
}
|
|
|
|
string conn = "ConnKJD";
|
|
MysqlUtils mySql = new MysqlUtils(conn);
|
|
string sql = "update bxx.third_product_select set";
|
|
if (operate_sub_sa_name != null)
|
|
sql += " operate_sub_sa_name='" + operate_sub_sa_name + "',";
|
|
sql += " add_sub_sa_time='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',";
|
|
sql = sql.TrimEnd(',');
|
|
if (!string.IsNullOrEmpty(id))
|
|
sql += " where id in (" + id + ")";
|
|
else if (!string.IsNullOrEmpty(shop_id))
|
|
sql += " where shop_id in ('" + shop_id.Replace(",","','") + "')";
|
|
else
|
|
sql += " where 1=2";
|
|
if(!string.IsNullOrEmpty(status))
|
|
sql += " and status='" + status + "';";
|
|
var rst = mySql.ExecuteNonQuery(sql);
|
|
mySql.Close();
|
|
if (rst)
|
|
{
|
|
return "{\"code\":200,\"msg\":\"success\"}";
|
|
}
|
|
else
|
|
{
|
|
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}";
|
|
}
|
|
}
|
|
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
|
}
|
|
|
|
public string MdyProductSelectNotes(string inputData, bool isAdmin = false)
|
|
{
|
|
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");
|
|
var id = RegexUtils.GetStringQuery(ref inputData, "db_id");
|
|
string notes = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "notes"));
|
|
string user_notes = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "user_notes"));
|
|
string fission_product_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "fission_product_name"));
|
|
|
|
if (string.IsNullOrEmpty(user_name))
|
|
{
|
|
return "{\"code\":500,\"msg\":\"没有用户名\"}";
|
|
}
|
|
|
|
string conn = "ConnKJD";
|
|
MysqlUtils mySql = new MysqlUtils(conn);
|
|
string sql = "update bxx.third_product_select set";
|
|
if (notes != null)
|
|
sql += " notes=@notes,";
|
|
if (user_notes != null)
|
|
sql += " user_notes=@user_notes,";
|
|
if (fission_product_name != null)
|
|
sql += " fission_product_name=@fission_product_name,";
|
|
sql = sql.TrimEnd(',');
|
|
sql += " where id=@id;";
|
|
|
|
List<MySqlParameter> paramLst = new List<MySqlParameter>();
|
|
paramLst.Add(new MySqlParameter() { DbType = DbType.Int32, ParameterName = "@id", Value = id, });
|
|
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@fission_product_name", Value = fission_product_name, });
|
|
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@user_notes", Value = user_notes, });
|
|
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@notes", Value = notes, });
|
|
|
|
var rst = mySql.ExecuteNonQuery(sql, paramLst.ToArray());
|
|
mySql.Close();
|
|
if (rst)
|
|
{
|
|
return "{\"code\":200,\"msg\":\"success\"}";
|
|
}
|
|
else
|
|
{
|
|
return "{\"code\":500,\"msg\":\"更新失败:" + mySql.Message + "\"}";
|
|
}
|
|
}
|
|
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|