1Jit相关功能 50% 2 其他部分优化修改

This commit is contained in:
wule committed 2025-11-26 18:27:21 +08:00
1 parent 4d5ea741d7
commit e77914bafc
49 files changed
+2576 -419

No files matched your search

+221 -1
View File
@@ -8,6 +8,7 @@ using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Security;
@@ -94,7 +95,10 @@ namespace KJD_Web.BLL
}
else
{
sql = "SELECT s.*,c.add_product_remaining add_remaining,c.add_product_month add_month FROM kjd.shop s LEFT JOIN kjd.shop_add_prod_count c ON s.shop_id=c.shop_id WHERE 1=1";
sql = "SELECT s.*,c.add_product_remaining add_remaining,c.add_product_month add_month,cc.jit_expire_time FROM kjd.shop s" +
" LEFT JOIN kjd.shop_add_prod_count c ON s.shop_id=c.shop_id" +
" LEFT JOIN (SELECT shop_id, MAX(expire_time) as jit_expire_time FROM kjd.card_code GROUP BY shop_id) cc ON s.shop_id=cc.shop_id" +
" WHERE 1=1";
sql += where; // where 子句
@@ -131,6 +135,7 @@ namespace KJD_Web.BLL
ad_login_status = row["ad_login_status"].ParseToString(),
ad_seller_unique_id = row["ad_seller_unique_id"].ParseToString(),
ad_url = row["ad_url"].ParseToString(),
jit_expire_time = row["jit_expire_time"].IsNullOrEmpty() ? new DateTime?() : Convert.ToDateTime(row["jit_expire_time"]),
};
shopList.Add(shop);
}
@@ -807,5 +812,220 @@ namespace KJD_Web.BLL
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string GetShopCardCodeList(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
var password = RegexUtils.GetStringQuery(ref inputData, "password");
var search_card_code_id = RegexUtils.GetStringQuery(ref inputData, "search_card_code_id");
var search_shop_id = RegexUtils.GetStringQuery(ref inputData, "search_shop_id");
var search_shop_name = RegexUtils.GetStringQuery(ref inputData, "search_shop_name");
var search_notes = RegexUtils.GetStringQuery(ref inputData, "search_notes");
var card_code_ids = RegexUtils.GetStringQuery(ref inputData, "card_code_ids")?.Replace("'", "");
var sort_field = RegexUtils.GetStringQuery(ref inputData, "sort_field")?.Replace("'", "");
if (!string.IsNullOrWhiteSpace(card_code_ids))
{
List<string> shopIdLst = card_code_ids.Split(',').ToList();
card_code_ids = "'" + string.Join("','", shopIdLst) + "'";
}
var shop_ids = RegexUtils.GetStringQuery(ref inputData, "shop_ids")?.Replace("'", "");
if (!string.IsNullOrWhiteSpace(shop_ids))
{
List<string> shopIdLst = shop_ids.Split(',').ToList();
shop_ids = "'" + string.Join("','", shopIdLst) + "'";
}
var shop_names = RegexUtils.GetStringQuery(ref inputData, "shop_names");
if (!string.IsNullOrWhiteSpace(shop_names))
{
List<string> shopNameLst = shop_names.Split(',').ToList();
shop_names = "'" + string.Join("','", shopNameLst) + "'";
}
var list_notes = RegexUtils.GetStringQuery(ref inputData, "list_notes");
if (!string.IsNullOrWhiteSpace(list_notes))
{
List<string> notesLst = list_notes.Split(',').ToList();
list_notes = "'" + string.Join("','", notesLst) + "'";
}
var page = RegexUtils.GetStringQuery(ref inputData, "page").ParseToInt();
var page_size = RegexUtils.GetStringQuery(ref inputData, "page_size").ParseToInt();
if (page_size == 0)
page_size = 50;
int r2 = 0;
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "SELECT COUNT(s.id) FROM kjd.card_code s WHERE 1=1";
//where子句
string where = "";
if (!string.IsNullOrWhiteSpace(search_card_code_id))
where += " and s.card_code_id like '%" + search_card_code_id + "%'";
if (!string.IsNullOrWhiteSpace(search_shop_id))
where += " and s.shop_id like '%" + search_shop_id + "%'";
if (!string.IsNullOrWhiteSpace(search_shop_name))
where += " and s.shop_account like '%" + search_shop_name + "%'";
if (!string.IsNullOrWhiteSpace(search_notes))
where += " and s.notes like '%" + search_notes + "%'";
if (!string.IsNullOrWhiteSpace(card_code_ids))
where += " and s.card_code_id in (" + card_code_ids + ")";
if (!string.IsNullOrWhiteSpace(shop_ids))
where += " and s.shop_id in (" + shop_ids + ")";
if (!string.IsNullOrWhiteSpace(shop_names))
where += " and s.shop_account in (" + shop_names + ")";
if (!string.IsNullOrWhiteSpace(list_notes))
where += " and s.notes in (" + list_notes + ")";
sql += where;
var count = mySql.ExecuteRowCount(sql);
DataTable dt;
if (count == 0)
{
dt = new DataTable();
}
else
{
sql = "SELECT s.* FROM kjd.card_code s WHERE 1=1";
sql += where; // where 子句
// 排序
if (sort_field == "expire_time")
sql += " ORDER BY s.expire_time DESC";
else
sql += " ORDER BY s.id DESC";
sql += " LIMIT " + Math.Max(page - 1, 0) * page_size + "," + page_size;
dt = mySql.ExecuteDataTable(sql);
}
mySql.Close();
if (dt != null)
{
List<JitCardCodeParam> cardCodeList = new List<JitCardCodeParam>();
foreach (DataRow row in dt.Rows)
{
JitCardCodeParam cardCode = new JitCardCodeParam
{
id = Convert.ToInt32(row["id"]),
shop_id = row["shop_id"].ToString(),
shop_account = row["shop_account"].ToString(),
add_time = (DateTime)row["add_time"],
active_time = row["active_time"].IsNullOrEmpty() ? new DateTime?() : Convert.ToDateTime(row["active_time"]),
expire_time = row["expire_time"].IsNullOrEmpty() ? new DateTime?() : Convert.ToDateTime(row["expire_time"]),
card_code_id = row["card_code_id"].ToString(),
notes = row["notes"].ToString(),
};
cardCodeList.Add(cardCode);
}
var data = JsonUtils.SerializerObjectToString(cardCodeList);
return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"count\":" + count + "}";
}
}
return "{\"code\":19999,\"msg\":\"未知错误\"}";
}
public string CreateShopCardCode(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 create_count = RegexUtils.GetStringQuery(ref inputData, "create_count")?.Replace("'", "\\'");
if (string.IsNullOrEmpty(create_count))
{
return "{\"code\":50002,\"msg\":\"未选择生成数量\"}";
}
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "insert into kjd.card_code (card_code_id) values ";
Random random = new Random(Guid.NewGuid().GetHashCode());
for (int i = 0; i < create_count.ParseToInt(); i++)
{
sql += "('" + GenerateCardCode(random, 16) + "'),";
}
sql = sql.TrimEnd(',') + ";";
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 DelShopCardCode(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 del_ids = RegexUtils.GetStringQuery(ref inputData, "del_ids")?.Replace("'", "\\'");
if (string.IsNullOrEmpty(del_ids))
{
return "{\"code\":50002,\"msg\":\"未选择删除数据\"}";
}
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "delete from kjd.card_code where id in (" + del_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\":\"输入为空\"}";
}
private static readonly char[] chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".ToCharArray(); // 增加特殊字符
public static string GenerateCardCode(Random random, int length)
{
StringBuilder result = new StringBuilder(length);
for (int i = 0; i < length; i++)
{
result.Append(chars[random.Next(chars.Length)]);
}
return result.ToString();
}
}
}