ai图片随机作为sku图或者主图上传商品
This commit is contained in:
1 parent
0d3ab6321e
commit
ec8736b8f9
31 files changed
+3169
-75
No files matched your search
@@ -72,7 +72,7 @@ namespace KJD_Web.BLL
|
||||
if (time1 != EncrypUtil.Encryption(time))
|
||||
return "{\"code\":50000,\"msg\":\"校验失败\"}";
|
||||
|
||||
var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name")?.Replace("'","\\'");
|
||||
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("'", "\\'");
|
||||
@@ -86,7 +86,7 @@ namespace KJD_Web.BLL
|
||||
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);
|
||||
int page_size = RegexUtils.GetStringQuery(ref inputData, "page_size").ParseToInt(50);
|
||||
|
||||
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
||||
MysqlUtils mySql = new MysqlUtils(conn);
|
||||
@@ -129,7 +129,7 @@ namespace KJD_Web.BLL
|
||||
"p.add_time,p.mdy_time,p.select_total_count,p.fission_words,p.head_words,p.end_words,COUNT(s.id) AS select_count " +
|
||||
"FROM kjd.product p LEFT JOIN kjd.product_select s ON p.id=s.out_product_id AND s.shop_id='" + select_shop_id + "' " +
|
||||
"WHERE p.is_del=0";
|
||||
|
||||
|
||||
//where子句
|
||||
sql += where;
|
||||
|
||||
@@ -701,10 +701,10 @@ namespace KJD_Web.BLL
|
||||
if (!string.IsNullOrEmpty(id))
|
||||
sql += " where id in (" + id + ")";
|
||||
else if (!string.IsNullOrEmpty(shop_id))
|
||||
sql += " where shop_id in ('" + shop_id.Replace(",","','") + "')";
|
||||
sql += " where shop_id in ('" + shop_id.Replace(",", "','") + "')";
|
||||
else
|
||||
sql += " where 1=2";
|
||||
if(!string.IsNullOrEmpty(status))
|
||||
if (!string.IsNullOrEmpty(status))
|
||||
sql += " and status='" + status + "';";
|
||||
var rst = mySql.ExecuteNonQuery(sql);
|
||||
mySql.Close();
|
||||
@@ -857,23 +857,278 @@ namespace KJD_Web.BLL
|
||||
}
|
||||
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
||||
}
|
||||
|
||||
public string AddSkuImg(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 img_md5 = RegexUtils.GetStringQuery(ref inputData, "img_md5");
|
||||
string img_base64 = RegexUtils.GetStringQuery(ref inputData, "img_base64");
|
||||
string product_id = RegexUtils.GetStringQuery(ref inputData, "product_id");
|
||||
string spec_id = RegexUtils.GetStringQuery(ref inputData, "spec_id");
|
||||
string spec_name = RegexUtils.GetStringQuery(ref inputData, "spec_name");
|
||||
string original_img_url = RegexUtils.GetStringQuery(ref inputData, "original_img_url");
|
||||
|
||||
if (string.IsNullOrEmpty(user_name))
|
||||
{
|
||||
return "{\"code\":500,\"msg\":\"没有用户名\"}";
|
||||
}
|
||||
|
||||
int img_base64_db_id = 0;
|
||||
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
||||
MysqlUtils mySql = new MysqlUtils(conn);
|
||||
string sql = "";
|
||||
|
||||
sql = "select id from kjd.sku_img_base64 where img_md5='" + img_md5 + "';";
|
||||
var nRst = 0L;
|
||||
var rst = mySql.ExecuteFirstInt(sql).ParseToLong();
|
||||
if (rst <= 0)
|
||||
{
|
||||
sql = "insert into kjd.sku_img_base64 (img_md5,img_base64) " +
|
||||
"values ('" + img_md5 + "','" + img_base64 + "');";
|
||||
rst = mySql.ExecuteInsertId(sql);
|
||||
}
|
||||
if (rst > 0)
|
||||
{
|
||||
img_base64_db_id = (int)rst;
|
||||
sql = "insert kjd.sku_img (img_base64_db_id,product_id,spec_id,spec_name,original_img_url) " +
|
||||
"values (" + img_base64_db_id + ",'" + product_id + "','" + spec_id + "','" + spec_name + "','" + original_img_url + "');";
|
||||
nRst = mySql.ExecuteInsertId(sql);
|
||||
}
|
||||
mySql.Close();
|
||||
if (nRst > 0)
|
||||
{
|
||||
return "{\"code\":200,\"msg\":\"success\",\"sku_img_id\":" + nRst + ",\"sku_img_Base64_id\":" + img_base64_db_id + "}";
|
||||
}
|
||||
|
||||
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}";
|
||||
}
|
||||
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
||||
}
|
||||
|
||||
public string DelSkuImg(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");
|
||||
int img_id = RegexUtils.GetStringQuery(ref inputData, "img_id").ParseToInt();
|
||||
int img_base64_id = RegexUtils.GetStringQuery(ref inputData, "img_base64_id").ParseToInt();
|
||||
|
||||
if (string.IsNullOrEmpty(user_name))
|
||||
{
|
||||
return "{\"code\":500,\"msg\":\"没有用户名\"}";
|
||||
}
|
||||
if (img_id == 0 || img_base64_id == 0)
|
||||
{
|
||||
return "{\"code\":501,\"msg\":\"图片编号或者图片数据编号为空\"}";
|
||||
}
|
||||
|
||||
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
||||
MysqlUtils mySql = new MysqlUtils(conn);
|
||||
string sql = "";
|
||||
|
||||
sql = "delete from kjd.sku_img where id=" + img_id + ";";
|
||||
var bRst = mySql.ExecuteNonQuery(sql);
|
||||
if (!bRst)
|
||||
{
|
||||
mySql.Close();
|
||||
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}";
|
||||
}
|
||||
sql = "select id from kjd.sku_img where img_base64_db_id=" + img_base64_id + " limit 1;";
|
||||
var nRst = mySql.ExecuteRowCount(sql);
|
||||
//如果已无对图片的引用,则删除原图片
|
||||
if (nRst == 0)
|
||||
{
|
||||
sql = "delete from kjd.sku_img_base64 where id=" + img_base64_id + ";";
|
||||
mySql.ExecuteNonQuery(sql);
|
||||
}
|
||||
mySql.Close();
|
||||
if (!string.IsNullOrEmpty(mySql.Message))
|
||||
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}";
|
||||
return "{\"code\":200,\"msg\":\"success\"}";
|
||||
}
|
||||
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
||||
}
|
||||
|
||||
public string GetSkuImgList(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("'", "\\'");
|
||||
if (string.IsNullOrEmpty(user_name))
|
||||
{
|
||||
return "{\"code\":500,\"msg\":\"没有用户名\"}";
|
||||
}
|
||||
|
||||
var search_db_id = RegexUtils.GetStringQuery(ref inputData, "search_db_id")?.Replace("'", "\\'");
|
||||
var search_db_ids = RegexUtils.GetStringQuery(ref inputData, "search_db_ids")?.Replace("'", "\\'");
|
||||
var search_product_id = RegexUtils.GetStringQuery(ref inputData, "search_product_id")?.Replace("'", "\\'");
|
||||
var search_spec_id = RegexUtils.GetStringQuery(ref inputData, "search_spec_id")?.Replace("'", "\\'");
|
||||
var search_original_img_url = RegexUtils.GetStringQuery(ref inputData, "search_original_img_url")?.Replace("'", "\\'");
|
||||
|
||||
int page = RegexUtils.GetStringQuery(ref inputData, "page").ParseToInt();
|
||||
int page_size = RegexUtils.GetStringQuery(ref inputData, "page_size").ParseToInt(200);
|
||||
|
||||
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
||||
MysqlUtils mySql = new MysqlUtils(conn);
|
||||
|
||||
string sql = "select count(id) from kjd.sku_img s where 1=1";
|
||||
|
||||
string where = "";
|
||||
if (!string.IsNullOrWhiteSpace(search_db_id))
|
||||
where += " and s.id like '%" + search_db_id + "%'";
|
||||
if (!string.IsNullOrWhiteSpace(search_product_id))
|
||||
where += " and s.product_id like '%" + search_product_id + "%'";
|
||||
if (!string.IsNullOrWhiteSpace(search_spec_id))
|
||||
where += " and s.spec_id like '%" + search_spec_id + "%'";
|
||||
if (!string.IsNullOrWhiteSpace(search_original_img_url))
|
||||
where += " and s.original_img_url like '%" + search_original_img_url + "%'";
|
||||
if (!string.IsNullOrEmpty(search_db_ids))
|
||||
where += " and s.id in (" + search_db_ids + ")";
|
||||
sql += where;
|
||||
|
||||
var count = mySql.ExecuteRowCount(sql);
|
||||
|
||||
DataTable dt;
|
||||
if (count == 0)
|
||||
{
|
||||
dt = new DataTable();
|
||||
}
|
||||
else
|
||||
{
|
||||
sql = "select s.*,b.img_md5,b.img_base64,b.img_url,b.mdy_time base64_mdy_time from kjd.sku_img s left join kjd.sku_img_base64 b on " +
|
||||
"s.img_base64_db_id = b.id where 1=1";
|
||||
|
||||
//where子句
|
||||
sql += where;
|
||||
|
||||
sql += " order by s.id desc";
|
||||
sql += " limit " + Math.Max(page - 1, 0) * page_size + "," + page_size;
|
||||
dt = mySql.ExecuteDataTable(sql);
|
||||
}
|
||||
mySql.Close();
|
||||
if (!string.IsNullOrEmpty(mySql.Message))
|
||||
{
|
||||
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\",\"data\":[],\"count\":" + 0 + "}";
|
||||
}
|
||||
|
||||
if (dt != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
List<SkuImgResult> skuImgLst = new List<SkuImgResult>();
|
||||
foreach (DataRow row in dt.Rows)
|
||||
{
|
||||
SkuImgResult img = new SkuImgResult
|
||||
{
|
||||
id = row["id"].ParseToInt(),
|
||||
img_base64 = row["img_base64"].ParseToString(),
|
||||
img_base64_db_id = row["img_base64_db_id"].ParseToInt(),
|
||||
img_md5 = row["img_md5"].ParseToString(),
|
||||
img_url = row["img_url"].ParseToString(),
|
||||
original_img_url = row["original_img_url"].ParseToString(),
|
||||
add_time = Convert.ToDateTime(row["add_time"]),
|
||||
mdy_time = Convert.ToDateTime(row["mdy_time"]),
|
||||
base64_mdy_time = Convert.ToDateTime(row["base64_mdy_time"]),
|
||||
product_id = row["product_id"].ParseToString(),
|
||||
spec_id = row["spec_id"].ParseToString(),
|
||||
spec_name = row["spec_name"].ParseToString(),
|
||||
};
|
||||
if(img.base64_mdy_time.AddDays(2) < DateTime.Now)
|
||||
{
|
||||
// 每过两天返回给客户端空图,让客户端重传base64图片
|
||||
img.img_url = "";
|
||||
}
|
||||
//if (isDetail)
|
||||
//{
|
||||
// img.img_base64 = row["img_base64"].ToString();
|
||||
//}
|
||||
skuImgLst.Add(img);
|
||||
}
|
||||
var data = JsonUtils.SerializerObjectToString(skuImgLst);
|
||||
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 MdyBase64ImgUrl(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("'", "\\'");
|
||||
var img_url = RegexUtils.GetStringQuery(ref inputData, "img_url")?.Replace("'", "\\'");
|
||||
if(string.IsNullOrEmpty(id) || string.IsNullOrEmpty(img_url))
|
||||
{
|
||||
return "{\"code\":500,\"msg\":\"保存失败:缺少图片编号或图片路径\"}";
|
||||
}
|
||||
|
||||
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
||||
MysqlUtils mySql = new MysqlUtils(conn);
|
||||
string sql = "update kjd.sku_img_base64 set img_url=\'" + img_url + "\' 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\":\"输入为空\"}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
List<MySqlParameter> paramLst = new List<MySqlParameter>();
|
||||
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());*/
|
||||
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());*/
|
||||
@@ -114,6 +114,7 @@
|
||||
<Compile Include="Model\ProductSelectResultParam.cs" />
|
||||
<Compile Include="Model\ShopModel\ShopParam.cs" />
|
||||
<Compile Include="Model\ShopModel\sku_img_replace.cs" />
|
||||
<Compile Include="Model\SkuImgResult.cs" />
|
||||
<Compile Include="Model\UserLoginResultParam.cs" />
|
||||
<Compile Include="BXXPriceService.asmx.cs">
|
||||
<DependentUpon>BXXPriceService.asmx</DependentUpon>
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
namespace KJD_Web.Model
|
||||
{
|
||||
public class SkuImgResult
|
||||
{
|
||||
public int id { get; set; }
|
||||
public int img_base64_db_id { get; set; }
|
||||
public string img_md5 { get; set; }
|
||||
public string img_url { get; set; }
|
||||
public string product_id { get; set; }
|
||||
public string spec_id { get; set; }
|
||||
public string spec_name { get; set; }
|
||||
public string original_img_url { get; set; }
|
||||
public DateTime add_time { get; set; }
|
||||
public DateTime mdy_time { get; set; }
|
||||
public DateTime base64_mdy_time { get; set; }
|
||||
public string img_base64 { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -229,5 +229,49 @@ namespace KJD_Web
|
||||
Context.Response.Write(result);
|
||||
Context.Response.End();
|
||||
}
|
||||
|
||||
[WebMethod]
|
||||
public void add_sku_image()
|
||||
{
|
||||
string jsontext = GetRequestJsonString();
|
||||
var result = jsontext;
|
||||
result = new ProductManage().AddSkuImg(jsontext);
|
||||
|
||||
Context.Response.Write(result);
|
||||
Context.Response.End();
|
||||
}
|
||||
|
||||
[WebMethod]
|
||||
public void del_sku_image()
|
||||
{
|
||||
string jsontext = GetRequestJsonString();
|
||||
var result = jsontext;
|
||||
result = new ProductManage().DelSkuImg(jsontext);
|
||||
|
||||
Context.Response.Write(result);
|
||||
Context.Response.End();
|
||||
}
|
||||
|
||||
[WebMethod]
|
||||
public void get_sku_image_list()
|
||||
{
|
||||
string jsontext = GetRequestJsonString();
|
||||
var result = jsontext;
|
||||
result = new ProductManage().GetSkuImgList(jsontext);
|
||||
|
||||
Context.Response.Write(result);
|
||||
Context.Response.End();
|
||||
}
|
||||
|
||||
[WebMethod]
|
||||
public void mdy_base64_img_url()
|
||||
{
|
||||
string jsontext = GetRequestJsonString();
|
||||
var result = jsontext;
|
||||
result = new ProductManage().MdyBase64ImgUrl(jsontext);
|
||||
|
||||
Context.Response.Write(result);
|
||||
Context.Response.End();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user