using KJD_Web.BLL.WXXD; using KJD_Web.Model; using KJD_Web.Model.ShopModel; using KJD_Web.Utils; using MySql.Data.MySqlClient; using NaiBa.Util.Extension; using NaiBa.Util.Helper; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.Data; using System.Drawing; using System.IO; using System.Linq; using System.Threading; using System.Web; using System.Web.Security; namespace KJD_Web.BLL.BXX { public class BXXProductManage { 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")?.Replace("'", "\\'"); string from_shop_id = RegexUtils.GetStringQuery(ref inputData, "from_shop_id")?.Replace("'", "\\'"); string from_shop_name = RegexUtils.GetStringQuery(ref inputData, "from_shop_name")?.Replace("'", "\\'"); string offline_supplier_id = RegexUtils.GetStringQuery(ref inputData, "offline_supplier_id")?.Replace("'", "\\'"); string offline_supplier_name = RegexUtils.GetStringQuery(ref inputData, "offline_supplier_name")?.Replace("'", "\\'"); string spu_id = RegexUtils.GetStringQuery(ref inputData, "spu_id")?.Replace("'", "\\'"); //厂商直采聚水潭商品使用skcid存储coid数据 string skc_id = RegexUtils.GetStringQuery(ref inputData, "skc_id")?.Replace("'", "\\'"); // skcId,聚水潭商品为coid string real_coid = RegexUtils.GetStringQuery(ref inputData, "real_coid")?.Replace("'", "\\'"); // 聚水潭爆款专区真实商家coid,供应商直采商品该字段留空 string real_spu_id = RegexUtils.GetStringQuery(ref inputData, "real_spu_id")?.Replace("'", "\\'"); // 聚水潭爆款专区真实商家spuid,供应商直采商品该字段留空 string price_text = RegexUtils.GetStringQuery(ref inputData, "price_text")?.Replace("'", "\\'"); string main_cat_id = RegexUtils.GetStringQuery(ref inputData, "main_cat_id")?.Replace("'", "\\'"); string main_cat_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "main_cat_name"))?.Replace("'", "\\'"); string cat_id = RegexUtils.GetStringQuery(ref inputData, "cat_id"); string cat_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "cat_name"))?.Replace("'", "\\'"); string ext_code = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "ext_code"))?.Replace("'", "\\'"); string product_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "product_name"))?.Replace("'", "\\'"); 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"))?.Replace("'", "\\'"); string group = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "group"))?.Replace("'", "\\'"); string notes = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "notes"))?.Replace("'", "\\'"); 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 distribution_set = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "distribution_set"))?.Replace("'", "\\'"); string special_prod_type = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "special_prod_type"))?.Replace("'", "\\'"); if (special_prod_type != "爆款商品") special_prod_type = "普通商品"; string add_user_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "add_user_name"))?.Replace("'", "\\'"); if (string.IsNullOrEmpty(product_get_type)) { product_get_type = "母店采集"; } if (string.IsNullOrEmpty(user_name)) { return "{\"code\":500,\"msg\":\"没有用户名\"}"; } string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString; MysqlUtils mySql = new MysqlUtils(conn); string sql = ""; int ban_wx = 0; int ban_pdd = 0; if (product_get_type == "厂商直采") { if (real_coid != null) sql = "select ban_wx,ban_pdd from bxx.jst_supplier_ban_platform where coid=" + real_coid; else if (skc_id != null) sql = "select ban_wx,ban_pdd from bxx.jst_supplier_ban_platform where coid=" + skc_id; var dtr = mySql.ExecuteDataTableRow(sql); if (!string.IsNullOrEmpty(mySql.Message)) { mySql.Close(); return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}"; } else if (dtr != null) { ban_wx = dtr["ban_wx"].ParseToInt(); ban_pdd = dtr["ban_pdd"].ParseToInt(); } } sql = "INSERT INTO bxx.product("; sql += "from_shop_id,from_shop_name,offline_supplier_id,offline_supplier_name,spu_id,skc_id,real_coid,real_spu_id,main_cat_id,main_cat_name,cat_id,"; sql += "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,"; sql += "distribution_set,ban_wx,ban_pdd,add_time,mdy_time,"; if (add_user_name != null) sql += "add_user_name,"; if (group != null) sql += "`group`,"; sql = sql.TrimEnd(','); sql += ") "; sql += "values ('" + from_shop_id + "','" + from_shop_name + "','" + offline_supplier_id + "','" + offline_supplier_name + "','" + spu_id + "','" + skc_id + "','" + real_coid + "','" + real_spu_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 + "'," + distribution_set.ParseToInt() + "," + ban_wx + "," + ban_pdd + ","; sql += "'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',"; sql += "'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',"; if (add_user_name != null) sql += "'" + add_user_name + "',"; if (group != null) sql += "'" + group + "',"; sql = sql.TrimEnd(','); sql += ");"; List paramLst = new List(); 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, }); 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\":\"输入为空\"}"; } public string MdyProduct(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")?.Replace("'", "\\'"); string from_shop_id = RegexUtils.GetStringQuery(ref inputData, "from_shop_id")?.Replace("'", "\\'"); string from_shop_name = RegexUtils.GetStringQuery(ref inputData, "from_shop_name")?.Replace("'", "\\'"); string offline_supplier_id = RegexUtils.GetStringQuery(ref inputData, "offline_supplier_id")?.Replace("'", "\\'"); string offline_supplier_name = RegexUtils.GetStringQuery(ref inputData, "offline_supplier_name")?.Replace("'", "\\'"); string spu_id = RegexUtils.GetStringQuery(ref inputData, "spu_id")?.Replace("'", "\\'"); string skc_id = RegexUtils.GetStringQuery(ref inputData, "skc_id")?.Replace("'", "\\'"); // skcId,聚水潭商品为coid string real_coid = RegexUtils.GetStringQuery(ref inputData, "real_coid")?.Replace("'", "\\'"); // 聚水潭爆款专区真实商家coid,供应商直采商品该字段留空 string real_spu_id = RegexUtils.GetStringQuery(ref inputData, "real_spu_id")?.Replace("'", "\\'"); // 聚水潭爆款专区真实商家spuid,供应商直采商品该字段留空 string secret_spu_id = RegexUtils.GetStringQuery(ref inputData, "secret_spu_id")?.Replace("'", "\\'"); string price_text = RegexUtils.GetStringQuery(ref inputData, "price_text")?.Replace("'", "\\'"); string main_cat_id = RegexUtils.GetStringQuery(ref inputData, "main_cat_id")?.Replace("'", "\\'"); string main_cat_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "main_cat_name"))?.Replace("'", "\\'"); string cat_id = RegexUtils.GetStringQuery(ref inputData, "cat_id")?.Replace("'", "\\'"); string cat_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "cat_name"))?.Replace("'", "\\'"); string ext_code = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "ext_code"))?.Replace("'", "\\'"); string product_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "product_name"))?.Replace("'", "\\'"); 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"))?.Replace("'", "\\'"); string group = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "group"))?.Replace("'", "\\'"); string notes = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "notes"))?.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 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(special_prod_type) && special_prod_type != "爆款商品") special_prod_type = "普通商品"; string wx_cat_1 = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "wx_cat_1"))?.Replace("'", "\\'"); string wx_cat_2 = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "wx_cat_2"))?.Replace("'", "\\'"); string wx_cat_3 = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "wx_cat_3"))?.Replace("'", "\\'"); string wx_cat_leaf = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "wx_cat_leaf"))?.Replace("'", "\\'"); string delivery_fee_set = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "delivery_fee_set"))?.Replace("'", "\\'"); string after_sale_set = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "after_sale_set"))?.Replace("'", "\\'"); string distribution_set = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "distribution_set"))?.Replace("'", "\\'"); string send_to_out_server = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "send_to_out_server"))?.Replace("'", "\\'"); string sku_edit_json = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sku_edit_json"))?.Replace("'", "\\'"); string sku_secret_json = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sku_secret_json"))?.Replace("'", "\\'"); string wx_img_map_json = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "wx_img_map_json"))?.Replace("'", "\\'"); string problem_prod_data = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "problem_prod_data"))?.Replace("'", "\\'"); string is_relation = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "is_relation"))?.Replace("'", "\\'"); if (string.IsNullOrEmpty(user_name)) { return "{\"code\":500,\"msg\":\"没有用户名\"}"; } string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString; MysqlUtils mySql = new MysqlUtils(conn); string sql = ""; sql = "update bxx.product p set"; if (from_shop_id != null) sql += " p.from_shop_id='" + from_shop_id + "',"; if (from_shop_name != null) sql += " p.from_shop_name='" + from_shop_name + "',"; if (offline_supplier_id != null) sql += " p.offline_supplier_id='" + offline_supplier_id + "',"; if (offline_supplier_name != null) sql += " p.offline_supplier_name='" + offline_supplier_name + "',"; if (main_cat_id != null) sql += " p.main_cat_id='" + main_cat_id + "',"; if (main_cat_name != null) sql += " p.main_cat_name='" + main_cat_name + "',"; if (cat_id != null) sql += " p.cat_id='" + cat_id + "',"; if (cat_name != null) sql += " p.cat_name='" + cat_name + "',"; if (price_text != null) sql += " p.price_text='" + price_text + "',"; if (product_name != null) sql += " p.product_name='" + product_name + "',"; if (ext_code != null) sql += " p.ext_code='" + ext_code + "',"; if (secret_spu_id != null) sql += " p.secret_spu_id='" + secret_spu_id + "',"; if (main_img != null) sql += " p.main_img='" + main_img + "',"; if (product_json != null) sql += " p.product_json=@product_json,"; if (size_json != null) sql += " p.size_json=@size_json,"; if (group != null) sql += " p.group='" + group + "',"; if (notes != null) sql += " p.notes='" + notes + "',"; if (sale_count != null) sql += " p.sale_count='" + 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 != "") sql += " p.special_prod_type='" + special_prod_type + "',"; if (wx_cat_1 != null) sql += " p.wx_cat_1=" + wx_cat_1 + ","; if (wx_cat_2 != null) sql += " p.wx_cat_2=" + wx_cat_2 + ","; if (wx_cat_3 != null) sql += " p.wx_cat_3=" + wx_cat_3 + ","; if (wx_cat_leaf != null) sql += " p.wx_cat_leaf=" + wx_cat_leaf + ","; if (delivery_fee_set != null) sql += " p.delivery_fee_set=" + delivery_fee_set + ","; if (after_sale_set != null) sql += " p.after_sale_set=" + after_sale_set + ","; if (distribution_set != null) sql += " p.distribution_set=" + distribution_set + ","; if (send_to_out_server != null) sql += " p.send_to_out_server=" + send_to_out_server + ","; if (sku_edit_json != null) sql += " p.sku_edit_json='" + sku_edit_json + "',"; if (sku_secret_json != null) sql += " p.sku_secret_json=@sku_secret_json,"; if (wx_img_map_json != null) sql += " p.wx_img_map_json=@wx_img_map_json,"; if (!problem_prod_data.IsNullOrEmpty()) sql += " p.problem_prod_data=" + problem_prod_data + ","; if (!is_relation.IsNullOrEmpty()) sql += " p.is_relation=" + is_relation + ","; sql += " p.mdy_time='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',"; sql = sql.TrimEnd(','); sql += " where spu_id='" + spu_id + "';"; List paramLst = new List(); 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 = "sku_secret_json", Value = sku_secret_json, }); paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "wx_img_map_json", Value = wx_img_map_json, }); 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\":\"输入为空\"}"; } /// /// 违规商品 /// /// /// public string MdyViolationProd(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")?.Replace("'", "\\'"); if (string.IsNullOrEmpty(user_name)) { return "{\"code\":500,\"msg\":\"没有用户名\"}"; } string product_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "product_name"))?.Replace("'", "\\'"); string secret_spu_id = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "secret_spu_id"))?.Replace("'", "\\'"); string spu_id = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "spu_id"))?.Replace("'", "\\'"); string group = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "group"))?.Replace("'", "\\'"); string notes = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "notes"))?.Replace("'", "\\'"); string wx_safe_status = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "wx_safe_status"))?.Replace("'", "\\'"); if (string.IsNullOrWhiteSpace(product_name) && string.IsNullOrWhiteSpace(secret_spu_id) && string.IsNullOrWhiteSpace(spu_id)) return "{\"code\":500,\"msg\":\"没有商品查询信息\"}"; string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString; MysqlUtils mySql = new MysqlUtils(conn); string sql = ""; if (!string.IsNullOrEmpty(product_name)) sql = "select id,spu_id from bxx.product p where p.product_name='" + product_name + "' and p.wx_safe_status in ('安全商品','未校验');"; else if (!string.IsNullOrEmpty(secret_spu_id)) sql = "select id,spu_id from bxx.product p where p.secret_spu_id='" + secret_spu_id + "' and p.wx_safe_status in ('安全商品','未校验');"; else sql = "select id,spu_id from bxx.product p where p.spu_id='" + spu_id + "' and p.wx_safe_status in ('安全商品','未校验');"; var dt = mySql.ExecuteDataTable(sql); if (!string.IsNullOrEmpty(mySql.Message)) { mySql.Close(); return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}"; } var ids = ""; foreach(DataRow row in dt.Rows) { ids += row["spu_id"].ParseToString() + "','"; } ids.Trim(',', '\''); if (string.IsNullOrEmpty(ids)) { return "{\"code\":200,\"msg\":\"success\",\"err_msg\":\"商品不存在\"}"; } else { sql = "update bxx.product p set"; if (group != null) sql += " p.group='" + group + "',"; if (notes != null) sql += " p.notes='" + notes + "',"; if (wx_safe_status != null) sql += " p.wx_safe_status='" + wx_safe_status + "',"; sql += " p.mdy_time='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',"; sql = sql.TrimEnd(','); sql += " where p.spu_id in('" + ids + "')"; 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\":\"输入为空\"}"; } /// /// 获取商品SpuId(快速查询) /// /// /// public string GetProductSpuIdLst(string inputData) { var timeCalc = DateTime.Now; 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 version = RegexUtils.GetStringQuery(ref inputData, "version").ParseToInt(); if (version < (System.Configuration.ConfigurationManager.ConnectionStrings["LimitVersion"]?.ConnectionString).ParseToInt()) return "{\"code\":1,\"msg\":\"当前版本过于陈旧,请立即升级新版\"}"; var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name")?.Replace("'", "\\'"); var password = RegexUtils.GetStringQuery(ref inputData, "password")?.Replace("'", "\\'"); var search_secret_spu_ids = RegexUtils.GetStringQuery(ref inputData, "search_secret_spu_ids")?.Replace("'", "\\'"); var search_spu_ids = RegexUtils.GetStringQuery(ref inputData, "search_spu_ids")?.Replace("'", "\\'"); var wx_safe_status = RegexUtils.GetStringQuery(ref inputData, "wx_safe_status")?.Replace("'", "\\'"); int page = RegexUtils.GetStringQuery(ref inputData, "page").ParseToInt(); int page_size = RegexUtils.GetStringQuery(ref inputData, "page_size").ParseToInt(500); string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString; MysqlUtils mySql = new MysqlUtils(conn); string sql = "select id,spu_id,secret_spu_id from bxx.product p where p.is_del=0"; if (search_secret_spu_ids != null) { sql += " and p.secret_spu_id in ('" + string.Join("','", search_secret_spu_ids.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries)) + "')"; } if (search_spu_ids != null) { sql += " and p.spu_id in ('" + string.Join("','", search_spu_ids.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries)) + "')"; } if (wx_safe_status != null) { sql += " and p.wx_safe_status in ('" + string.Join("','", wx_safe_status.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries)) + "')"; } var dt = mySql.ExecuteDataTable(sql); mySql.Close(); if (dt != null) { try { List productLst = new List(); foreach (DataRow row in dt.Rows) { DBProductResultParamLite prod = new DBProductResultParamLite { id = Convert.ToInt32(row["id"]), spu_id = row["spu_id"].ToString(), secret_spu_id = row["secret_spu_id"].IsNullOrEmpty() ? null : row["secret_spu_id"].ParseToString(), }; productLst.Add(prod); } JsonSerializerSettings jsonSetting = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }; var data = JsonUtils.SerializeObjectToString(productLst, jsonSetting); var seconds = (DateTime.Now - timeCalc).TotalSeconds.ToString("0.000"); return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"count\":" + productLst.Count + ",\"seconds\":" + seconds + "}"; } 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 GetProductList(string inputData, bool isDetail = false) { var timeCalc = DateTime.Now; 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 version = RegexUtils.GetStringQuery(ref inputData, "version").ParseToInt(); if (version < (System.Configuration.ConfigurationManager.ConnectionStrings["LimitVersion"]?.ConnectionString).ParseToInt()) return "{\"code\":1,\"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_cat1 = RegexUtils.GetStringQuery(ref inputData, "search_cat1")?.Replace("'", "\\'"); var search_cat = RegexUtils.GetStringQuery(ref inputData, "search_cat")?.Replace("'", "\\'"); var wx_cat_1 = RegexUtils.GetStringQuery(ref inputData, "wx_cat_1")?.Replace("'", "\\'"); var wx_cat_2 = RegexUtils.GetStringQuery(ref inputData, "wx_cat_2")?.Replace("'", "\\'"); var wx_cat_3 = RegexUtils.GetStringQuery(ref inputData, "wx_cat_3")?.Replace("'", "\\'"); var wx_cat_leaf = RegexUtils.GetStringQuery(ref inputData, "wx_cat_leaf")?.Replace("'", "\\'"); var search_ext_code = RegexUtils.GetStringQuery(ref inputData, "search_ext_code")?.Replace("'", "\\'"); var search_prod_name = HtmlUtils.UrlDecodeUtf8(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 search_secret_spu_ids = RegexUtils.GetStringQuery(ref inputData, "search_secret_spu_ids")?.Replace("'", "\\'"); var ext_code_in = RegexUtils.GetStringQuery(ref inputData, "ext_code_in")?.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 from_shop_name = RegexUtils.GetStringQuery(ref inputData, "from_shop_name")?.Replace("'", "\\'"); 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("'", "\\'"); if (special_prod_type.IsNullOrEmpty()) special_prod_type = "普通商品,书籍"; var is_supplier_prod_ok = RegexUtils.GetStringQuery(ref inputData, "is_supplier_prod_ok")?.Replace("'", "\\'"); var has_wx_cat = RegexUtils.GetStringQuery(ref inputData, "has_wx_cat")?.Replace("'", "\\'"); var send_to_out_server = RegexUtils.GetStringQuery(ref inputData, "send_to_out_server")?.Replace("'", "\\'"); var has_send_to_out_server = RegexUtils.GetStringQuery(ref inputData, "has_send_to_out_server")?.Replace("'", "\\'"); var real_coid = RegexUtils.GetStringQuery(ref inputData, "real_coid")?.Replace("'", "\\'"); var has_wx_format = RegexUtils.GetStringQuery(ref inputData, "has_wx_format")?.Replace("'", "\\'"); var problem_prod_data = RegexUtils.GetStringQuery(ref inputData, "problem_prod_data")?.Replace("'", "\\'"); var is_relation = RegexUtils.GetStringQuery(ref inputData, "is_relation")?.Replace("'", "\\'"); var start_time = RegexUtils.GetStringQuery(ref inputData, "start_time")?.Replace("'", "\\'"); var end_time = RegexUtils.GetStringQuery(ref inputData, "end_time")?.Replace("'", "\\'"); var ban_wx = RegexUtils.GetStringQuery(ref inputData, "ban_wx")?.Replace("'", "\\'"); var ban_pdd = RegexUtils.GetStringQuery(ref inputData, "ban_pdd")?.Replace("'", "\\'"); var add_user_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "add_user_name"))?.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); List paramLst = new List(); string sql = " select count(*) from bxx.product p " + " FORCE INDEX (index_wx_safe_status) " + //" LEFT JOIN bxx.jst_supplier_ban_platform b ON (p.skc_id=b.coid or p.real_coid=b.coid)" + " WHERE p.is_del=0"; string where = ""; //where += " AND (b.ban_wx IS NULL OR b.ban_wx=0)"; if (!string.IsNullOrEmpty(from_shop_id)) where += " and p.from_shop_id ='" + from_shop_id + "'"; if (!string.IsNullOrEmpty(from_shop_name)) where += " and p.from_shop_name ='" + from_shop_name + "'"; if (!string.IsNullOrEmpty(search_db_ids)) where += " and p.id in (" + search_db_ids + ")"; if (!string.IsNullOrEmpty(search_secret_spu_ids)) where += " and p.secret_spu_id in ('" + string.Join("','", search_secret_spu_ids.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries)) + "')"; if (!string.IsNullOrWhiteSpace(ext_code_in)) where += " and p.ext_code in ('" + string.Join("','", ext_code_in.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries)) + "')"; 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 in ('" + wx_safe_status.Replace(",", "','") + "')"; //if (!string.IsNullOrEmpty(wx_safe_status)) //{ // where += " and ("; // var index = 0; // foreach (var status in wx_safe_status.Split(new string[] { ",", ",", " " }, StringSplitOptions.RemoveEmptyEntries)) // { // index++; // if (index == 1) // where += " p.wx_safe_status='" + status + "'"; // else // where += " or p.wx_safe_status='" + status + "'"; // } // where += ") "; //} if (!string.IsNullOrEmpty(special_prod_type)) where += " and p.special_prod_type in ('" + special_prod_type.Replace(",", "','") + "')"; if (!string.IsNullOrWhiteSpace(search_spu)) { if (search_spu.Contains(",") || search_spu.Contains(",") || search_spu.Contains(";") || search_spu.Contains(";")) where += " and p.spu_id in ('" + string.Join("','", search_spu.Split(new string[] { ",", ",", ";", ";" }, StringSplitOptions.RemoveEmptyEntries)) + "')"; else 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_cat1)) where += " and p.main_cat_name like '%" + search_cat1 + "%'"; if (!string.IsNullOrWhiteSpace(search_ext_code)) where += " and p.ext_code like '%" + search_ext_code + "%'"; if (!string.IsNullOrWhiteSpace(search_prod_name)) { var searchProdNameWords = search_prod_name.Split(new string[] { ",", ",", ";", ";", "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries); var multi_search_prod_name = ""; var index = 0; foreach (var word in searchProdNameWords) { index++; string parameName = "@prodNameWords" + index; paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = parameName, Value = word/*.Replace("&", "&").Replace("'", "\\'")*/, }); //multi_search_prod_name += " or p.product_name like '%" + parameName + "%'"; multi_search_prod_name += " or p.product_name like CONCAT('%'," + parameName + ",'%')"; } where += " and (" + multi_search_prod_name.Substring(4) + ")"; } if (!string.IsNullOrWhiteSpace(search_group)) { if (search_group == "无分组") where += " and (p.group is null or p.group = '')"; else where += " and p.group like '%" + search_group + "%'"; } if (!string.IsNullOrWhiteSpace(search_notes)) where += " and p.notes like '%" + search_notes + "%'"; if (!string.IsNullOrWhiteSpace(wx_cat_1)) where += " and p.wx_cat_1 in (" + wx_cat_1 + ")"; if (!string.IsNullOrWhiteSpace(wx_cat_2)) where += " and p.wx_cat_2 in (" + wx_cat_2 + ")"; if (!string.IsNullOrWhiteSpace(wx_cat_3)) where += " and p.wx_cat_3 in (" + wx_cat_3 + ")"; if (!string.IsNullOrWhiteSpace(wx_cat_leaf)) where += " and p.wx_cat_leaf in (" + wx_cat_leaf + ")"; if (!string.IsNullOrEmpty(has_wx_cat)) { if (has_wx_cat.ToLower() == "true") where += " and wx_cat_leaf is NOT NULL"; else where += " and wx_cat_leaf is NULL"; } if (!string.IsNullOrEmpty(send_to_out_server)) where += " and send_to_out_server=" + send_to_out_server; else if (!string.IsNullOrEmpty(has_send_to_out_server)) { if (has_send_to_out_server.ToLower() == "true") where += " and send_to_out_server=1"; else where += " and send_to_out_server!=1"; } // 供应商货源是否已完成初始设置 if (!string.IsNullOrEmpty(is_supplier_prod_ok)) { //if (is_supplier_prod_ok == "1" || is_supplier_prod_ok == "已设置") // where += " and wx_cat_leaf IS NOT NULL and send_to_out_server=1 and delivery_fee_set=1 and after_sale_set=1 and distribution_set=1"; //else // where += " and (wx_cat_leaf IS NULL or send_to_out_server=0 or delivery_fee_set=0 or after_sale_set=0 or distribution_set=0)"; if (is_supplier_prod_ok == "1" || is_supplier_prod_ok == "已设置") where += " and wx_cat_leaf IS NOT NULL and send_to_out_server=1 and distribution_set=1"; else where += " and (wx_cat_leaf IS NULL or send_to_out_server!=1 or distribution_set=0)"; } if (!string.IsNullOrEmpty(real_coid)) { where += " and real_coid='" + real_coid + "'"; } if (!string.IsNullOrEmpty(has_wx_format)) { where += " and has_wx_format='" + has_wx_format + "'"; } if (!string.IsNullOrEmpty(problem_prod_data)) { if (problem_prod_data.ToLower().Contains("is null")) where += " and p.problem_prod_data " + problem_prod_data; else where += " and p.problem_prod_data='" + problem_prod_data + "'"; } if (!string.IsNullOrEmpty(is_relation)) { where += " and p.is_relation=" + is_relation; } if (start_time != null && end_time != null) { where += " and p.mdy_time between '" + start_time + "' and '" + end_time + "'"; } if (ban_wx != null) { where += " and p.ban_wx=" + ban_wx; } if (ban_pdd != null) { where += " and p.ban_pdd=" + ban_pdd; } if (!string.IsNullOrEmpty(add_user_name)) { add_user_name = "'" + string.Join("','", add_user_name.Split(new string[] { ",", ",", " " }, StringSplitOptions.RemoveEmptyEntries)) + "'"; where += " and p.add_user_name in (" + add_user_name + ")"; } sql += where; var count = 0; if (isDetail) count = 1; else count = mySql.ExecuteRowCount(sql, paramLst.ToArray()); 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" + //" LEFT JOIN bxx.jst_supplier_ban_platform b ON (p.skc_id=b.coid or p.real_coid=b.coid)" + " 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,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.wx_cat_leaf,p.send_to_out_server,p.secret_spu_id,p.real_coid,p.real_spu_id,p.is_relation," + " 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" + //" LEFT JOIN bxx.jst_supplier_ban_platform b ON (p.skc_id=b.coid or p.real_coid=b.coid)" + " 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,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.wx_cat_leaf,p.send_to_out_server,p.secret_spu_id,p.real_coid,p.real_spu_id,p.is_relation," + " 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" + //" LEFT JOIN bxx.jst_supplier_ban_platform b ON (p.skc_id=b.coid or p.real_coid=b.coid)" + " 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, paramLst.ToArray()); } mySql.Close(); if (dt != null) { try { List productLst = new List(); foreach (DataRow row in dt.Rows) { DBProductResultParam prod = new DBProductResultParam { id = Convert.ToInt32(row["id"]), from_shop_id = row["from_shop_id"].ToString(), from_shop_name = row["from_shop_name"].ToString(), //offline_supplier_id = row["offline_supplier_id"].ToString(), //offline_supplier_name = row["offline_supplier_name"].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(), wx_cat_1 = row["wx_cat_1"].ToString(), wx_cat_2 = row["wx_cat_2"].ToString(), wx_cat_3 = row["wx_cat_3"].ToString(), wx_cat_leaf = row["wx_cat_leaf"].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(), 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(), main_cat_id = row["main_cat_id"].ToString(), main_cat_name = row["main_cat_name"].ToString(), send_to_out_server = row["send_to_out_server"].ParseToInt(), secret_spu_id = row["secret_spu_id"].IsNullOrEmpty() ? null : row["secret_spu_id"].ParseToString(), real_coid = row["real_coid"].IsNullOrEmpty() ? null : row["real_coid"].ParseToString(), real_spu_id = row["real_spu_id"].IsNullOrEmpty() ? null : row["real_spu_id"].ParseToString(), is_relation = row["is_relation"].ParseToInt(), }; 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_secret_json = row["sku_secret_json"].ToString(); prod.fission_imgs = row["fission_imgs"].ToString(); prod.has_wx_format = row["has_wx_format"].ParseToNullableString(); // 微信回采 prod.sku_img_replace_base64 = row["img_base64"].ToString(); //prod.sku_img_replace_url = row["img_url"].ToString(); prod.wx_img_map_json = row["wx_img_map_json"].ToString(); problem_prod_data = row["problem_prod_data"].IsNullOrEmpty() ? null : row["problem_prod_data"].ParseToString(); if (!prod.sku_secret_json.IsNullOrEmpty() && prod.secret_spu_id.IsNullOrEmpty()) { var secret_json = prod.sku_secret_json; var goodsId = RegexUtils.GetStringJson(ref secret_json, "goodsId"); prod.secret_spu_id = goodsId; if (!string.IsNullOrWhiteSpace(goodsId)) { mySql = new MysqlUtils(conn); try { sql = "update bxx.product set secret_spu_id='" + goodsId + "' where spu_id='" + prod.spu_id + "'"; mySql.ExecuteNonQuery(sql); } catch { } mySql.Close(); } } } if (!string.IsNullOrEmpty(get_select_count)) { prod.select_count = row["select_count"].ParseToInt(); } productLst.Add(prod); } JsonSerializerSettings jsonSetting = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }; var data = JsonUtils.SerializeObjectToString(productLst, jsonSetting); var seconds = (DateTime.Now - timeCalc).TotalSeconds.ToString("0.000"); return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"count\":" + count + ",\"seconds\":" + seconds + "}"; } 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 AddProdWXComplate(string inputData) { if (!string.IsNullOrEmpty(inputData)) { var timeCalc = DateTime.Now; 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 (user_name.IsNullOrEmpty()) { return "{\"code\":500,\"msg\":\"用户信息不能为空\"}"; } var spu_id = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "spu_id")).ParseToString().Replace("'", "\\'"); var coid = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "coid")).ParseToString().Replace("'", "\\'"); var secret_spu_id = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "secret_spu_id")).ParseToString().Replace("'", "\\'"); var wx_edit_prod_json = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "wx_edit_prod_json")).ParseToString().Replace("'", "\\'"); if (secret_spu_id.IsNullOrEmpty() || wx_edit_prod_json.IsNullOrEmpty()) { return "{\"code\":500,\"msg\":\"商品回采数据不能为空\"}"; } string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString; MysqlUtils mySql = new MysqlUtils(conn); string sql = ""; sql = "INSERT INTO bxx.product_wx_complate (spu_id,coid,secret_spu_id,wx_edit_prod_json) VALUES " + " ('" + spu_id + "','" + coid + "','" + secret_spu_id + "','" + wx_edit_prod_json + "')" + " ON DUPLICATE KEY UPDATE spu_id=VALUES(spu_id),coid=VALUES(coid),wx_edit_prod_json=VALUES(wx_edit_prod_json);"; var rst = mySql.ExecuteNonQuery(sql); if (!rst || !string.IsNullOrEmpty(mySql.Message)) { mySql.Close(); return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}"; } sql = "UPDATE bxx.product set has_wx_format='1' where secret_spu_id='" + secret_spu_id + "'"; rst = mySql.ExecuteNonQuery(sql); mySql.Close(); if (!rst || !string.IsNullOrEmpty(mySql.Message)) { return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}"; } else { var seconds = (DateTime.Now - timeCalc).TotalSeconds.ToString("0.000"); return "{\"code\":200,\"msg\":\"success\",\"seconds\":" + seconds + "}"; } } return "{\"code\":19999,\"msg\":\"输入为空\"}"; } /// /// 查询回采微信小店属性等商品数据 /// /// /// public string GetProdWXComplateList(string inputData) { if (!string.IsNullOrEmpty(inputData)) { var timeCalc = DateTime.Now; 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 (user_name.IsNullOrEmpty()) { return "{\"code\":500,\"msg\":\"用户信息不能为空\"}"; } var spu_id = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "spu_id")).ParseToString().Replace("'", "\\'"); var coid = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "coid")).ParseToString().Replace("'", "\\'"); var search_secret_spu_ids = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "search_secret_spu_ids")).ParseToString().Replace("'", "\\'"); if (search_secret_spu_ids.IsNullOrEmpty()) { return "{\"code\":500,\"msg\":\"商品回采数据编号不能为空\"}"; } int page = RegexUtils.GetStringQuery(ref inputData, "page").ParseToInt(); int page_size = RegexUtils.GetStringQuery(ref inputData, "page_size").ParseToInt(1000); string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString; MysqlUtils mySql = new MysqlUtils(conn); string sql = "select id,spu_id,coid,secret_spu_id,wx_edit_prod_json,add_time" + " from bxx.product_wx_complate p where 1=1"; if (search_secret_spu_ids != null) { sql += " and p.secret_spu_id in ('" + string.Join("','", search_secret_spu_ids.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries)) + "')"; } sql += " limit " + Math.Max(page - 1, 0) * page_size + "," + page_size; var dt = mySql.ExecuteDataTable(sql); mySql.Close(); if (dt != null) { try { JArray wxProdComplateArr = new JArray(); foreach (DataRow row in dt.Rows) { JObject wxProdComplateObj = new JObject(); wxProdComplateObj["id"] = Convert.ToInt32(row["id"]); wxProdComplateObj["spu_id"] = row["spu_id"].ToString(); wxProdComplateObj["coid"] = row["coid"].ToString(); wxProdComplateObj["secret_spu_id"] = row["secret_spu_id"].ToString(); wxProdComplateObj["wx_edit_prod_json"] = row["wx_edit_prod_json"].ToString(); wxProdComplateObj["add_time"] = Convert.ToDateTime(row["add_time"]); wxProdComplateArr.Add(wxProdComplateObj); } JsonSerializerSettings jsonSetting = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }; var data = JsonUtils.SerializeObjectToString(wxProdComplateArr, jsonSetting); var seconds = (DateTime.Now - timeCalc).TotalSeconds.ToString("0.000"); return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"count\":" + wxProdComplateArr.Count + ",\"seconds\":" + seconds + "}"; } 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\":\"输入为空\"}"; } /// /// 新增下架sku /// /// /// public string AddProdDownSku(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 password = RegexUtils.GetStringQuery(ref inputData, "password")?.Replace("'", "\\'"); var itemMainImage = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "itemMainImage")).ParseToString().Replace("'", "\\'"); var itemName = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "itemName")).ParseToString().Replace("'", "\\'"); var styleCode = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "styleCode")).ParseToString().Replace("'", "\\'"); var itemCode = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "itemCode")).ParseToString().Replace("'", "\\'"); var colourSpec = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "colourSpec")).ParseToString().Replace("'", "\\'"); var supplyPrice = RegexUtils.GetStringQuery(ref inputData, "supplyPrice").ParseToString().Replace("'", "\\'"); var supplierName = RegexUtils.GetStringQuery(ref inputData, "supplierName").ParseToString().Replace("'", "\\'"); var shelvesTime = RegexUtils.GetStringQuery(ref inputData, "shelvesTime").ParseToString().Replace("'", "\\'"); var supplierCoId = RegexUtils.GetStringQuery(ref inputData, "supplierCoId").ParseToString().Replace("'", "\\'"); var coId = RegexUtils.GetStringQuery(ref inputData, "coId").ParseToString().Replace("'", "\\'"); var spuId = RegexUtils.GetStringQuery(ref inputData, "spuId").ParseToString().Replace("'", "\\'"); var partnerSkuId = RegexUtils.GetStringQuery(ref inputData, "partnerSkuId").ParseToString().Replace("'", "\\'"); var partnerSpuId = RegexUtils.GetStringQuery(ref inputData, "partnerSpuId").ParseToString().Replace("'", "\\'"); var supplierId = RegexUtils.GetStringQuery(ref inputData, "supplierId").ParseToString().Replace("'", "\\'"); var drpItemStatus = RegexUtils.GetStringQuery(ref inputData, "drpItemStatus").ParseToString().Replace("'", "\\'"); var lastOperator = RegexUtils.GetStringQuery(ref inputData, "lastOperator").ParseToString().Replace("'", "\\'"); var itemSpuIdMd5 = RegexUtils.GetStringQuery(ref inputData, "itemSpuIdMd5").ParseToString().Replace("'", "\\'"); var secret_spu_id = RegexUtils.GetStringQuery(ref inputData, "secret_spu_id").ParseToString().Replace("'", "\\'"); var secret_sku_id = RegexUtils.GetStringQuery(ref inputData, "secret_sku_id").ParseToString().Replace("'", "\\'"); var is_in_product_db = RegexUtils.GetStringQuery(ref inputData, "is_in_product_db").ParseToInt(); string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString; MysqlUtils mySql = new MysqlUtils(conn); string sql = ""; sql = "select styleCode,itemCode,colourSpec from bxx.product_jst_update where styleCode='" + styleCode + "' and itemCode='" + itemCode + "' and colourSpec='" + colourSpec + "'"; var dt = mySql.ExecuteDataTable(sql); if (!string.IsNullOrEmpty(mySql.Message)) { mySql.Close(); return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}"; } if (dt.Rows.Count > 0) { mySql.Close(); return "{\"code\":500,\"msg\":\"数据已存在\"}"; } sql = "insert into bxx.product_jst_update " + " (itemMainImage,itemName,styleCode,itemCode,colourSpec,supplyPrice,supplierName,shelvesTime,supplierCoId,coId,spuId," + " partnerSkuId,partnerSpuId,supplierId,drpItemStatus,lastOperator,itemSpuIdMd5,secret_spu_id,secret_sku_id,is_in_product_db)" + " values('" + itemMainImage + "','" + itemName + "','" + styleCode + "','" + itemCode + "','" + colourSpec + "','" + supplyPrice + "','" + supplierName + "','" + shelvesTime + "','" + supplierCoId + "','" + coId + "','" + spuId + "','" + partnerSkuId + "','" + partnerSpuId + "','" + supplierId + "','" + drpItemStatus + "','" + lastOperator + "','" + itemSpuIdMd5 + "','" + secret_spu_id + "','" + secret_sku_id + "'," + is_in_product_db + ")"; //var rst = mySql.ExecuteNonQuery(sql, paramLst.ToArray()); 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\":\"输入为空\"}"; } /// /// 查询下架sku /// /// /// public string GetProdDownSkuLstBySkuCodes(string inputData) { var timeCalc = DateTime.Now; 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 version = RegexUtils.GetStringQuery(ref inputData, "version").ParseToInt(); //if (version < (System.Configuration.ConfigurationManager.ConnectionStrings["LimitVersion"]?.ConnectionString).ParseToInt()) // return "{\"code\":1,\"msg\":\"当前版本过于陈旧,请立即升级新版\"}"; var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name")?.Replace("'", "\\'"); var password = RegexUtils.GetStringQuery(ref inputData, "password")?.Replace("'", "\\'"); var search_spu_ids = RegexUtils.GetStringQuery(ref inputData, "search_spu_ids")?.Replace("'", "\\'"); var search_sku_codes = RegexUtils.GetStringQuery(ref inputData, "search_sku_codes")?.Replace("'", "\\'"); var search_secret_spu_ids = RegexUtils.GetStringQuery(ref inputData, "search_secret_spu_ids")?.Replace("'", "\\'"); if (search_spu_ids.IsNullOrEmpty() && search_sku_codes.IsNullOrEmpty() && search_secret_spu_ids.IsNullOrEmpty()) return "{\"code\":500,\"msg\":\"查询条件不能全部为空\",\"data\":[],\"count\":" + 0 + "}"; int page = RegexUtils.GetStringQuery(ref inputData, "page").ParseToInt(); int page_size = RegexUtils.GetStringQuery(ref inputData, "page_size").ParseToInt(1000); string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString; MysqlUtils mySql = new MysqlUtils(conn); string sql = "select id,spuId,itemName,styleCode,itemCode,colourSpec,supplierCoId,supplierName,is_in_product_db,secret_spu_id,secret_sku_id,add_time" + " from bxx.product_jst_update p where 1=1"; if (search_secret_spu_ids != null) { sql += " and p.secret_spu_id in ('" + string.Join("','", search_secret_spu_ids.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries)) + "')"; } if (search_spu_ids != null) { sql += " and p.spuId in ('" + string.Join("','", search_spu_ids.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries)) + "')"; } if (search_sku_codes != null) { sql += " and p.itemCode in ('" + string.Join("','", search_sku_codes.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries)) + "')"; } sql += " limit " + Math.Max(page - 1, 0) * page_size + "," + page_size; var dt = mySql.ExecuteDataTable(sql); mySql.Close(); if (dt != null) { try { List productLst = new List(); foreach (DataRow row in dt.Rows) { JSTDownProdSkuInfo prod = new JSTDownProdSkuInfo { id = Convert.ToInt32(row["id"]), spuId = row["spuId"].ToString(), itemName = row["itemName"].ToString(), styleCode = row["styleCode"].ToString(), itemCode = row["itemCode"].ToString(), colourSpec = row["colourSpec"].ToString(), supplierCoId = row["supplierCoId"].ToString(), supplierName = row["supplierName"].ToString(), add_time = Convert.ToDateTime(row["add_time"]), is_in_product_db = row["is_in_product_db"].ParseToInt(), secret_spu_id = row["secret_spu_id"].ParseToString(), secret_sku_id = row["secret_sku_id"].ParseToString(), }; productLst.Add(prod); } JsonSerializerSettings jsonSetting = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }; var data = JsonUtils.SerializeObjectToString(productLst, jsonSetting); var seconds = (DateTime.Now - timeCalc).TotalSeconds.ToString("0.000"); return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"count\":" + productLst.Count + ",\"seconds\":" + seconds + "}"; } 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 GetProductGroups(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(200); var product_get_type = RegexUtils.GetStringQuery(ref inputData, "product_get_type")?.Replace("'", "\\'"); var add_user_name = RegexUtils.GetStringQuery(ref inputData, "add_user_name")?.Replace("'", "\\'"); 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 = ""; if (!string.IsNullOrEmpty(product_get_type)) where += " and p.product_get_type ='" + product_get_type + "'"; if (!string.IsNullOrEmpty(add_user_name)) { add_user_name = "'" + string.Join("','", add_user_name.Split(new string[] { ",", ",", " " }, StringSplitOptions.RemoveEmptyEntries)) + "'"; where += " and p.add_user_name in (" + add_user_name + ")"; } 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 GetProductCates(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\":\"输入为空\"}"; } public string GetProductMainCates(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 sql = "SELECT DISTINCT p.main_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["main_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\":\"输入为空\"}"; } /// /// 查询商品替换sku /// /// /// /// public string GetSkuImgReplaceList(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 sku_img_replace_ids = RegexUtils.GetStringQuery(ref inputData, "sku_img_replace_ids")?.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(*) from bxx.sku_img_replace s where 1=1"; string where = ""; if (!string.IsNullOrWhiteSpace(sku_img_replace_ids)) where += " and s.id in (" + sku_img_replace_ids + ")"; sql += where; var count = mySql.ExecuteRowCount(sql); DataTable dt; if (count == 0) { dt = new DataTable(); } else { sql = "select * from bxx.sku_img_replace s where 1=1"; //where子句 sql += where; sql += " order by s.img_type asc, s.id desc"; sql += " limit " + Math.Max(page - 1, 0) * page_size + "," + page_size; dt = mySql.ExecuteDataTable(sql); } mySql.Close(); if (dt != null) { try { List skuImgReplaceLst = new List(); foreach (DataRow row in dt.Rows) { sku_img_replace skuImgReplace = new sku_img_replace { id = Convert.ToInt32(row["id"]), //img_base64 = row["img_base64"].ToString(), img_md5 = row["img_md5"].ToString(), img_url = row["img_url"].ToString(), add_time = Convert.ToDateTime(row["add_time"]), mdy_time = Convert.ToDateTime(row["mdy_time"]), img_type = row["img_type"].ToString(), img_group = row["img_group"].ToString(), }; if (isDetail) { skuImgReplace.img_base64 = row["img_base64"].ToString(); } skuImgReplaceLst.Add(skuImgReplace); } var data = JsonUtils.SerializeObjectToString(skuImgReplaceLst); 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 GetProductListRandom(string inputData) { var timeCalc = DateTime.Now; 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_spu_ids = RegexUtils.GetStringQuery(ref inputData, "in_spu_ids")?.Replace("'", "\\'"); var in_skc_ids = RegexUtils.GetStringQuery(ref inputData, "in_skc_ids")?.Replace("'", "\\'"); var in_groups = RegexUtils.GetStringQuery(ref inputData, "in_groups")?.Replace("'", "\\'"); var product_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "product_name"))?.Replace("'", "\\'"); var in_cates = RegexUtils.GetStringQuery(ref inputData, "in_cates")?.Replace("'", "\\'"); var wx_cat_1 = RegexUtils.GetStringQuery(ref inputData, "wx_cat_1")?.Replace("'", "\\'"); var wx_cat_2 = RegexUtils.GetStringQuery(ref inputData, "wx_cat_2")?.Replace("'", "\\'"); var wx_cat_3 = RegexUtils.GetStringQuery(ref inputData, "wx_cat_3")?.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("'", "\\'"); var is_supplier_prod_ok = RegexUtils.GetStringQuery(ref inputData, "is_supplier_prod_ok")?.Replace("'", "\\'"); var is_not_count = RegexUtils.GetStringQuery(ref inputData, "is_not_count").ParseToBool(); // 不计数 var prod_count = RegexUtils.GetStringQuery(ref inputData, "prod_count").ParseToInt(); var add_days_less = RegexUtils.GetStringQuery(ref inputData, "add_days_less").ParseToNullableInt(); 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("'", "\\'"); var ban_pdd = RegexUtils.GetStringQuery(ref inputData, "ban_pdd")?.Replace("'", "\\'"); var add_user_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "add_user_name"))?.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(*)" + " FROM bxx.product p" + " FORCE INDEX (index_wx_safe_status)" + //" LEFT JOIN bxx.jst_supplier_ban_platform b ON (p.skc_id=b.coid or p.real_coid=b.coid)" + " WHERE p.is_del=0"; string where = ""; //where += " AND (b.ban_wx IS NULL OR b.ban_wx=0)"; 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_spu_ids)) { in_spu_ids = "'" + string.Join("','", in_spu_ids.Split(new string[] { ",", ",", " " }, StringSplitOptions.RemoveEmptyEntries)) + "'"; where += " and p.spu_id in (" + in_spu_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 + "))"; } if (!string.IsNullOrEmpty(product_name)) { where += " and p.product_name='" + product_name + "'"; } if (!string.IsNullOrEmpty(wx_cat_1)) { where += " and p.wx_cat_1 in (" + wx_cat_1 + ")"; } if (!string.IsNullOrEmpty(wx_cat_2)) { where += " and p.wx_cat_2 in (" + wx_cat_2 + ")"; } if (!string.IsNullOrEmpty(wx_cat_3)) { where += " and p.wx_cat_3 in (" + wx_cat_3 + ")"; } 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 in ('" + wx_safe_status.Replace(",", "','") + "')"; //if (!string.IsNullOrEmpty(special_prod_type)) // 普通商品 爆款商品 // where += " and p.special_prod_type ='" + special_prod_type + "'"; sql += " and p.special_prod_type in ('普通商品','书籍')"; // 供应商货源是否已完成初始设置 if (!string.IsNullOrEmpty(is_supplier_prod_ok)) { if (is_supplier_prod_ok == "1" || is_supplier_prod_ok == "已设置") where += " and wx_cat_leaf IS NOT NULL and send_to_out_server=1 and distribution_set=1"; else where += " and (wx_cat_leaf IS NULL or send_to_out_server!=1 or distribution_set=0)"; } if (!add_days_less.IsNullOrZero()) { where += " and add_time > '" + DateTime.Now.AddDays(-add_days_less.ParseToInt()).ToString("yyyy-MM-dd") + "'"; } if (!has_wx_format.IsNullOrEmpty()) { where += " and has_wx_format = '" + has_wx_format + "'"; } if (is_relation != null) { where += " and is_relation = " + is_relation; } if (ban_wx != null) { where += " and p.ban_wx=" + ban_wx; } if (ban_pdd != null) { where += " and p.ban_pdd=" + ban_pdd; } if (!string.IsNullOrEmpty(add_user_name)) { add_user_name = "'" + string.Join("','", add_user_name.Split(new string[] { ",", ",", " " }, StringSplitOptions.RemoveEmptyEntries)) + "'"; where += " and p.add_user_name in (" + add_user_name + ")"; } sql += where; int count = prod_count; if (product_get_type == "厂商直采" && count > 1000) count = (count / 2.0).ParseToInt(); if (!is_not_count) { count = mySql.ExecuteRowCount(sql); Thread.Sleep(1500); } DataTable dt; if (count == 0 && !is_not_count) { dt = new DataTable(); } else { sql = " SELECT p.id" + " FROM bxx.product p" + //" LEFT JOIN bxx.jst_supplier_ban_platform b ON (p.skc_id=b.coid OR p.real_coid=b.coid)" + " WHERE p.is_del=0"; //where子句 sql += where; sql += " ORDER BY RAND()"; sql += " limit " + Math.Max(page - 1, 0) * page_size + "," + page_size; //var limit = RandomUtils.GetId(Math.Max(0, count - page_size)); //sql += " limit " + limit + "," + 5000; dt = mySql.ExecuteDataTable(sql); Thread.Sleep(100); if (!string.IsNullOrEmpty(mySql.Message) || dt == null) { mySql.Close(); return "{\"code\":500,\"msg\":\"" + mySql.Message + "\",\"data\":[],\"count\":" + 0 + "}"; } var db_ids = string.Join(",", dt.Rows.Cast().Select(r => r["id"].ParseToInt()).OrderBy(x => RandomUtils.GetId(10000000)).Take(page_size)); 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.product_get_type," + " p.wx_safe_status,p.special_prod_type,p.wx_cat_1,p.wx_cat_2,p.wx_cat_3,p.send_to_out_server," + " p.wx_cat_leaf,p.is_relation" + " from bxx.product p where p.is_del=0"; //where子句 //sql += where; sql += " and id in (" + db_ids + ")"; //sql += " ORDER BY RAND()"; //sql += " limit " + Math.Max(page - 1, 0) * page_size + "," + page_size; dt = mySql.ExecuteDataTable(sql); } mySql.Close(); Thread.Sleep(500); if (dt != null) { try { List productLst = new List(); foreach (DataRow row in dt.Rows) { DBProductResultParam prod = new DBProductResultParam { id = Convert.ToInt32(row["id"]), from_shop_id = row["from_shop_id"].ToString(), spu_id = row["spu_id"].ToString(), skc_id = row["skc_id"].ToString(), main_cat_id = row["main_cat_id"].ToString(), main_cat_name = row["main_cat_name"].ToString(), cat_id = row["cat_id"].ToString(), cat_name = row["cat_name"].ToString(), wx_cat_1 = row["wx_cat_1"].ToString(), wx_cat_2 = row["wx_cat_2"].ToString(), wx_cat_3 = row["wx_cat_3"].ToString(), wx_cat_leaf = row["wx_cat_leaf"].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(), add_time = Convert.ToDateTime(row["add_time"]), mdy_time = Convert.ToDateTime(row["mdy_time"]), group = row["group"].ToString(), notes = row["notes"].ToString(), product_get_type_text = row["product_get_type"].ParseToString(), //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(), send_to_out_server = row["send_to_out_server"].ParseToInt(), is_relation = row["is_relation"].ParseToInt(), }; productLst.Add(prod); } JsonSerializerSettings jsonSetting = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }; var data = JsonUtils.SerializeObjectToString(productLst, jsonSetting); var seconds = (DateTime.Now - timeCalc).TotalSeconds.ToString("0.000"); if (product_get_type == "厂商直采" && count > 500) count = (count * 2.0).ParseToInt(); return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"count\":" + count + ",\"seconds\":" + seconds + "}"; } 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\":\"输入为空\"}"; } /// /// 获取拼多多商品随机sku替换图 /// /// /// public string GetSkuReplaceImgListRandom(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 password = RegexUtils.GetStringQuery(ref inputData, "password")?.Replace("'", "\\'"); var in_img_type = RegexUtils.GetStringQuery(ref inputData, "in_img_type")?.Replace("'", "\\'"); var in_img_group = RegexUtils.GetStringQuery(ref inputData, "in_img_group")?.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(*) from bxx.sku_img_replace s where 1=1"; string where = ""; if (!string.IsNullOrWhiteSpace(in_img_type) && !string.IsNullOrWhiteSpace(in_img_group)) { in_img_type = "'" + string.Join("','", in_img_type.Split(new string[] { ",", ",", " " }, StringSplitOptions.RemoveEmptyEntries)) + "'"; in_img_group = "'" + string.Join("','", in_img_group.Split(new string[] { ",", ",", " " }, StringSplitOptions.RemoveEmptyEntries)) + "'"; where += " and (s.img_type in (" + in_img_type + ") or s.img_group in (" + in_img_group + ")"; } else if (!string.IsNullOrWhiteSpace(in_img_type)) { in_img_type = "'" + string.Join("','", in_img_type.Split(new string[] { ",", ",", " " }, StringSplitOptions.RemoveEmptyEntries)) + "'"; where += " and s.img_type in (" + in_img_type + ")"; } else if (!string.IsNullOrWhiteSpace(in_img_group)) { in_img_group = "'" + string.Join("','", in_img_group.Split(new string[] { ",", ",", " " }, StringSplitOptions.RemoveEmptyEntries)) + "'"; where += " and s.img_group in (" + in_img_group + ")"; } sql += where; var count = mySql.ExecuteRowCount(sql); DataTable dt; if (count == 0) { dt = new DataTable(); } else { sql = "select s.img_url from bxx.sku_img_replace s where 1=1"; //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 imgs = new List(); foreach (DataRow row in dt.Rows) { imgs.Add(row["img_url"].ToString()); } var data = JsonUtils.SerializeObjectToString(imgs); 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("'", "\\'"); if (string.IsNullOrEmpty(user_name)) { return "{\"code\":500,\"msg\":\"没有用户名\"}"; } var id = RegexUtils.GetStringQuery(ref inputData, "db_id")?.Replace("'", "\\'"); if (string.IsNullOrEmpty(id)) { return "{\"code\":500,\"msg\":\"删除失败:请指定要删除的数据!\"}"; } string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString; MysqlUtils mySql = new MysqlUtils(conn); //string sql = "delete from bxx.product where id='" + id + "'"; string sql = "update bxx.product set is_del=1 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 MdyProductNotes(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 notes = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "notes"))?.Replace("'", "\\'"); if (string.IsNullOrEmpty(user_name)) { return "{\"code\":500,\"msg\":\"没有用户名\"}"; } string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString; MysqlUtils mySql = new MysqlUtils(conn); string sql = "update bxx.product set"; if (notes != null) sql += " notes='" + notes + "',"; 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 MdyDBProduct(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\":\"校验失败\"}"; string user_name = RegexUtils.GetStringQuery(ref inputData, "user_name")?.Replace("'", "\\'"); string id = RegexUtils.GetStringQuery(ref inputData, "db_id")?.Replace("'", "\\'"); string in_db_ids = RegexUtils.GetStringQuery(ref inputData, "in_db_ids")?.Replace("'", "\\'"); string product_name = RegexUtils.GetStringQuery(ref inputData, "product_name")?.Replace("'", "\\'"); string group = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "group"))?.Replace("'", "\\'"); string notes = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "notes"))?.Replace("'", "\\'"); string ext_code = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "ext_code"))?.Replace("'", "\\'"); string fission_imgs = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "fission_imgs"))?.Replace("'", "\\'"); string fission_words = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "fission_words"))?.Replace("'", "\\'"); string head_words = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "head_words"))?.Replace("'", "\\'"); 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(special_prod_type) && special_prod_type != "爆款商品") special_prod_type = "普通商品"; if (string.IsNullOrEmpty(user_name)) { return "{\"code\":500,\"msg\":\"没有用户名\"}"; } string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString; MysqlUtils mySql = new MysqlUtils(conn); string sql = "update bxx.product p set"; if (product_name != null) sql += " p.product_name='" + product_name + "',"; if (group != null) sql += " p.group='" + group + "',"; if (notes != null) sql += " p.notes='" + notes + "',"; if (ext_code != null) sql += " p.ext_code='" + ext_code + "',"; if (fission_imgs != null) sql += " p.fission_imgs='" + fission_imgs + "',"; if (fission_words != null) sql += " p.fission_words='" + fission_words + "',"; if (head_words != null) sql += " p.head_words='" + head_words + "',"; if (end_words != null) sql += " p.end_words='" + end_words + "',"; if (sku_edit_json != null) 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) { sql += " where id in (" + in_db_ids + ");"; } else { 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 AddSkuImgReplace(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_db_id = RegexUtils.GetStringQuery(ref inputData, "product_db_id"); string img_url = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "img_url")); string img_type = RegexUtils.GetStringQuery(ref inputData, "img_type")?.Replace("'", "\\'"); string img_group = RegexUtils.GetStringQuery(ref inputData, "img_group")?.Replace("'", "\\'"); if (string.IsNullOrEmpty(user_name)) { return "{\"code\":500,\"msg\":\"没有用户名\"}"; } //int sku_img_replace_id = 0; string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString; MysqlUtils mySql = new MysqlUtils(conn); string sql = ""; sql = "select id from bxx.sku_img_replace where img_md5='" + img_md5 + "';"; var bRst = false; var rst = mySql.ExecuteFirstInt(sql).ParseToLong(); if (rst <= 0) { sql = "insert into bxx.sku_img_replace (img_md5,img_base64,img_url,img_type,img_group) " + "values ('" + img_md5 + "','" + img_base64 + "','" + img_url + "','" + img_type + "','" + img_group + "');"; rst = mySql.ExecuteInsertId(sql); } if (rst > 0) { //sku_img_replace_id = (int)rst; //sql = "update bxx.product set sku_img_replace_id= "+ sku_img_replace_id + " where id=" + product_db_id + ";"; //bRst = mySql.ExecuteNonQuery(sql); bRst = true; } mySql.Close(); if (rst > 0 && bRst) { return "{\"code\":200,\"msg\":\"success\",\"sku_img_replace_id\":" + rst + "}"; } return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}"; } return "{\"code\":19999,\"msg\":\"输入为空\"}"; } public string MdyProdSkuImgReplaceId(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 product_db_id = RegexUtils.GetStringQuery(ref inputData, "product_db_id"); string img_db_id = RegexUtils.GetStringQuery(ref inputData, "img_db_id"); if (string.IsNullOrEmpty(user_name)) { return "{\"code\":500,\"msg\":\"没有用户名\"}"; } string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString; MysqlUtils mySql = new MysqlUtils(conn); string sql = ""; sql = "update bxx.product set sku_img_replace_id= " + img_db_id + " where id=" + product_db_id + ";"; var bRst = mySql.ExecuteNonQuery(sql); mySql.Close(); if (bRst) return "{\"code\":200,\"msg\":\"success\"}"; return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}"; } return "{\"code\":19999,\"msg\":\"输入为空\"}"; } public string MdySkuImgReplace(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 img_md5 = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "img_md5")); string img_base64 = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "img_base64")); string img_url = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "img_url")); string img_type = RegexUtils.GetStringQuery(ref inputData, "img_type")?.Replace("'", "\\'"); string img_group = RegexUtils.GetStringQuery(ref inputData, "img_group")?.Replace("'", "\\'"); if (string.IsNullOrEmpty(user_name)) { return "{\"code\":500,\"msg\":\"没有用户名\"}"; } string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString; MysqlUtils mySql = new MysqlUtils(conn); string sql = "update bxx.sku_img_replace set"; if (img_md5 != null) sql += " img_md5='" + img_md5 + "',"; if (img_base64 != null) sql += " img_base64='" + img_base64 + "',"; if (img_url != null) sql += " img_url='" + img_url + "',"; if (img_type != null) sql += " img_type='" + img_type + "',"; if (img_group != null) sql += " img_group='" + img_group + "',"; 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 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").Replace("'", "\\'"); string img_md5 = RegexUtils.GetStringQuery(ref inputData, "img_md5").Replace("'", "\\'"); string img_base64 = RegexUtils.GetStringQuery(ref inputData, "img_base64").Replace("'", "\\'"); string img_url = RegexUtils.GetStringQuery(ref inputData, "img_url").Replace("'", "\\'"); if (string.IsNullOrEmpty(user_name)) { return "{\"code\":500,\"msg\":\"没有用户名\"}"; } int sku_img_replace_id = 0; string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString; MysqlUtils mySql = new MysqlUtils(conn); string sql = ""; sql = "select id from bxx.sku_img where img_md5='" + img_md5 + "';"; var bRst = false; var rst = mySql.ExecuteFirstInt(sql).ParseToLong(); if (rst <= 0) { sql = "insert into bxx.sku_img (img_md5,img_base64,img_url) " + "values ('" + img_md5 + "','" + img_base64 + "','" + img_url + "');"; rst = mySql.ExecuteInsertId(sql); if (rst > 0) { mySql.Close(); return "{\"code\":200,\"msg\":\"success\",\"insert_id\":" + rst + "}"; } } else { sku_img_replace_id = (int)rst; sql = "update bxx.sku_img set img_url='" + img_url + "' where img_md5='" + img_md5 + "';"; bRst = mySql.ExecuteNonQuery(sql); if (bRst) { mySql.Close(); return "{\"code\":200,\"msg\":\"success\",\"update_id\":" + rst + "}"; } } mySql.Close(); 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(); var add_fission_product_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "add_fission_product_name").ParseToString())?.Replace("'", "\\'"); if (string.IsNullOrEmpty(user_name)) { return "{\"code\":500,\"msg\":\"没有用户名\"}"; } if (string.IsNullOrEmpty(shop_id)) { return "{\"code\":500,\"msg\":\"没有店铺信息\"}"; } string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString; MysqlUtils mySql = new MysqlUtils(conn); string sql = "insert into bxx.product_select " + "(out_product_Id,shop_id,shop_account,user_name,sub_user_name,notes,status,fission_product_name,add_time,mdy_time) values " + "('" + out_product_Id + "','" + shop_id + "','" + shop_account + "','" + user_name + "','" + sub_user_name + "','" + notes + "','" + status + "','" + add_fission_product_name + "','" + 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.product set select_total_count=select_total_count+1 where id=" + out_product_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 = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString; 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"; // temu商品反复上传后记录一件选品商品上传的所有DraftId记录,pdd不需要 //sql += "insert into kjd_map.product_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.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")?.Replace("'", "\\'"); var search_spu = RegexUtils.GetStringQuery(ref inputData, "search_spu")?.Replace("'", "\\'"); var search_skc = RegexUtils.GetStringQuery(ref inputData, "search_skc")?.Replace("'", "\\'"); var search_cat1 = RegexUtils.GetStringQuery(ref inputData, "search_cat1")?.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_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 = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString; MysqlUtils mySql = new MysqlUtils(conn); string sql = "select count(s.id) from bxx.product_select s " + "left join bxx.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 + "%'"; where += " and p.id_del=0"; 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_cat1)) where += " and p.main_cat_name like '%" + search_cat1 + "%'"; 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; var count = mySql.ExecuteRowCount(sql); DataTable dt; if (count == 0) { dt = new DataTable(); } else { //if (isDetail) //sql = "select * from bxx.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.ext_code,p.product_name,p.main_img,p.group" + "u.nick_name as operate_sub_sa_nick " + "from bxx.product_select s left join bxx.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); } mySql.Close(); if (dt != null) { try { List productLst = new List(); 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(), product_name = row["product_name"].ParseToString(), main_img = row["main_img"].ParseToString(), group = row["group"].ToString(), 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("'", "\\'"); if (string.IsNullOrEmpty(user_name)) { return "{\"code\":500,\"msg\":\"没有用户名\"}"; } var id = RegexUtils.GetStringQuery(ref inputData, "db_id")?.Replace("'", "\\'"); if (string.IsNullOrEmpty(id)) { return "{\"code\":500,\"msg\":\"删除失败:请指定要删除的数据!\"}"; } string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString; MysqlUtils mySql = new MysqlUtils(conn); string sql = "delete from bxx.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\":\"输入为空\"}"; } /// /// 设置上传商品的二级超管 /// /// 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 = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString; MysqlUtils mySql = new MysqlUtils(conn); string sql = "update bxx.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 = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString; MysqlUtils mySql = new MysqlUtils(conn); string sql = "update bxx.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 paramLst = new List(); 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\":\"输入为空\"}"; } public string WxApiGetWxAllCate(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\":\"校验失败\"}"; string token = RegexUtils.GetStringQuery(ref inputData, "token", true); return HttpUtils.WxApiGetResponse("https://api.weixin.qq.com/shop/ec/category/all?access_token=" + token, ""); } return "{\"code\":19999,\"msg\":\"输入为空\"}"; } public string WxApiCategoryClassify(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\":\"校验失败\"}"; string post_data = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "post_data")); string token = RegexUtils.GetStringQuery(ref inputData, "token"); return HttpUtils.WxApiPostResponse("https://api.weixin.qq.com/channels/ec/product/category/classify?access_token=" + token, post_data, ""); } return "{\"code\":19999,\"msg\":\"输入为空\"}"; } public string WxApiUploadImage(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\":\"校验失败\"}"; string img_base64 = RegexUtils.GetStringQuery(ref inputData, "img_base64")?.Replace("'", "\\'"); if (!string.IsNullOrEmpty(img_base64)) { return WxApiUploadImageBase64(inputData, img_base64); } bool is_file = RegexUtils.GetStringQuery(ref inputData, "is_file")?.Replace("'", "\\'").ToLower() == "true"; if (is_file) { return WxApiUploadImageFile(inputData); } string post_data = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "post_data")); string token = RegexUtils.GetStringQuery(ref inputData, "token"); //https://api.weixin.qq.com/shop/ec/basics/img/upload?access_token=ACCESS_TOKEN&upload_type=1&resp_type=1 return HttpUtils.WxApiPostResponse("https://api.weixin.qq.com/shop/ec/basics/img/upload?access_token=" + token + "&upload_type=1&resp_type=1", post_data, ""); } return "{\"code\":19999,\"msg\":\"输入为空\"}"; } public string WxApiUploadImageFile(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\":\"校验失败\"}"; string token = RegexUtils.GetStringQuery(ref inputData, "token")?.Replace("'", "\\'"); string img_url = RegexUtils.GetStringQuery(ref inputData, "img_url")?.Replace("'", "\\'"); string random_code = RegexUtils.GetStringQuery(ref inputData, "random_code")?.Replace("'", "\\'"); int img_width = RegexUtils.GetStringQuery(ref inputData, "width").ParseToInt(); int img_height = RegexUtils.GetStringQuery(ref inputData, "height").ParseToInt(); bool is_keep_file = RegexUtils.GetStringQuery(ref inputData, "is_keep_file").ParseToBool(); string getImgError; var image = HttpUtils.GetUrlImg(img_url.Replace("https://", "http://"), out getImgError); if (!string.IsNullOrEmpty(getImgError) || image == null) { return "{\"code\":50001,\"msg\":\"获取图片失败:" + getImgError + "\"}"; } try { if (img_width.IsNullOrZero() || img_height.IsNullOrZero()) { img_width = image.Width; img_height = image.Height; } var imageBg = new Bitmap(img_width, img_height); using (Graphics g = Graphics.FromImage(imageBg)) { g.DrawImage(image, new Rectangle(0, 0, imageBg.Width, imageBg.Height), 0, 0, image.Width, image.Height, GraphicsUnit.Pixel); if (!string.IsNullOrEmpty(random_code) && random_code.ToLower() == "true") { g.FillRectangle(new SolidBrush(Color.FromArgb(RandomUtils.GetId(256), RandomUtils.GetId(256), RandomUtils.GetId(256))), new Rectangle(RandomUtils.GetId(imageBg.Width - 30), RandomUtils.GetId(imageBg.Height - 30), 30, 30)); } } //string tempImgPath = Path.GetTempPath() + "\\" + RandomUtils.GetWordNumber(8).ToLower(); string tempImgPath = "C:\\tempImg\\" + RandomUtils.GetWordNumber(8).ToLower(); if (!Directory.Exists(tempImgPath)) Directory.CreateDirectory(tempImgPath); string imgFullPath = tempImgPath + "\\" + EncrypUtil.GetMd5(img_url) + ".jpg"; imageBg.Save(imgFullPath, System.Drawing.Imaging.ImageFormat.Jpeg); var apiUpImgFileRst = HttpUtils.WxApiUploadImgFile(imgFullPath, imageBg.Width, imageBg.Height, token); if (string.IsNullOrEmpty(apiUpImgFileRst)) apiUpImgFileRst = "{\"code\":50002,\"msg\":\"图片传输超时\"}"; if (!is_keep_file) { try { // 删除文件夹及其所有内容 Directory.Delete(tempImgPath, true); // 第二个参数为true表示递归删除所有子文件夹和文件 } catch (Exception ex) { } } return apiUpImgFileRst; } catch (Exception ex) { return "{\"code\":50001,\"msg\":\"上传图片失败:" + ex.Message + "\"}"; } } return "{\"code\":19999,\"msg\":\"输入为空\"}"; } public string WxApiUploadImageBase64(string inputData, string imgBase64) { 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\":\"校验失败\"}"; string token = RegexUtils.GetStringQuery(ref inputData, "token")?.Replace("'", "\\'"); string img_url = RegexUtils.GetStringQuery(ref inputData, "img_url")?.Replace("'", "\\'"); bool is_keep_file = RegexUtils.GetStringQuery(ref inputData, "is_keep_file").ParseToBool(); is_keep_file = System.Configuration.ConfigurationManager.ConnectionStrings["IsKeepBase64UploadImgFile"]?.ConnectionString == "1"; try { byte[] imageBytes = Convert.FromBase64String(imgBase64); using (MemoryStream ms = new MemoryStream(imageBytes, 0, imageBytes.Length)) { // 创建Image对象 Image imageBg = Image.FromStream(ms, true); string tempImgPath = "C:\\tempImg\\" + RandomUtils.GetWordNumber(16).ToLower(); if (!Directory.Exists(tempImgPath)) Directory.CreateDirectory(tempImgPath); string imgFullPath = tempImgPath + "\\" + EncrypUtil.GetMd5(img_url) + ".jpg"; imageBg.Save(imgFullPath, System.Drawing.Imaging.ImageFormat.Jpeg); var apiUpImgFileRst = HttpUtils.WxApiUploadImgFile(imgFullPath, imageBg.Width, imageBg.Height, token); if (string.IsNullOrEmpty(apiUpImgFileRst)) apiUpImgFileRst = "{\"code\":50002,\"msg\":\"图片传输超时\"}"; if (!is_keep_file) { try { // 删除文件夹及其所有内容 Directory.Delete(tempImgPath, true); // 第二个参数为true表示递归删除所有子文件夹和文件 } catch (Exception ex) { } } return apiUpImgFileRst; } } catch (Exception ex) { return "{\"code\":50001,\"msg\":\"上传图片失败:" + ex.Message + "\"}"; } } return "{\"code\":19999,\"msg\":\"输入为空\"}"; } public string AddJSTSku(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")?.Replace("'", "\\'"); if (string.IsNullOrEmpty(user_name)) return "{\"code\":50000,\"msg\":\"用户不存在\"}"; string coid = RegexUtils.GetStringQuery(ref inputData, "coid")?.Replace("'", "\\'"); string supplierId = RegexUtils.GetStringQuery(ref inputData, "supplierId")?.Replace("'", "\\'"); string supplierName = RegexUtils.GetStringQuery(ref inputData, "supplierName"); string skuId = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "skuId"))?.Replace("'", "\\'"); string itemSpuId = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "itemSpuId"))?.Replace("'", "\\'"); string pic = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "pic"))?.Replace("'", "\\'"); string itemName = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "itemName")); string styleCode = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "styleCode")); string itemCode = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "itemCode"))?.Replace("'", "\\'"); string color = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "color"))?.Replace("'", "\\'"); string spec = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "spec"))?.Replace("'", "\\'"); string salePrice = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "salePrice"))?.Replace("'", "\\'"); string supplyPrice = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "supplyPrice"))?.Replace("'", "\\'"); string stock = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "stock"))?.Replace("'", "\\'"); string stockTime = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "stockTime"))?.Replace("'", "\\'"); string weight = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "weight"))?.Replace("'", "\\'"); string status = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "status"))?.Replace("'", "\\'"); if (string.IsNullOrEmpty(user_name)) { return "{\"code\":500,\"msg\":\"没有用户名\"}"; } string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString; MysqlUtils mySql = new MysqlUtils(conn); string sql = ""; sql = "insert into "; sql += "bxx.product_sku_restore "; sql += "(coid,supplierId,supplierName,skuId,itemSpuId,pic,itemName,styleCode,itemCode,color,spec,stockTime," + "salePrice,supplyPrice,stock,weight) " + "values ('" + coid + "','" + supplierId + "','" + supplierName + "','" + skuId + "','" + itemSpuId + "','" + pic + "','" + itemName + "','" + styleCode + "','" + itemCode + "','" + color + "','" + spec + "','" + stockTime + "'," + (salePrice.IsNullOrEmpty() ? "null" : salePrice) + "," + supplyPrice + "," + stock + "," + weight + ");"; List paramLst = new List(); //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, }); 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\":\"输入为空\"}"; } public string MdyJSTSku(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")?.Replace("'", "\\'"); if (string.IsNullOrEmpty(user_name)) return "{\"code\":50000,\"msg\":\"用户不存在\"}"; string coid = RegexUtils.GetStringQuery(ref inputData, "coid")?.Replace("'", "\\'"); string supplierId = RegexUtils.GetStringQuery(ref inputData, "supplierId")?.Replace("'", "\\'"); string supplierName = RegexUtils.GetStringQuery(ref inputData, "supplierName"); string skuId = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "skuId"))?.Replace("'", "\\'"); string itemSpuId = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "itemSpuId"))?.Replace("'", "\\'"); string pic = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "pic"))?.Replace("'", "\\'"); string itemName = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "itemName")); string styleCode = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "styleCode")); string itemCode = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "itemCode"))?.Replace("'", "\\'"); string color = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "color"))?.Replace("'", "\\'"); string spec = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "spec"))?.Replace("'", "\\'"); string salePrice = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "salePrice"))?.Replace("'", "\\'"); string supplyPrice = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "supplyPrice"))?.Replace("'", "\\'"); string stock = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "stock"))?.Replace("'", "\\'"); string stockTime = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "stockTime"))?.Replace("'", "\\'"); string weight = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "weight"))?.Replace("'", "\\'"); string status = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "status"))?.Replace("'", "\\'"); if (string.IsNullOrEmpty(user_name)) { return "{\"code\":500,\"msg\":\"没有用户名\"}"; } string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString; MysqlUtils mySql = new MysqlUtils(conn); string sql = ""; sql = "update "; sql += "bxx.product_sku_restore p set "; if (coid != null) sql += " p.coid='" + coid + "',"; if (supplierId != null) sql += " p.supplierId='" + supplierId + "',"; if (supplierName != null) sql += " p.supplierName='" + supplierName + "',"; if (pic != null) sql += " p.pic='" + pic + "',"; if (itemName != null) sql += " p.itemName='" + itemName + "',"; if (styleCode != null) sql += " p.styleCode='" + styleCode + "',"; if (itemCode != null) sql += " p.itemCode='" + itemCode + "',"; if (color != null) sql += " p.color='" + color + "',"; if (spec != null) sql += " p.spec='" + spec + "',"; if (salePrice != null) sql += " p.salePrice=" + salePrice + ","; if (supplyPrice != null) sql += " p.supplyPrice=" + supplyPrice + ","; if (stock != null) sql += " p.stock=" + stock + ","; if (stockTime != null) sql += " p.stockTime='" + stockTime + "',"; if (salePrice != null) sql += " p.salePrice=" + salePrice + ","; if (weight != null) sql += " p.weight='" + weight + "',"; sql = sql.TrimEnd(','); sql += " where skuId='" + skuId + "' and itemSpuId='" + itemSpuId + "';"; List paramLst = new List(); //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, }); 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\":\"输入为空\"}"; } public string GetJSTSkuList(string inputData) { var timeCalc = DateTime.Now; 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 version = RegexUtils.GetStringQuery(ref inputData, "version").ParseToInt(); if (version < (System.Configuration.ConfigurationManager.ConnectionStrings["LimitVersion"]?.ConnectionString).ParseToInt()) return "{\"code\":1,\"msg\":\"当前版本过于陈旧,请立即升级新版\"}"; var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name")?.Replace("'", "\\'"); if (string.IsNullOrEmpty(user_name)) return "{\"code\":50000,\"msg\":\"用户不存在\"}"; var search_coid = RegexUtils.GetStringQuery(ref inputData, "search_coid")?.Replace("'", "\\'"); var search_supplierId = RegexUtils.GetStringQuery(ref inputData, "search_supplierId")?.Replace("'", "\\'"); var search_supplierName = RegexUtils.GetStringQuery(ref inputData, "search_supplierName")?.Replace("'", "\\'"); var search_skuId = RegexUtils.GetStringQuery(ref inputData, "search_skuId")?.Replace("'", "\\'"); var search_itemSpuId = RegexUtils.GetStringQuery(ref inputData, "search_itemSpuId")?.Replace("'", "\\'"); var search_itemName = RegexUtils.GetStringQuery(ref inputData, "search_itemName")?.Replace("'", "\\'"); var search_styleCode = RegexUtils.GetStringQuery(ref inputData, "search_styleCode")?.Replace("'", "\\'"); var search_itemCode = RegexUtils.GetStringQuery(ref inputData, "search_itemCode")?.Replace("'", "\\'"); var search_color = RegexUtils.GetStringQuery(ref inputData, "search_color")?.Replace("'", "\\'"); var search_spec = RegexUtils.GetStringQuery(ref inputData, "search_spec")?.Replace("'", "\\'"); var search_status = RegexUtils.GetStringQuery(ref inputData, "search_status")?.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(*) from bxx.product_sku_restore p where 1=1"; string where = ""; if (!string.IsNullOrEmpty(search_coid)) where += " and p.coid ='" + search_coid + "'"; if (!string.IsNullOrEmpty(search_supplierId)) where += " and p.supplierId ='" + search_supplierId + "'"; if (!string.IsNullOrEmpty(search_supplierName)) where += " and p.supplierName ='" + search_supplierName + "'"; if (!string.IsNullOrEmpty(search_skuId)) where += " and p.skuId ='" + search_skuId + "'"; if (!string.IsNullOrEmpty(search_itemSpuId)) where += " and p.itemSpuId ='" + search_itemSpuId + "'"; if (!string.IsNullOrEmpty(search_itemName)) where += " and p.itemName like '%" + search_itemName + "%'"; if (!string.IsNullOrEmpty(search_styleCode)) where += " and p.styleCode ='" + search_styleCode + "'"; if (!string.IsNullOrEmpty(search_itemCode)) where += " and p.itemCode ='" + search_itemCode + "'"; if (!string.IsNullOrEmpty(search_color)) where += " and p.color ='" + search_color + "'"; if (!string.IsNullOrEmpty(search_spec)) where += " and p.spec ='" + search_spec + "'"; if (!string.IsNullOrEmpty(search_status)) where += " and p.status ='" + search_status + "'"; sql += where; var count = 0; count = mySql.ExecuteRowCount(sql); DataTable dt; if (count == 0) { dt = new DataTable(); } else { sql = "select p.* from bxx.product_sku_restore p" + " where 1=1"; //where子句 sql += where; 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 productLst = new List(); foreach (DataRow row in dt.Rows) { JSTListProductSkuInfo prod = new JSTListProductSkuInfo { id = Convert.ToInt32(row["id"]), coid = row["coid"].ToString(), color = row["color"].ToString(), itemCode = row["itemCode"].ToString(), itemName = row["itemName"].ToString(), itemSpuId = row["itemSpuId"].ToString(), pic = row["pic"].ToString(), salePrice = row["salePrice"].ParseToDecimal(), skuId = row["skuId"].ToString(), spec = row["spec"].ToString(), status = row["status"].ToString(), stock = row["stock"].ParseToInt(), styleCode = row["styleCode"].ParseToString(), supplierId = row["supplierId"].ToString(), supplierName = row["supplierName"].ToString(), supplyPrice = row["supplyPrice"].ParseToDecimal(), add_time = Convert.ToDateTime(row["add_time"]), mdy_time = Convert.ToDateTime(row["mdy_time"]), stockTime = row["stockTime"].ParseToString().ParseToDateTime(), weight = row["weight"].ParseToDecimal(), }; productLst.Add(prod); } JsonSerializerSettings jsonSetting = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }; var data = JsonUtils.SerializeObjectToString(productLst, jsonSetting); var seconds = (DateTime.Now - timeCalc).TotalSeconds.ToString("0.000"); return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"count\":" + count + ",\"seconds\":" + seconds + "}"; } 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 SetRandomCompanyProductConfig(string inputData) { var timeCalc = DateTime.Now; 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\":50000,\"msg\":\"用户不存在\"}"; string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString; MysqlUtils mySql = new MysqlUtils(conn); string product_group = RegexUtils.GetStringQuery(ref inputData, "product_group")?.Replace("'", "\\'"); string product_interval = RegexUtils.GetStringQuery(ref inputData, "product_interval")?.Replace("'", "\\'"); string is_on = RegexUtils.GetStringQuery(ref inputData, "is_on")?.Replace("'", "\\'"); string sql = "update bxx.product_com_random set "; if (product_group != null) sql += "product_group='" + product_group + "',"; if (product_interval != null) sql += "product_interval=" + product_interval + ","; if (is_on != null) sql += "is_on=" + is_on + ","; sql = sql.TrimEnd(','); sql += " where 1=1;"; var rst = mySql.ExecuteNonQuery(sql); mySql.Close(); if (string.IsNullOrEmpty(mySql.Message)) { return "{\"code\":200,\"msg\":\"success\"}"; } else { return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}"; } } return "{\"code\":19999,\"msg\":\"输入为空\"}"; } /// /// 随机工厂商品 /// /// /// public string GetRandomCompanyProductConfig(string inputData) { var timeCalc = DateTime.Now; 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\":50000,\"msg\":\"用户不存在\"}"; string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString; MysqlUtils mySql = new MysqlUtils(conn); string sql = "select p.* from bxx.product_com_random p" + " where 1=1;"; var dt = mySql.ExecuteDataTable(sql); mySql.Close(); if (dt != null) { try { string product_group = dt.Rows[0]["product_group"].ParseToString(); string product_interval = dt.Rows[0]["product_interval"].ParseToString(); string is_on = dt.Rows[0]["is_on"].ParseToString(); var seconds = (DateTime.Now - timeCalc).TotalSeconds.ToString("0.000"); return "{\"code\":200,\"msg\":\"success\"" + ",\"product_group\":\"" + product_group + "\"" + ",\"product_interval\":" + product_interval + ",\"is_on\":" + is_on + ",\"seconds\":" + seconds + "}"; } catch (Exception ex) { return "{\"code\":500,\"msg\":\"" + ex.Message + "\"}"; } } else { return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}"; } } return "{\"code\":19999,\"msg\":\"输入为空\"}"; } public string AddRelation(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 up_spu_id = RegexUtils.GetStringQuery(ref inputData, "up_spu_id")?.Replace("'", "\\'"); if (string.IsNullOrEmpty(up_spu_id)) { return "{\"code\":500,\"msg\":\"缺少上家编号\"}"; } var index = RegexUtils.GetStringQuery(ref inputData, "index").ParseToNullableLong(); if (index == null) index = Math.Abs(up_spu_id.GetHashCode()) % 128; var up_goods_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "up_goods_name")); if (string.IsNullOrEmpty(up_goods_name)) { return "{\"code\":500,\"msg\":\"缺少上家商品名称\"}"; } var from_site = RegexUtils.GetStringQuery(ref inputData, "from_site")?.Replace("'", "\\'"); if (string.IsNullOrEmpty(from_site)) { return "{\"code\":500,\"msg\":\"缺少关联商品平台\"}"; } var goods_id = RegexUtils.GetStringQuery(ref inputData, "goods_id")?.Replace("'", "\\'"); if (string.IsNullOrEmpty(goods_id)) { return "{\"code\":500,\"msg\":\"缺少关联商品编号\"}"; } var shop_id = RegexUtils.GetStringQuery(ref inputData, "shop_id")?.Replace("'", "\\'"); if (string.IsNullOrEmpty(shop_id)) { return "{\"code\":500,\"msg\":\"缺少关联店铺编号\"}"; } var price_max = RegexUtils.GetStringQuery(ref inputData, "price_max")?.Replace("'", "\\'"); if (string.IsNullOrEmpty(price_max)) { return "{\"code\":500,\"msg\":\"缺少关联最高价格\"}"; } var price_min = RegexUtils.GetStringQuery(ref inputData, "price_min")?.Replace("'", "\\'"); if (string.IsNullOrEmpty(price_min)) { return "{\"code\":500,\"msg\":\"缺少关联最低价格\"}"; } string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString; MysqlUtils mySql = new MysqlUtils(conn); string sql = "insert into bxx_relation.out_prod_relation_" + index.ParseToString().PadLeft(4, '0') + " (up_spu_id,up_goods_name,from_site,goods_id,shop_id,price_min,price_max) " + " values ('" + up_spu_id + "',@up_goods_name,'" + from_site + "','" + goods_id + "'," + shop_id + "," + price_min + "," + price_max + ");"; List paramLst = new List(); paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@up_goods_name", Value = up_goods_name, }); mySql.ExecuteNonQuery(sql, paramLst.ToArray()); mySql.Close(); if (mySql.Message.IsNullOrEmpty()) { return "{\"code\":200,\"msg\":\"成功\"}"; } else { return "{\"code\":500,\"msg\":\"失败:" + mySql.Message + "\"}"; } } return "{\"code\":19999,\"msg\":\"输入为空\"}"; } public string GetRelation(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 up_spu_id = RegexUtils.GetStringQuery(ref inputData, "up_spu_id")?.Replace("'", "\\'"); if (string.IsNullOrEmpty(up_spu_id)) { return "{\"code\":500,\"msg\":\"缺少来源商品编号\"}"; } var index = RegexUtils.GetStringQuery(ref inputData, "index").ParseToNullableLong(); if (index == null) index = Math.Abs(up_spu_id.GetHashCode()) % 128; string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString; MysqlUtils mySql = new MysqlUtils(conn); string sql = "select * from bxx_relation.out_prod_relation_" + index.ParseToString().PadLeft(4, '0') + " where up_spu_id='" + up_spu_id + "' limit 20;"; var dt = mySql.ExecuteDataTable(sql); mySql.Close(); if (mySql.Message.IsNullOrEmpty()) { JArray jArr = new JArray(); foreach (DataRow row in dt.Rows) { JObject jObj = new JObject(); jObj["id"] = row["id"].ParseToInt(); jObj["up_spu_id"] = row["up_spu_id"].ToString(); jObj["up_goods_name"] = row["up_goods_name"].ToString(); jObj["from_site"] = row["from_site"].ToString(); jObj["goods_id"] = row["goods_id"].ToString(); jObj["shop_id"] = row["shop_id"].ToString(); jObj["price_min"] = row["price_min"].ParseToInt(); jObj["price_max"] = row["price_max"].ParseToInt(); jObj["add_time"] = row["add_time"].ParseToString().ParseToDateTime(); jArr.Add(jObj); } JsonSerializerSettings jsonSetting = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }; var data = JsonUtils.SerializeObjectToString(jArr, jsonSetting); return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"count\":" + jArr.Count + "}"; } else { return "{\"code\":500,\"msg\":\"失败:" + mySql.Message + "\"}"; } } return "{\"code\":19999,\"msg\":\"输入为空\"}"; } public string AddMdyJstProductBan(string inputData) { if (!string.IsNullOrEmpty(inputData)) { if (!WXUserManage.GetSign(inputData)) return "{\"code\":999,\"msg\":\"校验失败\"}"; // 软件用户名 string coid = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "coid"))?.Replace("'", "\\'"); int? ban_wx = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "ban_wx"))?.ParseToNullableInt(); int? ban_pdd = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "ban_pdd"))?.ParseToNullableInt(); // 收件人 string user_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "receiver"))?.Replace("'", "\\'"); if (string.IsNullOrEmpty(coid)) return "{\"code\":500,\"msg\":\"缺少供应商编号\"}"; if (ban_wx == null) return "{\"code\":500,\"msg\":\"缺少设置值\"}"; if (ban_pdd == null) return "{\"code\":500,\"msg\":\"缺少设置值\"}"; string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString; MysqlUtils mySql = new MysqlUtils(conn, true); string sql = "SELECT 1 FROM `bxx`.`jst_supplier_ban_platform` where coid='" + coid + "'"; string where = ""; sql += where; var exist = mySql.ExecuteFirstInt(sql); if (!mySql.Message.IsNullOrEmpty()) { mySql.RollBack(); mySql.Close(); return "{\"code\":501,\"msg\":\"" + mySql.Message + "\"}"; } if (exist == 0) { sql = " INSERT INTO `bxx`.`jst_supplier_ban_platform` (coid,ban_wx,ban_pdd)" + " VALUES (@coid,@ban_wx,@ban_pdd);"; } else { sql = "UPDATE `bxx`.`jst_supplier_ban_platform` SET "; if (ban_wx != null) sql += " ban_wx=@ban_wx,"; if (ban_pdd != null) sql += " ban_pdd=@ban_pdd,"; sql = sql.TrimEnd(','); sql += " WHERE coid=@coid;"; } List paramLst = new List(); paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "coid", Value = coid, }); paramLst.Add(new MySqlParameter() { DbType = DbType.Int16, ParameterName = "ban_wx", Value = ban_wx, }); paramLst.Add(new MySqlParameter() { DbType = DbType.Int16, ParameterName = "ban_pdd", Value = ban_pdd, }); var rowCnt = mySql.ExecuteAffectedRows(sql, paramLst.ToArray()); if (!string.IsNullOrEmpty(mySql.Message)) { mySql.RollBack(); mySql.Close(); return "{\"code\":50003,\"msg\":\"" + mySql.Message + "\",\"data\":\"\"}"; } sql = "UPDATE `bxx`.`product` SET "; if (ban_wx != null) sql += " ban_wx=@ban_wx,"; if (ban_pdd != null) sql += " ban_pdd=@ban_pdd,"; sql = sql.TrimEnd(','); sql += " WHERE (real_coid=@coid or skc_id=@coid) AND product_get_type='厂商直采';"; rowCnt = mySql.ExecuteAffectedRows(sql, paramLst.ToArray()); if (!string.IsNullOrEmpty(mySql.Message)) { mySql.RollBack(); mySql.Close(); return "{\"code\":50003,\"msg\":\"" + mySql.Message + "\",\"data\":\"\"}"; } mySql.Commit(); mySql.Close(); return "{\"code\":200,\"msg\":\"success\",\"data\":\"\"}"; } return "{\"code\":19999,\"msg\":\"输入为空\"}"; } public string GetJstProductCoidList(string inputData) { if (!string.IsNullOrEmpty(inputData)) { var timeCalc = DateTime.Now; if (!WXUserManage.GetSign(inputData)) return "{\"code\":999,\"msg\":\"校验失败\"}"; int page = RegexUtils.GetStringQuery(ref inputData, "page").ParseToInt(); int page_size = RegexUtils.GetStringQuery(ref inputData, "page_size").ParseToInt(200); string coids = RegexUtils.GetStringQuery(ref inputData, "coids")?.Replace("'", "\\'"); string not_count = RegexUtils.GetStringQuery(ref inputData, "not_count")?.Replace("'", "\\'"); string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString; MysqlUtils mySql = new MysqlUtils(conn); string sql = ""; var count = -1; //sql = " SELECT COUNT(*) FROM" + // " (SELECT skc_id as coid FROM bxx.product WHERE product_get_type='厂商直采' UNION SELECT real_coid as coid FROM bxx.product WHERE product_get_type='厂商直采') as coids" + // " WHERE 1=1 AND coids.coid != ''"; sql = "select count(*) FROM (SELECT DISTINCT coids.*,a.after_sale_json,p.from_shop_name,b.ban_wx,b.ban_pdd" + " FROM (SELECT skc_id as coid FROM bxx.product WHERE product_get_type='厂商直采' UNION SELECT real_coid as coid FROM bxx.product WHERE product_get_type='厂商直采') as coids" + " LEFT JOIN wxxd.after_sale as a ON coids.coid=a.coid AND a.is_del = 0" + " LEFT JOIN bxx.product p ON coids.coid=p.skc_id" + " LEFT JOIN bxx.jst_supplier_ban_platform b ON coids.coid=b.coid" + " WHERE 1=1 AND coids.coid != ''"; string where = ""; if (coids != null) where += " AND coids.coid IN ('" + coids.Replace(",", "','") + "')"; sql += where; sql += ") as cnt"; sql += ";"; if (not_count != "true") count = mySql.ExecuteRowCount(sql); DataTable dt; if (count == 0) { dt = new DataTable(); } else { sql = " SELECT DISTINCT coids.*,a.after_sale_json,p.from_shop_name,b.ban_wx,b.ban_pdd" + " FROM (SELECT skc_id as coid FROM bxx.product WHERE product_get_type='厂商直采' UNION SELECT real_coid as coid FROM bxx.product WHERE product_get_type='厂商直采') as coids" + " LEFT JOIN wxxd.after_sale as a ON coids.coid=a.coid AND a.is_del = 0" + " LEFT JOIN bxx.product p ON coids.coid=p.skc_id" + " LEFT JOIN bxx.jst_supplier_ban_platform b ON coids.coid=b.coid" + " WHERE 1=1 AND coids.coid != ''"; sql += where; //sql += " ORDER BY coid DESC"; //sql += " ORDER BY coid ASC"; sql += " LIMIT " + Math.Max(0, page - 1) * page_size + "," + page_size + ";"; dt = mySql.ExecuteDataTable(sql); if (!string.IsNullOrEmpty(mySql.Message)) { mySql.Close(); return "{\"code\":500,\"msg\":\"" + mySql.Message + "\",\"data\":[],\"count\":" + 0 + "}"; } } mySql.Close(); if (dt != null) { try { List coidLst = new List(); foreach (DataRow row in dt.Rows) { var jObj = new JObject(); var afterSaleJson = row["after_sale_json"].ParseToString(); var supplier_name = row["from_shop_name"].ParseToString(); if (string.IsNullOrEmpty(supplier_name)) supplier_name = RegexUtils.GetStringJson(ref afterSaleJson, "name"); coidLst.Add(jObj); jObj["coid"] = row["coid"].ParseToString(); jObj["supplier_name"] = supplier_name; jObj["ban_wx"] = row["ban_wx"].ParseToInt(); jObj["ban_pdd"] = row["ban_pdd"].ParseToInt(); } JsonSerializerSettings jsonSetting = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }; var data = JsonUtils.SerializeObjectToString(coidLst, jsonSetting); var seconds = (DateTime.Now - timeCalc).TotalSeconds.ToString("0.000"); return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"count\":" + count + ",\"seconds\":" + seconds + "}"; } 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 GetJstProductBanPlatformList(string inputData) { if (!string.IsNullOrEmpty(inputData)) { var timeCalc = DateTime.Now; if (!WXUserManage.GetSign(inputData)) return "{\"code\":999,\"msg\":\"校验失败\"}"; int page = RegexUtils.GetStringQuery(ref inputData, "page").ParseToInt(); int page_size = RegexUtils.GetStringQuery(ref inputData, "page_size").ParseToInt(200); string coids = RegexUtils.GetStringQuery(ref inputData, "coid")?.Replace("'", "\\'"); string not_count = RegexUtils.GetStringQuery(ref inputData, "not_count")?.Replace("'", "\\'"); string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString; MysqlUtils mySql = new MysqlUtils(conn); string sql = ""; var count = -1; sql = "SELECT count(*) FROM `bxx`.`jst_supplier_ban_platform` where 1=1"; string where = ""; if (coids != null) where += " AND coid IN ('" + coids.Replace(",", "','") + "')"; sql += where; sql += ";"; if (not_count != "true") count = mySql.ExecuteRowCount(sql); DataTable dt; if (count == 0) { dt = new DataTable(); } else { sql = "SELECT * FROM `bxx`.`jst_supplier_ban_platform` WHERE 1=1"; sql += where; sql += " ORDER BY id DESC LIMIT " + Math.Max(0, page - 1) * page_size + "," + page_size + ";"; dt = mySql.ExecuteDataTable(sql); } mySql.Close(); if (dt != null) { try { List supplierBanPlatformLst = new List(); foreach (DataRow row in dt.Rows) { var jObj = new JObject(); supplierBanPlatformLst.Add(jObj); jObj["id"] = row["id"].ParseToInt(); jObj["coid"] = row["coid"].ParseToString(); jObj["ban_wx"] = row["ban_wx"].ParseToInt(); jObj["ban_pdd"] = row["ban_pdd"].ParseToInt(); } JsonSerializerSettings jsonSetting = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }; var data = JsonUtils.SerializeObjectToString(supplierBanPlatformLst, jsonSetting); var seconds = (DateTime.Now - timeCalc).TotalSeconds.ToString("0.000"); return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"count\":" + count + ",\"seconds\":" + seconds + "}"; } 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 XJGetAiImage(string inputData) { if (string.IsNullOrEmpty(inputData)) return "{\"code\":19999,\"msg\":\"输入为空\"}"; if (!WXUserManage.GetSign(inputData)) return "{\"code\":999,\"msg\":\"校验失败\"}"; string image_url = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "image_url"))?.ParseToString(); string word = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "word"))?.ParseToString(); if (image_url == null) return "{\"code\":500,\"msg\":\"缺少图片地址\"}"; if (word == null) return "{\"code\":500,\"msg\":\"缺少图片文字\"}"; string secret = "sadhjufhe15c4fbvFBvcvds+5sdfds@#%$xsc"; string time = TimeUtils.DateTimeToTimestampSeconds(DateTime.Now).ToString(); string code = EncrypUtil.GetMd5(secret + time); try { string url = "http://ai-bs.jiaotian.vip:" + RandomUtils.GetId(20010, 20021) + "/index.php?obj=public/image"; string data = "time=" + time + "&code=" + code + "&image_url=" + image_url + "&word=" + word; string html = HttpUtils.e57GetResponse(url, ""); return html; } catch (Exception ex) { return "{\"code\":50001,\"msg\":\"" + ex.Message + "\"}"; } } } } /* List paramLst = new List(); 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());*/