产品库手动更新sku下架情况

This commit is contained in:
wule committed 2026-02-26 11:56:00 +08:00
1 parent 1b2b6bb553
commit 30efe8fccb
25 files changed
+2214 -490

No files matched your search

@@ -4,6 +4,7 @@ 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;
@@ -242,6 +243,76 @@ namespace KJD_Web.BLL.BXX
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
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("'", "\\'");
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)) + "')";
}
var dt = mySql.ExecuteDataTable(sql);
mySql.Close();
if (dt != null)
{
try
{
List<DBProductResultParamLite> productLst = new List<DBProductResultParamLite>();
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.SerializerObjectToString(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;
@@ -500,7 +571,8 @@ namespace KJD_Web.BLL.BXX
}
productLst.Add(prod);
}
var data = JsonUtils.SerializerObjectToString(productLst);
JsonSerializerSettings jsonSetting = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore };
var data = JsonUtils.SerializerObjectToString(productLst, jsonSetting);
var seconds = (DateTime.Now - timeCalc).TotalSeconds.ToString("0.000");
return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"count\":" + count + ",\"seconds\":" + seconds + "}";
}
@@ -517,6 +589,158 @@ namespace KJD_Web.BLL.BXX
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
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\":\"输入为空\"}";
}
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("'", "\\'");
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,spuId,itemName,styleCode,itemCode,colourSpec,supplierCoId,supplierName,is_in_product_db,add_time from bxx.product_jst_update p where 1=1";
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)) + "')";
}
var dt = mySql.ExecuteDataTable(sql);
mySql.Close();
if (dt != null)
{
try
{
List<JSTDownProdSkuInfo> productLst = new List<JSTDownProdSkuInfo>();
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(),
};
productLst.Add(prod);
}
JsonSerializerSettings jsonSetting = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore };
var data = JsonUtils.SerializerObjectToString(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))
@@ -738,6 +962,7 @@ namespace KJD_Web.BLL.BXX
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("'", "\\'");
@@ -755,7 +980,7 @@ namespace KJD_Web.BLL.BXX
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "select count(*) from bxx.product p where p.is_del=0";
string sql = "select count(*) from bxx.product p FORCE INDEX (index_wx_safe_status) where p.is_del=0";
string where = "";
if (!string.IsNullOrEmpty(in_ext_codes))
@@ -783,6 +1008,10 @@ namespace KJD_Web.BLL.BXX
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=" + wx_cat_1 + "";
@@ -833,14 +1062,14 @@ namespace KJD_Web.BLL.BXX
//sql += " ORDER BY RAND()";
//sql += " limit " + Math.Max(page - 1, 0) * page_size + "," + page_size;
var limit = RandomUtils.GetId(count - page_size);
var limit = RandomUtils.GetId(Math.Max(1, count - page_size));
sql += " limit " + limit + "," + page_size;
dt = mySql.ExecuteDataTable(sql);
Thread.Sleep(100);
if (!string.IsNullOrEmpty(mySql.Message) || dt == null)
{
mySql.Close();
Thread.Sleep(1000);
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\",\"data\":[],\"count\":" + 0 + "}";
}
@@ -8,6 +8,7 @@ using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Threading;
using System.Web;
using System.Web.Security;
@@ -450,7 +451,7 @@ namespace KJD_Web.BLL.WXXD
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "select id from wxxd_product_shop_map.product_shop_map_" + index.ParseToString().PadLeft(4, '0') +
" where up_secret_spu_id='" + up_secret_spu_id + "'and shop_id='" + shop_id + "'";
" where up_secret_spu_id='" + up_secret_spu_id + "' and shop_id='" + shop_id + "';";
DataTable dt = mySql.ExecuteDataTable(sql);
if (!string.IsNullOrEmpty(mySql.Message) || dt == null || dt.Rows == null)
@@ -481,6 +482,104 @@ namespace KJD_Web.BLL.WXXD
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string WXGetSecretSpuIdShopIdMapList(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 up_secret_spu_id = RegexUtils.GetStringQuery(ref inputData, "up_secret_spu_id")?.Replace("'", "\\'");
if (string.IsNullOrEmpty(up_secret_spu_id))
{
return "{\"code\":500,\"msg\":\"缺少商品编号1\"}";
}
var index = RegexUtils.GetStringQuery(ref inputData, "index").ParseToNullableLong();
if (index == null)
index = up_secret_spu_id.ParseToLong() % 1024;
int page = RegexUtils.GetStringQuery(ref inputData, "page").ParseToInt();
int page_size = RegexUtils.GetStringQuery(ref inputData, "page_size").ParseToInt(50);
var shop_id = RegexUtils.GetStringQuery(ref inputData, "shop_id")?.Replace("'", "\\'");
var is_not_count = (RegexUtils.GetStringQuery(ref inputData, "is_not_count")?.Replace("'", "\\'")).ParseToBool();
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
MysqlUtils mySql = new MysqlUtils(conn);
int count = 0;
string sql = "";
if (!is_not_count)
{
sql = "select count(*) from wxxd_product_shop_map.product_shop_map_" + index.ParseToString().PadLeft(4, '0') +
" where up_secret_spu_id='" + up_secret_spu_id;
if (!shop_id.IsNullOrEmpty())
sql += "' and shop_id='" + shop_id + "'";
sql += ";";
count = mySql.ExecuteRowCount(sql);
Thread.Sleep(100);
}
DataTable dt;
if (count == 0 && !is_not_count)
{
dt = new DataTable();
}
else
{
sql = "select * from wxxd_product_shop_map.product_shop_map_" + index.ParseToString().PadLeft(4, '0') +
" where up_secret_spu_id='" + up_secret_spu_id;
if (!shop_id.IsNullOrEmpty())
sql += "' and shop_id='" + shop_id + "'";
sql += " order by add_time desc";
sql += " limit " + Math.Max(page - 1, 0) * page_size + "," + page_size;
dt = mySql.ExecuteDataTable(sql);
mySql.Close();
if (!string.IsNullOrEmpty(mySql.Message) || dt == null)
{
Thread.Sleep(1000);
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\",\"data\":[],\"count\":" + 0 + "}";
}
}
if (dt != null)
{
try
{
List<WxProdSecretSpuIdShopIdMapParam> prodSecretIdMapLst = new List<WxProdSecretSpuIdShopIdMapParam>();
foreach (DataRow row in dt.Rows)
{
WxProdSecretSpuIdShopIdMapParam idMap = new WxProdSecretSpuIdShopIdMapParam
{
id = Convert.ToInt32(row["id"]),
up_secret_spu_id = row["up_secret_spu_id"].ToString(),
up_spu_id = row["up_spu_id"].ToString(),
shop_id = row["shop_id"].ToString(),
add_time = Convert.ToDateTime(row["add_time"]),
//mdy_time = Convert.ToDateTime(row["mdy_time"]),
};
prodSecretIdMapLst.Add(idMap);
}
var data = JsonUtils.SerializerObjectToString(prodSecretIdMapLst);
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 WXAddMdyAfterSale(string inputData)
{
if (!string.IsNullOrEmpty(inputData))