1拼多多sku货号价格 2拼多多sku增删改功能(70%)
This commit is contained in:
1 parent
4dde0936ed
commit
ad238cd241
31 files changed
+3155
-348
No files matched your search
@@ -596,5 +596,256 @@ namespace KJD_Web.BLL.BXX
|
||||
}
|
||||
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public string AddExtCodePrice(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 user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
|
||||
string ext_code = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "ext_code")).ParseToString();
|
||||
int ext_code_price = RegexUtils.GetStringQuery(ref inputData, "ext_code_price").ParseToInt();
|
||||
|
||||
if (string.IsNullOrEmpty(user_name))
|
||||
{
|
||||
return "{\"code\":500,\"msg\":\"没有用户名\"}";
|
||||
}
|
||||
if (string.IsNullOrEmpty(ext_code))
|
||||
{
|
||||
return "{\"code\":500,\"msg\":\"没有货号\"}";
|
||||
}
|
||||
|
||||
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
||||
MysqlUtils mySql = new MysqlUtils(conn);
|
||||
List<MySqlParameter> paramLst = new List<MySqlParameter>();
|
||||
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@ext_code", Value = ext_code, });
|
||||
paramLst.Add(new MySqlParameter() { DbType = DbType.Int32, ParameterName = "@ext_code_price", Value = ext_code_price, });
|
||||
|
||||
string sql= "select count(ext_code) from bxx.ext_code_price where ext_code=@ext_code";
|
||||
var count = mySql.ExecuteRowCount(sql, paramLst.ToArray());
|
||||
if (count.ParseToInt() > 0)
|
||||
{
|
||||
sql = "update bxx.ext_code_price set ext_code_price=@ext_code_price where ext_code=@ext_code";
|
||||
}
|
||||
else
|
||||
{
|
||||
sql = "insert into bxx.ext_code_price (ext_code,ext_code_price) values (@ext_code,@ext_code_price);";
|
||||
}
|
||||
|
||||
var rst = mySql.ExecuteNonQuery(sql, paramLst.ToArray());
|
||||
mySql.Close();
|
||||
if (rst)
|
||||
{
|
||||
return "{\"code\":200,\"msg\":\"success\"}";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "{\"code\":502,\"msg\":\"" + mySql.Message + "\"}";
|
||||
}
|
||||
}
|
||||
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
||||
}
|
||||
|
||||
public string GetExtCodePriceList(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");
|
||||
var password = RegexUtils.GetStringQuery(ref inputData, "password");
|
||||
|
||||
string start_ext_price = RegexUtils.GetStringQuery(ref inputData, "start_ext_price");
|
||||
string end_ext_price = RegexUtils.GetStringQuery(ref inputData, "end_ext_price");
|
||||
var search_ext_code = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "search_ext_code"));
|
||||
var in_ext_code = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "in_ext_code"));
|
||||
int page = RegexUtils.GetStringQuery(ref inputData, "page").ParseToInt();
|
||||
int page_size = RegexUtils.GetStringQuery(ref inputData, "page_size").ParseToInt(50);
|
||||
if (string.IsNullOrEmpty(user_name))
|
||||
{
|
||||
return "{\"code\":500,\"msg\":\"没有用户名\"}";
|
||||
}
|
||||
|
||||
|
||||
List<MySqlParameter> paramLst = new List<MySqlParameter>();
|
||||
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@search_ext_code", Value = "%" + search_ext_code + "%", });
|
||||
paramLst.Add(new MySqlParameter() { DbType = DbType.Int32, ParameterName = "@start_ext_price", Value = start_ext_price.ParseToInt(), });
|
||||
paramLst.Add(new MySqlParameter() { DbType = DbType.Int32, ParameterName = "@end_ext_price", Value = end_ext_price.ParseToInt(), });
|
||||
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@in_ext_code", Value = in_ext_code.ParseToString() });
|
||||
|
||||
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
||||
MysqlUtils mySql = new MysqlUtils(conn);
|
||||
|
||||
string sql = "select count(id) from bxx.ext_code_price p where 1=1";
|
||||
|
||||
string where = "";
|
||||
if (!string.IsNullOrWhiteSpace(search_ext_code))
|
||||
where += " and p.ext_code like @search_ext_code";
|
||||
if (!string.IsNullOrWhiteSpace(start_ext_price))
|
||||
where += " and p.ext_code_price >= @start_ext_price";
|
||||
if (!string.IsNullOrWhiteSpace(end_ext_price))
|
||||
where += " and p.ext_code_price <= @end_ext_price";
|
||||
if (!string.IsNullOrEmpty(in_ext_code))
|
||||
where += " and p.ext_code in ('" + in_ext_code?.Replace(",", "','") + "')";
|
||||
sql += where;
|
||||
|
||||
var count = mySql.ExecuteRowCount(sql, paramLst.ToArray());
|
||||
|
||||
DataTable dt;
|
||||
if (count == 0)
|
||||
{
|
||||
dt = new DataTable();
|
||||
}
|
||||
else
|
||||
{
|
||||
sql = "select * from bxx.ext_code_price 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, paramLst.ToArray());
|
||||
}
|
||||
|
||||
mySql.Close();
|
||||
if (dt != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
List<DBExtCodePriceResult> priceList = new List<DBExtCodePriceResult>();
|
||||
foreach (DataRow row in dt.Rows)
|
||||
{
|
||||
DBExtCodePriceResult price = new DBExtCodePriceResult
|
||||
{
|
||||
id = row["id"].ParseToInt(),
|
||||
ext_code_price = row["ext_code_price"].ParseToInt(),
|
||||
ext_code = row["ext_code"].ParseToString(),
|
||||
add_time = Convert.ToDateTime(row["add_time"]),
|
||||
mdy_time = Convert.ToDateTime(row["mdy_time"]),
|
||||
};
|
||||
priceList.Add(price);
|
||||
}
|
||||
var data = JsonUtils.SerializerObjectToString(priceList);
|
||||
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 DelDbExtCodePrice(string inputData)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(inputData))
|
||||
{
|
||||
var time = RegexUtils.GetStringQuery(ref inputData, "time").ParseToInt();
|
||||
string time1 = RegexUtils.GetStringQuery(ref inputData, "code");
|
||||
if (time1 != EncrypUtil.Encryption(time))
|
||||
return "{\"code\":50000,\"msg\":\"校验失败\"}";
|
||||
|
||||
var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name")?.Replace("'", "\\'");
|
||||
var id = RegexUtils.GetStringQuery(ref inputData, "db_id")?.Replace("'", "\\'");
|
||||
|
||||
if (string.IsNullOrEmpty(user_name))
|
||||
{
|
||||
return "{\"code\":500,\"msg\":\"没有用户名\"}";
|
||||
}
|
||||
|
||||
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
||||
MysqlUtils mySql = new MysqlUtils(conn);
|
||||
string sql = "delete from bxx.ext_code_price 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 MdyDBExtCodePrice(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 db_id = RegexUtils.GetStringQuery(ref inputData, "db_id");
|
||||
string ext_code = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "ext_code"));
|
||||
string ext_code_price = RegexUtils.GetStringQuery(ref inputData, "original_price");
|
||||
|
||||
if (string.IsNullOrEmpty(user_name))
|
||||
{
|
||||
return "{\"code\":500,\"msg\":\"没有用户名\"}";
|
||||
}
|
||||
|
||||
List<MySqlParameter> paramLst = new List<MySqlParameter>();
|
||||
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@ext_code", Value = ext_code, });
|
||||
paramLst.Add(new MySqlParameter() { DbType = DbType.Int32, ParameterName = "@ext_code_price", Value = ext_code_price.ParseToInt(), });
|
||||
paramLst.Add(new MySqlParameter() { DbType = DbType.Int32, ParameterName = "@db_id", Value = db_id, });
|
||||
|
||||
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
||||
MysqlUtils mySql = new MysqlUtils(conn);
|
||||
|
||||
//string sqlExist = "select count(ext_code) from bxx.ext_code_price where ext_code=@ext_code and id!=@db_id";
|
||||
//var has = mySql.ExecuteFirst(sqlExist, paramLst.ToArray());
|
||||
//if (has != "0")
|
||||
//{
|
||||
// mySql.Close();
|
||||
// return "{\"code\":501,\"msg\":\"货号 " + ext_code + " 价格数据已存在\"}";
|
||||
//}
|
||||
|
||||
string sql = "update bxx.ext_code_price set";
|
||||
if (ext_code != null)
|
||||
sql += " ext_code=@ext_code,";
|
||||
if (ext_code_price != null)
|
||||
sql += " ext_code_price=@ext_code_price,";
|
||||
sql = sql.TrimEnd(',');
|
||||
sql += " where id=@db_id;";
|
||||
|
||||
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\":\"输入为空\"}";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user