782 lines
40 KiB
C#
782 lines
40 KiB
C#
using KJD_Web.Model;
|
|
using KJD_Web.Utils;
|
|
using Mysqlx.Crud;
|
|
using NaiBa.Util.Extension;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Net;
|
|
using System.Reflection;
|
|
using System.Web;
|
|
using System.Web.Security;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace KJD_Web.BLL.WXXD
|
|
{
|
|
public class WXUserManage
|
|
{
|
|
public static bool GetSign(string signData, bool isUserLogin = false)
|
|
{
|
|
if (string.IsNullOrEmpty(signData)) { return false; }
|
|
|
|
var time = 0;
|
|
int.TryParse(RegexUtils.GetStringQuery(ref signData, "time"), out time);
|
|
string time1 = RegexUtils.GetStringQuery(ref signData, "code");
|
|
if (time1 != EncrypUtil.Encryption(time))
|
|
return false;
|
|
|
|
if (!isUserLogin)
|
|
{
|
|
var user_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref signData, "user_name"))?.ParseToString();
|
|
if (user_name.IsNullOrEmpty())
|
|
{
|
|
//return "{\"code\":500,\"msg\":\"请输入用户名\"}";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
public string CheckUserLogin(string inputData)
|
|
{
|
|
if (!string.IsNullOrEmpty(inputData))
|
|
{
|
|
if (!GetSign(inputData, true))
|
|
return "{\"code\":999,\"msg\":\"校验失败\"}";
|
|
|
|
var mobile = RegexUtils.GetStringQuery(ref inputData, "mobile")?.Replace("'", "\\'");
|
|
var password = RegexUtils.GetStringQuery(ref inputData, "password")?.Replace("'", "\\'");
|
|
|
|
var version = RegexUtils.GetStringQuery(ref inputData, "version").ParseToInt();
|
|
if (version < (System.Configuration.ConfigurationManager.ConnectionStrings["LimitVersion"]?.ConnectionString).ParseToInt())
|
|
return "{\"code\":1,\"msg\":\"当前版本过于陈旧,请立即升级新版\"}";
|
|
|
|
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 u.*,uu.authority as main_authority " +
|
|
"FROM wxxd.user u LEFT JOIN wxxd.user uu ON uu.user_name=u.parent_user_name where u.user_name='"
|
|
+ mobile + "' and u.password='" + password + "'";
|
|
|
|
var dt = mySql.ExecuteDataTable(sql);
|
|
if (!string.IsNullOrEmpty(mySql.Message))
|
|
{
|
|
mySql.Close();
|
|
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}";
|
|
}
|
|
|
|
if (dt == null)
|
|
dt = new DataTable();
|
|
|
|
foreach (DataRow row in dt.Rows)
|
|
{
|
|
UserLoginResultParam user = new UserLoginResultParam
|
|
{
|
|
id = Convert.ToInt32(row["id"]),
|
|
user_name = row["user_name"].ToString(),
|
|
nick_name = row["nick_name"].ToString(),
|
|
mobile = row["user_name"].ToString(),
|
|
password = row["password"].ToString(),
|
|
group_id = row["group_id"].ToString(),
|
|
card_id = row["card_id"].ToString(),
|
|
company_name = row["company_name"].ToString(),
|
|
is_sa = row.Table.Columns.Contains("is_sa") ? row["is_sa"].ParseToInt() : 0,
|
|
sa_level = row.Table.Columns.Contains("sa_level") ? row["sa_level"].ParseToInt() : 0,
|
|
authority = row.Table.Columns.Contains("authority") ? row["authority"].ParseToString() : "",
|
|
parent_user_name = row["parent_user_name"].ToString(),
|
|
points = row.Table.Columns.Contains("points") ? row["points"].ParseToInt() : 0,
|
|
};
|
|
var main_authority = row.Table.Columns.Contains("main_authority") ? row["main_authority"].ParseToString() : "";
|
|
// 子账号积分用户权限跟随
|
|
if (user.group_id != "3")
|
|
{
|
|
var userAuthLst = user.authority.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).ToList();
|
|
if (!main_authority.Contains("积分用户"))
|
|
{
|
|
userAuthLst.Remove("积分用户");
|
|
user.authority = string.Join(",", userAuthLst);
|
|
}
|
|
else if (!user.authority.Contains("积分用户"))
|
|
{
|
|
user.authority = (user.authority + "," + "积分用户").Trim(',');
|
|
}
|
|
}
|
|
if (string.IsNullOrEmpty(user.company_name))
|
|
{
|
|
user.company_name = "-";
|
|
}
|
|
if (user.group_id != "3" && !string.IsNullOrEmpty(user.parent_user_name))
|
|
{
|
|
sql = "select authority from wxxd.user where user_name='" + user.parent_user_name + "'";
|
|
var rst = mySql.ExecuteFirst(sql);
|
|
if (mySql.Message.IsNullOrEmpty())
|
|
{
|
|
user.parent_authority = rst;
|
|
}
|
|
}
|
|
|
|
var data = JsonUtils.SerializeObjectToString(user);
|
|
|
|
mySql.Close();
|
|
return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"c\":\"" + EncrypUtil.Encryption(r2) + "\"}";
|
|
}
|
|
mySql.Close();
|
|
return "{\"code\":1,\"msg\":\"用户名或密码错误\"}";
|
|
|
|
}
|
|
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
|
}
|
|
|
|
public string AddSubUser(string inputData)
|
|
{
|
|
if (!string.IsNullOrEmpty(inputData))
|
|
{
|
|
if (!GetSign(inputData))
|
|
return "{\"code\":999,\"msg\":\"校验失败\"}";
|
|
|
|
var parent_user_name = RegexUtils.GetStringQuery(ref inputData, "user_name")?.Replace("'", "\\'");
|
|
var nick_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sub_nick_name"))?.Replace("'", "\\'");
|
|
var user_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sub_name"))?.Replace("'", "\\'");
|
|
var mobile = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sub_mobile"))?.Replace("'", "\\'");
|
|
var password = RegexUtils.GetStringQuery(ref inputData, "sub_password")?.Replace("'", "\\'");
|
|
var group_id = RegexUtils.GetStringQuery(ref inputData, "group_id")?.Replace("'", "\\'");
|
|
var card_id = RegexUtils.GetStringQuery(ref inputData, "card_id")?.Replace("'", "\\'");
|
|
var company_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "company"))?.Replace("'", "\\'");
|
|
var notes = RegexUtils.GetStringQuery(ref inputData, "notes")?.Replace("'", "\\'");
|
|
var authority = RegexUtils.GetStringQuery(ref inputData, "authority")?.Replace("'", "\\'");
|
|
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 = "";
|
|
sql = "select exists (select 1 from wxxd.user where user_name='" + user_name + "')";
|
|
var exist = mySql.ExecuteFirstInt(sql);
|
|
if (exist > 0)
|
|
{
|
|
mySql.Close();
|
|
return "{\"code\":500,\"msg\":\"用户名已存在\"}";
|
|
}
|
|
|
|
sql = "insert into wxxd.user (nick_name,user_name,mobile,password,card_id,group_id,company_name,notes,parent_user_name,authority,add_time,mdy_time) " +
|
|
"values ('" + nick_name + "','" + user_name + "','" + mobile + "','" + password + "','" + card_id + "','" +
|
|
group_id + "','" + company_name + "','" + notes + "','" + parent_user_name + "','" + authority + "','" +
|
|
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','" +
|
|
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "');";
|
|
var rst = mySql.ExecuteNonQuery(sql);
|
|
mySql.Close();
|
|
if (!rst)
|
|
return "{\"code\":501,\"msg\":\""+ mySql.Message + "\"}";
|
|
else
|
|
return "{\"code\":200,\"msg\":\"子账户创建成功!\"}";
|
|
}
|
|
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
|
}
|
|
|
|
public string GetSubUser(string inputData)
|
|
{
|
|
if (!string.IsNullOrEmpty(inputData))
|
|
{
|
|
if (!GetSign(inputData))
|
|
return "{\"code\":999,\"msg\":\"校验失败\"}";
|
|
|
|
var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
|
|
var password = RegexUtils.GetStringQuery(ref inputData, "password");
|
|
var group = RegexUtils.GetStringQuery(ref inputData, "group");
|
|
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 * from wxxd.user where parent_user_name='"
|
|
+ user_name + "'";
|
|
|
|
var dt = mySql.ExecuteDataTable(sql);
|
|
mySql.Close();
|
|
if (dt != null)
|
|
{
|
|
List<UserLoginResultParam> userList = new List<UserLoginResultParam>();
|
|
foreach (DataRow row in dt.Rows)
|
|
{
|
|
|
|
UserLoginResultParam user = new UserLoginResultParam
|
|
{
|
|
id = Convert.ToInt32(row["id"]),
|
|
user_name = row["user_name"].ToString(),
|
|
nick_name = row["nick_name"].ToString(),
|
|
mobile = row["mobile"].ToString(),
|
|
password = row["password"].ToString(),
|
|
group_id = row["group_id"].ToString(),
|
|
card_id = row["card_id"].ToString(),
|
|
parent_user_name = row["parent_user_name"].ToString(),
|
|
company_name = row["company_name"].ToString(),
|
|
notes = row["notes"].ToString(),
|
|
authority = row.Table.Columns.Contains("authority") ? row["authority"].ParseToString() : "",
|
|
};
|
|
if (string.IsNullOrEmpty(user.mobile))
|
|
{
|
|
user.mobile = row["user_name"].ToString();
|
|
}
|
|
userList.Add(user);
|
|
}
|
|
var data = JsonUtils.SerializeObjectToString(userList);
|
|
return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"c\":\"" + EncrypUtil.Encryption(r2) + "\"}";
|
|
}
|
|
}
|
|
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
|
}
|
|
|
|
public string UpdateSubUser(string inputData)
|
|
{
|
|
if (!string.IsNullOrEmpty(inputData))
|
|
{
|
|
if (!GetSign(inputData))
|
|
return "{\"code\":999,\"msg\":\"校验失败\"}";
|
|
|
|
var id = RegexUtils.GetStringQuery(ref inputData, "id")?.Replace("'", "\\'");
|
|
var parent_user_name = RegexUtils.GetStringQuery(ref inputData, "user_name")?.Replace("'", "\\'");
|
|
var nick_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sub_nick_name"))?.Replace("'", "\\'");
|
|
var user_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sub_name"))?.Replace("'", "\\'");
|
|
var mobile = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sub_mobile"))?.Replace("'", "\\'");
|
|
var password = RegexUtils.GetStringQuery(ref inputData, "sub_password")?.Replace("'", "\\'");
|
|
var group_id = RegexUtils.GetStringQuery(ref inputData, "group_id")?.Replace("'", "\\'");
|
|
var card_id = RegexUtils.GetStringQuery(ref inputData, "card_id")?.Replace("'", "\\'");
|
|
var notes = RegexUtils.GetStringQuery(ref inputData, "notes")?.Replace("'", "\\'");
|
|
var authority = RegexUtils.GetStringQuery(ref inputData, "authority")?.Replace("'", "\\'");
|
|
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 = "";
|
|
//sql = "select * from wxxd.user where parent_user_name='"
|
|
// + user_name + "'";
|
|
sql = "update wxxd.user set";
|
|
if (!string.IsNullOrEmpty(nick_name))
|
|
sql += " nick_name='" + nick_name + "',";
|
|
if (!string.IsNullOrEmpty(user_name))
|
|
sql += " user_name='" + user_name + "',";
|
|
if (!string.IsNullOrEmpty(mobile))
|
|
sql += " mobile='" + mobile + "',";
|
|
if (!string.IsNullOrEmpty(password))
|
|
sql += " password='" + password + "',";
|
|
if (!string.IsNullOrEmpty(group_id))
|
|
sql += " group_id=" + group_id + ",";
|
|
if (!string.IsNullOrEmpty(card_id))
|
|
sql += " card_id='" + card_id + "',";
|
|
if (!string.IsNullOrEmpty(notes))
|
|
sql += " notes='" + notes + "',";
|
|
if (authority != null)
|
|
sql += " authority='" + authority + "',";
|
|
sql = sql.TrimEnd(',');
|
|
sql += " where id=" + id + "";
|
|
|
|
var rst = mySql.ExecuteNonQuery(sql);
|
|
mySql.Close();
|
|
if (rst)
|
|
{
|
|
return "{\"code\":200,\"msg\":\"success\"}";
|
|
}
|
|
}
|
|
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
|
}
|
|
|
|
public string DelUser(string inputData)
|
|
{
|
|
if (!string.IsNullOrEmpty(inputData))
|
|
{
|
|
if (!GetSign(inputData))
|
|
return "{\"code\":999,\"msg\":\"校验失败\"}";
|
|
|
|
var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
|
|
var id = RegexUtils.GetStringQuery(ref inputData, "id");
|
|
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 = "delete from wxxd.user where id='"
|
|
+ id + "'";
|
|
|
|
var rst = mySql.ExecuteNonQuery(sql);
|
|
mySql.Close();
|
|
if (rst)
|
|
{
|
|
return "{\"code\":200,\"msg\":\"success\"}";
|
|
}
|
|
else
|
|
return "{\"code\":500,\"msg\":\"删除失败,请稍后重试\"}";
|
|
}
|
|
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
|
}
|
|
|
|
public string GetAllUser(string inputData)
|
|
{
|
|
if (!string.IsNullOrEmpty(inputData))
|
|
{
|
|
if (!GetSign(inputData))
|
|
return "{\"code\":999,\"msg\":\"校验失败\"}";
|
|
|
|
var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name")?.Replace("'", "\\'");
|
|
var password = RegexUtils.GetStringQuery(ref inputData, "password")?.Replace("'", "\\'");
|
|
var group_id = RegexUtils.GetStringQuery(ref inputData, "group_id")?.Replace("'", "\\'");
|
|
var search = RegexUtils.GetStringQuery(ref inputData, "search")?.Replace("'", "\\'");
|
|
var sa_level = RegexUtils.GetStringQuery(ref inputData, "sa_level")?.Replace("'", "\\'");
|
|
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 * from wxxd.user where group_id=3";
|
|
string sql = "select u.*,uu.authority as main_authority from wxxd.user u " +
|
|
"LEFT JOIN wxxd.user uu ON uu.user_name=u.parent_user_name WHERE 1=1";
|
|
if (!string.IsNullOrEmpty(group_id))
|
|
sql += " and u.group_id=" + group_id;
|
|
if (!string.IsNullOrEmpty(sa_level))
|
|
sql += " and u.sa_level=" + sa_level;
|
|
if (!string.IsNullOrEmpty(search))
|
|
sql += " and (u.user_name like '%" + search +
|
|
"%' or u.nick_name like '%" + search +
|
|
"%' or u.company_name like '%" + search + "%')";
|
|
sql += " order by u.id desc";
|
|
|
|
var dt = mySql.ExecuteDataTable(sql);
|
|
mySql.Close();
|
|
if (dt != null)
|
|
{
|
|
List<UserLoginResultParam> userList = new List<UserLoginResultParam>();
|
|
foreach (DataRow row in dt.Rows)
|
|
{
|
|
|
|
UserLoginResultParam user = new UserLoginResultParam
|
|
{
|
|
id = Convert.ToInt32(row["id"]),
|
|
user_name = row["user_name"].ToString(),
|
|
nick_name = row["nick_name"].ToString(),
|
|
mobile = row["mobile"].ToString(),
|
|
password = row["password"].ToString(),
|
|
group_id = row["group_id"].ToString(),
|
|
card_id = row["card_id"].ToString(),
|
|
parent_user_name = row["parent_user_name"].ToString(),
|
|
company_name = row["company_name"].ToString(),
|
|
notes = row["notes"].ToString(),
|
|
is_sa = row.Table.Columns.Contains("is_sa") ? row["is_sa"].ParseToInt() : 0,
|
|
sa_level = row.Table.Columns.Contains("sa_level") ? row["sa_level"].ParseToInt() : 0,
|
|
authority = row.Table.Columns.Contains("authority") ? row["authority"].ParseToString() : "",
|
|
points = row.Table.Columns.Contains("points") ? row["points"].ParseToInt() : 0,
|
|
};
|
|
var main_authority = row.Table.Columns.Contains("main_authority") ? row["main_authority"].ParseToString() : "";
|
|
// 子账号积分用户权限跟随
|
|
if (user.group_id != "3")
|
|
{
|
|
var userAuthLst = user.authority.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).ToList();
|
|
if (!main_authority.Contains("积分用户"))
|
|
{
|
|
userAuthLst.Remove("积分用户");
|
|
user.authority = string.Join(",", userAuthLst);
|
|
}
|
|
else if (!user.authority.Contains("积分用户"))
|
|
{
|
|
user.authority = (user.authority + "," + "积分用户").Trim(',');
|
|
}
|
|
}
|
|
if (string.IsNullOrEmpty(user.mobile))
|
|
{
|
|
user.mobile = row["user_name"].ToString();
|
|
}
|
|
userList.Add(user);
|
|
}
|
|
var data = JsonUtils.SerializeObjectToString(userList);
|
|
return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"c\":\"" + EncrypUtil.Encryption(r2) + "\"}";
|
|
}
|
|
}
|
|
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
|
}
|
|
|
|
public string AddUser(string inputData)
|
|
{
|
|
if (!string.IsNullOrEmpty(inputData))
|
|
{
|
|
if (!GetSign(inputData))
|
|
return "{\"code\":999,\"msg\":\"校验失败\"}";
|
|
|
|
var nick_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "add_nick_name"))?.Replace("'", "\\'");
|
|
var user_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "add_user_name"))?.Replace("'", "\\'");
|
|
var mobile = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "add_mobile"))?.Replace("'", "\\'");
|
|
var password = RegexUtils.GetStringQuery(ref inputData, "add_password")?.Replace("'", "\\'");
|
|
var company_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "add_company"))?.Replace("'", "\\'");
|
|
var group_id = RegexUtils.GetStringQuery(ref inputData, "group_id")?.Replace("'", "\\'"); ;
|
|
var card_id = RegexUtils.GetStringQuery(ref inputData, "card_id")?.Replace("'", "\\'");
|
|
var notes = RegexUtils.GetStringQuery(ref inputData, "notes")?.Replace("'", "\\'");
|
|
var sa_level = RegexUtils.GetStringQuery(ref inputData, "sa_level")?.Replace("'", "\\'");
|
|
var authority = RegexUtils.GetStringQuery(ref inputData, "authority")?.Replace("'", "\\'");
|
|
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 = "";
|
|
sql = "select exists (select 1 from wxxd.user where user_name='" + user_name + "')";
|
|
var exist = mySql.ExecuteFirstInt(sql);
|
|
if (exist > 0)
|
|
{
|
|
mySql.Close();
|
|
return "{\"code\":500,\"msg\":\"用户名已存在\"}";
|
|
}
|
|
|
|
sql = "insert into wxxd.user (nick_name,user_name,mobile,password,card_id,group_id,company_name,notes,sa_level,authority,add_time,mdy_time) " +
|
|
"values ('" + nick_name + "','" + user_name + "','" + mobile + "','" + password + "','" + card_id + "','" +
|
|
group_id + "','" + company_name + "','" + notes + "'," + sa_level + ",'" + authority + "','" +
|
|
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','" +
|
|
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "');";
|
|
var rst = mySql.ExecuteNonQuery(sql);
|
|
mySql.Close();
|
|
if (!rst)
|
|
return "{\"code\":501,\"msg\":\"" + mySql.Message + "\"}";
|
|
else
|
|
return "{\"code\":200,\"msg\":\"success\"}";
|
|
}
|
|
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
|
}
|
|
|
|
public string UpdateUser(string inputData)
|
|
{
|
|
if (!string.IsNullOrEmpty(inputData))
|
|
{
|
|
if (!GetSign(inputData))
|
|
return "{\"code\":999,\"msg\":\"校验失败\"}";
|
|
|
|
var id = RegexUtils.GetStringQuery(ref inputData, "id")?.Replace("'", "\\'");
|
|
var nick_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "add_nick_name"))?.Replace("'", "\\'");
|
|
var user_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "add_user_name"))?.Replace("'", "\\'");
|
|
var mobile = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "add_mobile"))?.Replace("'", "\\'");
|
|
var company_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "add_company"))?.Replace("'", "\\'");
|
|
var password = RegexUtils.GetStringQuery(ref inputData, "add_password")?.Replace("'", "\\'");
|
|
var group_id = RegexUtils.GetStringQuery(ref inputData, "group_id")?.Replace("'", "\\'");
|
|
var card_id = RegexUtils.GetStringQuery(ref inputData, "card_id")?.Replace("'", "\\'");
|
|
var notes = RegexUtils.GetStringQuery(ref inputData, "notes")?.Replace("'", "\\'");
|
|
var sa_level = RegexUtils.GetStringQuery(ref inputData, "sa_level")?.Replace("'", "\\'");
|
|
var authority = RegexUtils.GetStringQuery(ref inputData, "authority")?.Replace("'", "\\'");
|
|
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 = "";
|
|
//sql = "select * from wxxd.user where parent_user_name='"
|
|
// + user_name + "'";
|
|
sql = "update wxxd.user set";
|
|
if (!string.IsNullOrEmpty(nick_name))
|
|
sql += " nick_name='" + nick_name + "',";
|
|
if (!string.IsNullOrEmpty(user_name))
|
|
sql += " user_name='" + user_name + "',";
|
|
if (!string.IsNullOrEmpty(mobile))
|
|
sql += " mobile='" + mobile + "',";
|
|
if (!string.IsNullOrEmpty(company_name))
|
|
sql += " company_name='" + company_name + "',";
|
|
if (!string.IsNullOrEmpty(password))
|
|
sql += " password='" + password + "',";
|
|
if (!string.IsNullOrEmpty(group_id))
|
|
sql += " group_id=" + group_id + ",";
|
|
if (!string.IsNullOrEmpty(card_id))
|
|
sql += " card_id='" + card_id + "',";
|
|
if (!string.IsNullOrEmpty(notes))
|
|
sql += " notes='" + notes + "',";
|
|
if (!string.IsNullOrEmpty(sa_level))
|
|
sql += " sa_level=" + sa_level + ",";
|
|
if (authority != null)
|
|
sql += " authority='" + authority + "',";
|
|
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 UpdateUserPointsTest(string inputData)
|
|
{
|
|
if (!string.IsNullOrEmpty(inputData))
|
|
{
|
|
if (!GetSign(inputData))
|
|
return "{\"code\":999,\"msg\":\"校验失败\"}";
|
|
|
|
var id = RegexUtils.GetStringQuery(ref inputData, "id")?.Replace("'", "\\'");
|
|
var delta_points = RegexUtils.GetStringQuery(ref inputData, "delta_points")?.Replace("'", "\\'");
|
|
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 = "";
|
|
//sql = "select * from wxxd.user where parent_user_name='"
|
|
// + user_name + "'";
|
|
sql = "update wxxd.user set";
|
|
if (!string.IsNullOrEmpty(delta_points))
|
|
sql += " points=points+" + delta_points.ParseToInt() + ",";
|
|
sql = sql.TrimEnd(',');
|
|
sql += " where id=" + id + "";
|
|
|
|
var rst = mySql.ExecuteNonQuery(sql);
|
|
mySql.Close();
|
|
if (rst)
|
|
{
|
|
return "{\"code\":200,\"msg\":\"success\"}";
|
|
}
|
|
}
|
|
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
|
}
|
|
|
|
/// <summary>
|
|
/// 增加或减少用户积分
|
|
/// </summary>
|
|
/// <param name="inputData"></param>
|
|
/// <returns></returns>
|
|
public string UpdateUserPoints(string inputData)
|
|
{
|
|
if (!string.IsNullOrEmpty(inputData))
|
|
{
|
|
if (!GetSign(inputData))
|
|
return "{\"code\":999,\"msg\":\"校验失败\"}";
|
|
|
|
var user_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "update_user_name"))?.Replace("'", "\\'");
|
|
var user_nick = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "update_user_nick"))?.Replace("'", "\\'");
|
|
var delta_points = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "delta_points"))?.ParseToInt();
|
|
var option_type = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "option_type"))?.Replace("'", "\\'");
|
|
var operator_type = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "operator_type"))?.Replace("'", "\\'");
|
|
var operator_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "operator_name"))?.Replace("'", "\\'");
|
|
var shop_id = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "shop_id"))?.Replace("'", "\\'");
|
|
var shop_account = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "shop_account"))?.Replace("'", "\\'");
|
|
|
|
if (string.IsNullOrEmpty(user_name) || string.IsNullOrEmpty(user_nick))
|
|
{
|
|
return "{\"code\":500,\"msg\":\"充值对象不能为空\"}";
|
|
}
|
|
if (delta_points.IsNullOrZero())
|
|
{
|
|
return "{\"code\":500,\"msg\":\"充值金额不合法\"}";
|
|
}
|
|
if (string.IsNullOrEmpty(option_type) || string.IsNullOrEmpty(operator_type) || string.IsNullOrEmpty(operator_name))
|
|
{
|
|
return "{\"code\":500,\"msg\":\"操作或操作者信息不合法\"}";
|
|
}
|
|
|
|
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
|
MysqlUtils mySql = new MysqlUtils(conn);
|
|
mySql.Close();
|
|
//////string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
|
//////MysqlUtils mySql = new MysqlUtils(conn);
|
|
//////string sql = "";
|
|
//////sql += " START TRANSACTION";
|
|
//////sql += " SELECT * FROM wxxd.user WHERE user_name='" + user_name + "' FOR UPDATE;";
|
|
//////sql += " INSERT INTO wxxd.user_points_record(user_name,user_nick,points,option_type,operator_type,operator_name,shop_id,shop_account)";
|
|
//////sql += " VALUES()";
|
|
//////sql += " UPDATE wxxd.user SET points = points + delta_points";
|
|
|
|
////////INSERT INTO TableB(column1, column2)
|
|
////////SELECT A.column1, 'some_value' AS column2
|
|
////////FROM TableA A
|
|
////////WHERE A.value > 100;
|
|
|
|
//////sql = "select points from wxxd.user where user_name='" + user_name + "'";
|
|
//////var rst1 = mySql.ExecuteFirstInt(sql);
|
|
|
|
|
|
//sql = "UPDATE wxxd.user SET";
|
|
//if (option_type == "充值")
|
|
// sql += " points=points+" + delta_points.ParseToInt() + ",";
|
|
//else
|
|
// sql += " points=points-" + delta_points.ParseToInt() + ",";
|
|
//sql = sql.TrimEnd(',');
|
|
//sql += " where id=" + id + "";
|
|
//-
|
|
//if (!string.IsNullOrEmpty(notes))
|
|
// sql += " notes='" + notes + "',";
|
|
//if (!string.IsNullOrEmpty(sa_level))
|
|
// sql += " sa_level=" + sa_level + ",";
|
|
//if (authority != null)
|
|
// sql += " authority='" + authority + "',";
|
|
//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\":200,\"msg\":\"success\"}";
|
|
}
|
|
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
|
}
|
|
|
|
public string ChangePassword(string inputData)
|
|
{
|
|
if (!GetSign(inputData))
|
|
return "{\"code\":999,\"msg\":\"校验失败\"}";
|
|
|
|
var userName = RegexUtils.GetStringJson(ref inputData, "user_name")?.Replace("'", "\\'");
|
|
var password = RegexUtils.GetStringJson(ref inputData, "password")?.Replace("'", "\\'");
|
|
var newPassword = RegexUtils.GetStringJson(ref inputData, "new_password")?.Replace("'", "\\'");
|
|
|
|
if (string.IsNullOrWhiteSpace(userName) || string.IsNullOrWhiteSpace(password) || string.IsNullOrWhiteSpace(newPassword))
|
|
{
|
|
return "{\"code\":500,\"msg\":\"输入不能为空\"}";
|
|
}
|
|
|
|
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["Conn"].ConnectionString;
|
|
MysqlUtils mySql = new MysqlUtils(conn);
|
|
string sql = "select user_id,password from pepdtp.user where user_id='"
|
|
+ userName + "' and password='" + password + "'";
|
|
|
|
var dw = mySql.ExecuteDataTableRow(sql);
|
|
if (dw != null)
|
|
{
|
|
UserLoginResultParam user = new UserLoginResultParam
|
|
{
|
|
user_name = dw["user_id"].ToString(),
|
|
password = dw["password"].ToString(),
|
|
};
|
|
sql = "update pepdtp.user set password = '" + newPassword + "' where user_id='" + userName + "'";
|
|
var result = mySql.ExecuteNonQuery(sql);
|
|
mySql.Close();
|
|
|
|
if (result)
|
|
{
|
|
return "{\"code\":0,\"msg\":\"密码修改成功!\"}";
|
|
}
|
|
else
|
|
return "{\"code\":19999,\"msg\":\"密码修改失败!请稍后再试。\"}";
|
|
}
|
|
else
|
|
{
|
|
mySql.Close();
|
|
return "{\"code\":1,\"msg\":\"原密码错误。\"}";
|
|
}
|
|
}
|
|
|
|
public string UpdateWxSaleAssistantCookie(string inputData)
|
|
{
|
|
if (!string.IsNullOrEmpty(inputData))
|
|
{
|
|
var id = (RegexUtils.GetStringQuery(ref inputData, "db_id")?.Replace("'", "\\'")).ParseToInt();
|
|
if (id == 0)
|
|
id = 1;
|
|
var cookie = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "cookie"))?.Replace("'", "\\'");
|
|
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 conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
|
MysqlUtils mySql = new MysqlUtils(conn);
|
|
string sql = "update wxxd.wx_sale_assistant_user set cookie='" + cookie + "' WHERE id=" + id + ";";
|
|
|
|
var rst = mySql.ExecuteNonQuery(sql);
|
|
mySql.Close();
|
|
if (rst && string.IsNullOrEmpty(mySql.Message))
|
|
{
|
|
return "{\"code\":200,\"msg\":\"success\"}";
|
|
}
|
|
if (!string.IsNullOrEmpty(mySql.Message))
|
|
{
|
|
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}";
|
|
}
|
|
}
|
|
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
|
}
|
|
|
|
public string GetWxSaleAssistantCookie(string inputData)
|
|
{
|
|
if (!string.IsNullOrEmpty(inputData))
|
|
{
|
|
var id = (RegexUtils.GetStringQuery(ref inputData, "db_id")?.Replace("'", "\\'")).ParseToInt();
|
|
if (id == 0)
|
|
id = 1;
|
|
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 conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
|
MysqlUtils mySql = new MysqlUtils(conn);
|
|
string sql = "select cookie from wxxd.wx_sale_assistant_user WHERE id=" + id + ";";
|
|
|
|
var rst = mySql.ExecuteDataTableRow(sql);
|
|
mySql.Close();
|
|
if (string.IsNullOrEmpty(mySql.Message))
|
|
{
|
|
return "{\"code\":200,\"cookie\":" + rst["cookie"] + "}";
|
|
}
|
|
if (!string.IsNullOrEmpty(mySql.Message))
|
|
{
|
|
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}";
|
|
}
|
|
}
|
|
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
|
}
|
|
|
|
/// <summary>
|
|
/// temu退回包裹的密钥
|
|
/// </summary>
|
|
public string return_package_secret_key { get; set; } = "aaMETt2bPe6YHzZ1ojbC+6wOvgtwehqc6A+/Rz+pCUU=";
|
|
|
|
/// <summary>
|
|
/// temu退回包裹的签名
|
|
/// </summary>
|
|
/// <param name="inputData"></param>
|
|
/// <returns></returns>
|
|
public string GetPackageSign(string inputData)
|
|
{
|
|
if (!string.IsNullOrEmpty(inputData))
|
|
{
|
|
var mobile = RegexUtils.GetStringQuery(ref inputData, "mobile")?.Replace("'", "\\'");
|
|
var password = RegexUtils.GetStringQuery(ref inputData, "password")?.Replace("'", "\\'");
|
|
var timestamp = RegexUtils.GetStringQuery(ref inputData, "timestamp")?.Replace("'", "\\'");
|
|
var mallId = RegexUtils.GetStringQuery(ref inputData, "mallId")?.Replace("'", "\\'");
|
|
var returnPackageNo = RegexUtils.GetStringQuery(ref inputData, "returnPackageNo")?.Replace("'", "\\'");
|
|
int r2 = RegexUtils.GetStringQuery(ref inputData, "r2").ParseToInt();
|
|
string c2 = RegexUtils.GetStringQuery(ref inputData, "c2");
|
|
|
|
if (EncrypUtil.Encryption(r2) != c2)
|
|
return "{\"code\":2,\"msg\":\"不合法的输入内容\"}";
|
|
|
|
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
|
MysqlUtils mySql = new MysqlUtils(conn);
|
|
string sql = "select * from wxxd.user where user_name='"
|
|
+ mobile + "' and password='" + password + "'";
|
|
|
|
sql = "select * from wxxd.user where user_name='" + mobile + "'";
|
|
|
|
var dt = mySql.ExecuteDataTable(sql);
|
|
mySql.Close();
|
|
if (dt == null || dt.Rows.Count <=0)
|
|
{
|
|
return "{\"code\":1,\"msg\":\"用户不存在\"}";
|
|
}
|
|
|
|
string sign = EncrypUtil.GetMd5(timestamp + return_package_secret_key + mallId + returnPackageNo).ToLower();
|
|
|
|
return "{\"code\":200, \"sign\":\"" + sign + "\", \"msg\":\"\"}";
|
|
}
|
|
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
|
}
|
|
}
|
|
} |