895 lines
44 KiB
C#
895 lines
44 KiB
C#
using StoreHub.KJDWebService.Services;
|
|
using StoreHub.Framework.Repositorys;
|
|
using Microsoft.Extensions.Configuration;
|
|
using StoreHub.KJDWebService.Models;
|
|
using StoreHub.KJDWebService.Models.PddModel;
|
|
using StoreHub.KJDWebService.Models.ShopModel;
|
|
using StoreHub.KJDWebService.Commons;
|
|
using NaiBa.Util.Extension;
|
|
using NaiBa.Util.Helper;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Net;
|
|
using System.Reflection;
|
|
|
|
namespace StoreHub.KJDWebService.Services
|
|
{
|
|
public class BXXUserService : ServiceBase
|
|
{
|
|
public BXXUserService(SqlRepository sqlRepository, IConfiguration configuration) : base(sqlRepository, configuration)
|
|
{
|
|
}
|
|
public string CheckUserLogin(string inputData)
|
|
{
|
|
if (!string.IsNullOrEmpty(inputData))
|
|
{
|
|
if (!WXUserService.GetSign(inputData, true))
|
|
return "{\"code\":999,\"msg\":\"校验失败\"}";
|
|
|
|
var mobile = RegexUtils.GetStringQuery(ref inputData, "mobile")?.Replace("'", "\\'");
|
|
var password = RegexUtils.GetStringQuery(ref inputData, "password")?.Replace("'", "\\'");
|
|
var r2 = RegexUtils.GetStringQuery(ref inputData, "r2").ParseToInt();
|
|
|
|
string conn = "ConnKJD";
|
|
MysqlUtils mySql = new MysqlUtils(conn);
|
|
string sql = "select * from bxx.user where user_name='"
|
|
+ mobile + "' and 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["authority"].ToString(),
|
|
forbidden_page = row["forbidden_page"].ToString(),
|
|
parent_user_name = row["parent_user_name"].ToString(),
|
|
};
|
|
|
|
if (string.IsNullOrEmpty(user.company_name))
|
|
{
|
|
user.company_name = "-";
|
|
}
|
|
if (user.group_id != "3" && !string.IsNullOrEmpty(user.parent_user_name))
|
|
{
|
|
sql = "select authority from bxx.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 (!WXUserService.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("'", "\\'");
|
|
var forbidden_page = RegexUtils.GetStringQuery(ref inputData, "forbidden_page")?.Replace("'", "\\'");
|
|
|
|
string conn = "ConnKJD";
|
|
MysqlUtils mySql = new MysqlUtils(conn);
|
|
string sql = "";
|
|
sql = "select exists (select 1 from bxx.user where user_name='" + user_name + "')";
|
|
var exist = mySql.ExecuteFirstInt(sql);
|
|
if (exist > 0)
|
|
{
|
|
mySql.Close();
|
|
return "{\"code\":500,\"msg\":\"用户名已存在\"}";
|
|
}
|
|
|
|
sql = "insert into bxx.user (nick_name,user_name,mobile,password,card_id,group_id,company_name,notes,parent_user_name,authority,forbidden_page,add_time,mdy_time) " +
|
|
"values ('" + nick_name + "','" + user_name + "','" + mobile + "','" + password + "','" + card_id + "','" +
|
|
group_id + "','" + company_name + "','" + notes + "','" + parent_user_name + "','" + authority + "','" + forbidden_page + "','" +
|
|
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 (!WXUserService.GetSign(inputData))
|
|
return "{\"code\":999,\"msg\":\"校验失败\"}";
|
|
|
|
var r2 = RegexUtils.GetStringQuery(ref inputData, "r2").ParseToInt();
|
|
var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
|
|
var password = RegexUtils.GetStringQuery(ref inputData, "password");
|
|
var group = RegexUtils.GetStringQuery(ref inputData, "group");
|
|
|
|
string conn = "ConnKJD";
|
|
MysqlUtils mySql = new MysqlUtils(conn);
|
|
string sql = "select * from bxx.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() : "",
|
|
forbidden_page = row.Table.Columns.Contains("forbidden_page") ? row["forbidden_page"].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 (!WXUserService.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("'", "\\'");
|
|
var forbidden_page = RegexUtils.GetStringQuery(ref inputData, "forbidden_page")?.Replace("'", "\\'");
|
|
|
|
string conn = "ConnKJD";
|
|
MysqlUtils mySql = new MysqlUtils(conn);
|
|
string sql = "";
|
|
//sql = "select * from bxx.user where parent_user_name='"
|
|
// + user_name + "'";
|
|
sql = "update bxx.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 + "',";
|
|
if (forbidden_page != null)
|
|
sql += " forbidden_page='" + forbidden_page + "',";
|
|
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 (!WXUserService.GetSign(inputData))
|
|
return "{\"code\":999,\"msg\":\"校验失败\"}";
|
|
|
|
var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
|
|
var id = RegexUtils.GetStringQuery(ref inputData, "id");
|
|
if (string.IsNullOrWhiteSpace(id))
|
|
return "{\"code\":500,\"msg\":\"id不能为空\"}";
|
|
|
|
string conn = "ConnKJD";
|
|
MysqlUtils mySql = new MysqlUtils(conn);
|
|
string sql = "delete from bxx.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 (!WXUserService.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("'", "\\'");
|
|
var r2 = RegexUtils.GetStringQuery(ref inputData, "r2").ParseToInt();
|
|
|
|
string conn = "ConnKJD";
|
|
MysqlUtils mySql = new MysqlUtils(conn);
|
|
//string sql = "select * from bxx.user where group_id=3";
|
|
string sql = "select * from bxx.user where 1=1";
|
|
if (!string.IsNullOrEmpty(group_id))
|
|
sql += " and group_id=" + group_id;
|
|
if (!string.IsNullOrEmpty(sa_level))
|
|
sql += " and sa_level=" + sa_level;
|
|
if (!string.IsNullOrEmpty(search))
|
|
sql += " and (user_name like '%" + search +
|
|
"%' or nick_name like '%" + search +
|
|
"%' or company_name like '%" + search + "%')";
|
|
sql += " order by 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() : "",
|
|
forbidden_page = row.Table.Columns.Contains("forbidden_page") ? row["forbidden_page"].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 AddUser(string inputData)
|
|
{
|
|
if (!string.IsNullOrEmpty(inputData))
|
|
{
|
|
if (!WXUserService.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("'", "\\'");
|
|
var forbidden_page = RegexUtils.GetStringQuery(ref inputData, "forbidden_page")?.Replace("'", "\\'");
|
|
|
|
string conn = "ConnKJD";
|
|
MysqlUtils mySql = new MysqlUtils(conn);
|
|
string sql = "";
|
|
sql = "select exists (select 1 from bxx.user where user_name='" + user_name + "')";
|
|
var exist = mySql.ExecuteFirstInt(sql);
|
|
if (exist > 0)
|
|
{
|
|
mySql.Close();
|
|
return "{\"code\":500,\"msg\":\"用户名已存在\"}";
|
|
}
|
|
|
|
sql = "insert into bxx.user (nick_name,user_name,mobile,password,card_id,group_id,company_name,notes,sa_level,authority,add_time,mdy_time,forbidden_page) " +
|
|
"values ('" + nick_name + "','" + user_name + "','" + mobile + "','" + password + "','" + card_id + "','" +
|
|
group_id + "','" + company_name + "','" + notes + "'," + sa_level + ",'" + authority + "','" + forbidden_page + "','" +
|
|
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 (!WXUserService.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("'", "\\'");
|
|
var forbidden_page = RegexUtils.GetStringQuery(ref inputData, "forbidden_page")?.Replace("'", "\\'");
|
|
|
|
string conn = "ConnKJD";
|
|
MysqlUtils mySql = new MysqlUtils(conn);
|
|
string sql = "";
|
|
//sql = "select * from bxx.user where parent_user_name='"
|
|
// + user_name + "'";
|
|
sql = "update bxx.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 + "',";
|
|
if (forbidden_page != null)
|
|
sql += " forbidden_page='" + forbidden_page + "',";
|
|
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 ChangePassword(string inputData)
|
|
{
|
|
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("'", "\\'");
|
|
|
|
string conn = "Conn";
|
|
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 return_package_secret_key { get; set; } = "aaMETt2bPe6YHzZ1ojbC+6wOvgtwehqc6A+/Rz+pCUU=";
|
|
|
|
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 = "ConnKJD";
|
|
MysqlUtils mySql = new MysqlUtils(conn);
|
|
string sql = "select * from bxx.user where user_name='"
|
|
+ mobile + "' and password='" + password + "'";
|
|
|
|
sql = "select * from bxx.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\":\"输入为空\"}";
|
|
}
|
|
|
|
public string UpdateScm121Cookie(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 = "ConnKJD";
|
|
MysqlUtils mySql = new MysqlUtils(conn);
|
|
string sql = "update bxx.scm121_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 GetScm121Cookie(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 = "ConnKJD";
|
|
MysqlUtils mySql = new MysqlUtils(conn);
|
|
string sql = "select cookie from bxx.scm121_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\":\"输入为空\"}";
|
|
}
|
|
|
|
public string AddBuyer(string inputData)
|
|
{
|
|
if (!string.IsNullOrEmpty(inputData))
|
|
{
|
|
string user_name = RegexUtils.GetStringQuery(ref inputData, "user_name")?.Replace("'", "\\'");
|
|
string buyer_id = RegexUtils.GetStringQuery(ref inputData, "buyer_id")?.Replace("'", "\\'");
|
|
string buyer_name = RegexUtils.GetStringQuery(ref inputData, "buyer_name")?.Replace("'", "\\'");
|
|
string buyer_nick = RegexUtils.GetStringQuery(ref inputData, "buyer_nick")?.Replace("'", "\\'");
|
|
string cookie = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "cookie"))?.Replace("'", "\\'");
|
|
string notes = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "notes"))?.Replace("'", "\\'");
|
|
|
|
int r2 = 0;
|
|
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
|
|
|
|
if (string.IsNullOrEmpty(user_name))
|
|
{
|
|
return "{\"code\":500,\"msg\":\"没有用户名\"}";
|
|
}
|
|
if (string.IsNullOrEmpty(buyer_name))
|
|
{
|
|
return "{\"code\":501,\"msg\":\"没有买手登录名\"}";
|
|
}
|
|
|
|
string conn = "ConnKJD";
|
|
MysqlUtils mySql = new MysqlUtils(conn);
|
|
string sql = "select exists (select 1 from bxx.shop where buyer_id='" + buyer_id + "' and user_name='" + user_name + "')";
|
|
var exist = mySql.ExecuteFirstInt(sql);
|
|
if (exist > 0)
|
|
{
|
|
mySql.Close();
|
|
return "{\"code\":500,\"msg\":\"买手" + buyer_name + " " + buyer_nick + "已存在\"}";
|
|
}
|
|
|
|
sql = "insert into bxx.buyer (user_name,buyer_id,buyer_name,buyer_nick,cookie,notes) " +
|
|
"values ('" + user_name + "','" + buyer_id + "','" + buyer_name + "','" + buyer_nick + "','" + cookie + "','" + notes + "');";
|
|
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 MdyBuyer(string inputData)
|
|
{
|
|
if (!string.IsNullOrEmpty(inputData))
|
|
{
|
|
string user_name = RegexUtils.GetStringQuery(ref inputData, "user_name")?.Replace("'", "\\'");
|
|
string buyer_id = RegexUtils.GetStringQuery(ref inputData, "buyer_id")?.Replace("'", "\\'");
|
|
string buyer_name = RegexUtils.GetStringQuery(ref inputData, "buyer_name")?.Replace("'", "\\'"); ;
|
|
string buyer_nick = RegexUtils.GetStringQuery(ref inputData, "buyer_nick")?.Replace("'", "\\'"); ;
|
|
string cookie = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "cookie"))?.Replace("'", "\\'"); ;
|
|
string notes = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "notes"))?.Replace("'", "\\'");
|
|
string status = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "status"))?.Replace("'", "\\'");
|
|
|
|
int r2 = 0;
|
|
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
|
|
|
|
if (string.IsNullOrEmpty(user_name))
|
|
{
|
|
return "{\"code\":500,\"msg\":\"没有用户名\"}";
|
|
}
|
|
if (string.IsNullOrEmpty(buyer_id))
|
|
{
|
|
return "{\"code\":501,\"msg\":\"没有买手号\"}";
|
|
}
|
|
|
|
string conn = "ConnKJD";
|
|
MysqlUtils mySql = new MysqlUtils(conn);
|
|
string sql = "update bxx.buyer set";
|
|
if (buyer_name != null)
|
|
sql += " buyer_name='" + buyer_name + "',";
|
|
if (buyer_nick != null)
|
|
sql += " buyer_nick='" + buyer_nick + "',";
|
|
if (cookie != null)
|
|
sql += " cookie='" + cookie + "',";
|
|
if (notes != null)
|
|
sql += " notes='" + notes + "',";
|
|
if (status != null)
|
|
sql += " status='" + status + "',";
|
|
sql = sql.TrimEnd(',');
|
|
|
|
sql += " where buyer_id='" + buyer_id + "' and user_name='" + user_name + "'";
|
|
|
|
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 MdyBuyerCookie(string inputData)
|
|
{
|
|
if (!string.IsNullOrEmpty(inputData))
|
|
{
|
|
string user_name = RegexUtils.GetStringQuery(ref inputData, "buyer_user_name")?.Replace("'", "\\'");
|
|
string buyer_id = RegexUtils.GetStringQuery(ref inputData, "buyer_id")?.Replace("'", "\\'");
|
|
string cookie = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "cookie"))?.Replace("'", "\\'");
|
|
string status = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "status"))?.Replace("'", "\\'");
|
|
|
|
int r2 = 0;
|
|
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
|
|
|
|
if (string.IsNullOrEmpty(buyer_id))
|
|
{
|
|
return "{\"code\":501,\"msg\":\"没有买手号\"}";
|
|
}
|
|
|
|
string conn = "ConnKJD";
|
|
MysqlUtils mySql = new MysqlUtils(conn);
|
|
string sql = "update bxx.buyer set";
|
|
if (cookie != null)
|
|
sql += " cookie='" + cookie + "',";
|
|
if (status != null)
|
|
sql += " status='" + status + "',";
|
|
sql = sql.TrimEnd(',');
|
|
|
|
sql += " where buyer_id='" + buyer_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 GetBuyer(string inputData)
|
|
{
|
|
if (!string.IsNullOrEmpty(inputData))
|
|
{
|
|
var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
|
|
var password = RegexUtils.GetStringQuery(ref inputData, "password");
|
|
if (string.IsNullOrEmpty(user_name))
|
|
{
|
|
return "{\"code\":500,\"msg\":\"没有用户名\"}";
|
|
}
|
|
|
|
var search_notes = RegexUtils.GetStringQuery(ref inputData, "search_notes");
|
|
var search_buyer_id = RegexUtils.GetStringQuery(ref inputData, "search_buyer_id");
|
|
var search_buyer_name = RegexUtils.GetStringQuery(ref inputData, "search_buyer_name");
|
|
var search_buyer_nick = RegexUtils.GetStringQuery(ref inputData, "search_buyer_nick");
|
|
|
|
var buyer_ids = RegexUtils.GetStringQuery(ref inputData, "buyer_ids")?.Replace("'", "");
|
|
if (!string.IsNullOrWhiteSpace(buyer_ids))
|
|
{
|
|
List<string> shopIdLst = buyer_ids.Split(',').ToList();
|
|
buyer_ids = "'" + string.Join("','", shopIdLst) + "'";
|
|
}
|
|
var buyer_names = RegexUtils.GetStringQuery(ref inputData, "buyer_names");
|
|
if (!string.IsNullOrWhiteSpace(buyer_names))
|
|
{
|
|
List<string> shopNameLst = buyer_names.Split(',').ToList();
|
|
buyer_names = "'" + string.Join("','", shopNameLst) + "'";
|
|
}
|
|
var buyer_nicks = RegexUtils.GetStringQuery(ref inputData, "buyer_nicks");
|
|
if (!string.IsNullOrWhiteSpace(buyer_nicks))
|
|
{
|
|
List<string> shopNotesLst = buyer_nicks.Split(',').ToList();
|
|
buyer_nicks = "'" + string.Join("','", shopNotesLst) + "'";
|
|
}
|
|
|
|
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 = "ConnKJD";
|
|
MysqlUtils mySql = new MysqlUtils(conn);
|
|
|
|
string sql = "SELECT COUNT(s.id) FROM bxx.buyer s WHERE 1=1";
|
|
|
|
//where子句
|
|
string where = "";
|
|
if (!string.IsNullOrWhiteSpace(search_notes))
|
|
where += " and s.notes like '%" + search_notes + "%'";
|
|
if (!string.IsNullOrWhiteSpace(search_buyer_id))
|
|
where += " and s.buyer_id like '%" + search_buyer_id + "%'";
|
|
if (!string.IsNullOrWhiteSpace(search_buyer_name))
|
|
where += " and s.buyer_name like '%" + search_buyer_name + "%'";
|
|
if (!string.IsNullOrWhiteSpace(search_buyer_nick))
|
|
where += " and s.buyer_nick like '%" + search_buyer_nick + "%'";
|
|
|
|
if (!string.IsNullOrWhiteSpace(buyer_ids))
|
|
where += " and s.buyer_id in (" + buyer_ids + ")";
|
|
if (!string.IsNullOrWhiteSpace(buyer_names))
|
|
where += " and s.buyer_name in (" + buyer_names + ")";
|
|
if (!string.IsNullOrWhiteSpace(buyer_nicks))
|
|
where += " and s.buyer_nick in (" + buyer_nicks + ")";
|
|
|
|
if (!string.IsNullOrWhiteSpace(user_name))
|
|
where += " and s.user_name='" + user_name + "'";
|
|
sql += where;
|
|
|
|
var count = mySql.ExecuteRowCount(sql);
|
|
|
|
DataTable dt;
|
|
if (count == 0)
|
|
{
|
|
dt = new DataTable();
|
|
}
|
|
else
|
|
{
|
|
sql = "SELECT s.*";
|
|
sql += " FROM bxx.buyer s WHERE 1=1";
|
|
|
|
sql += where; // where 子句
|
|
|
|
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<BuyerLoginInfo> buyerList = new List<BuyerLoginInfo>();
|
|
foreach (DataRow row in dt.Rows)
|
|
{
|
|
BuyerLoginInfo shop = new BuyerLoginInfo
|
|
{
|
|
id = Convert.ToInt32(row["id"]),
|
|
cookie = row["cookie"].ToString(),
|
|
user_name = row["user_name"].ToString(),
|
|
notes = row["notes"].ToString(),
|
|
add_time = row["add_time"].ParseToString().ParseToDateTime(),
|
|
mdy_time = row["mdy_time"].ParseToString().ParseToDateTime(),
|
|
buyer_id = row["buyer_id"].ToString(),
|
|
buyer_name = row["buyer_name"].ToString(),
|
|
buyer_nick = row["buyer_nick"].ToString(),
|
|
status = row["status"].ToString(),
|
|
};
|
|
buyerList.Add(shop);
|
|
}
|
|
var data = JsonUtils.SerializeObjectToString(buyerList);
|
|
return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"count\":" + count + "}";
|
|
}
|
|
}
|
|
return "{\"code\":19999,\"msg\":\"未知错误\"}";
|
|
}
|
|
|
|
public string DelBuyer(string inputData)
|
|
{
|
|
if (!string.IsNullOrEmpty(inputData))
|
|
{
|
|
var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
|
|
var password = RegexUtils.GetStringQuery(ref inputData, "password");
|
|
if (string.IsNullOrEmpty(user_name))
|
|
{
|
|
return "{\"code\":500,\"msg\":\"没有用户名\"}";
|
|
}
|
|
|
|
var buyer_id = RegexUtils.GetStringQuery(ref inputData, "buyer_id");
|
|
if (string.IsNullOrEmpty(buyer_id))
|
|
{
|
|
return "{\"code\":500,\"msg\":\"没有买手号\"}";
|
|
}
|
|
|
|
string conn = "ConnKJD";
|
|
MysqlUtils mySql = new MysqlUtils(conn);
|
|
|
|
string sql = "DELETE FROM bxx.buyer WHERE user_name='" + user_name + "' and buyer_id='" + buyer_id + "'";
|
|
|
|
|
|
var rst = mySql.ExecuteNonQuery(sql);
|
|
mySql.Close();
|
|
|
|
if (rst)
|
|
{
|
|
return "{\"code\":200,\"msg\":\"success\"}";
|
|
}
|
|
else
|
|
{
|
|
return "{\"code\":501,\"msg\":" + mySql.Message + "}";
|
|
}
|
|
}
|
|
return "{\"code\":19999,\"msg\":\"未知错误\"}";
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|