1452 lines
74 KiB
C#
1452 lines
74 KiB
C#
using StoreHub.KJDWebService.Models;
|
|
using StoreHub.Framework.Repositorys;
|
|
using Microsoft.Extensions.Configuration;
|
|
using StoreHub.KJDWebService.Models.ShopModel;
|
|
using StoreHub.KJDWebService.Commons;
|
|
using MySql.Data.MySqlClient;
|
|
using NaiBa.Util.Extension;
|
|
using Newtonsoft.Json.Linq;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
|
|
namespace StoreHub.KJDWebService.Services
|
|
{
|
|
public class BXXShopService : ServiceBase
|
|
{
|
|
public BXXShopService(SqlRepository sqlRepository, IConfiguration configuration) : base(sqlRepository, configuration)
|
|
{
|
|
}
|
|
public string GetPddClientInfo(string inputData)
|
|
{
|
|
if (!string.IsNullOrEmpty(inputData))
|
|
{
|
|
var time = 0;
|
|
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "time"), out time);
|
|
string time1 = RegexUtils.GetStringQuery(ref inputData, "code");
|
|
if (time1 != EncrypUtil.Encryption(time))
|
|
return "{\"code\":50000,\"msg\":\"校验失败\"}";
|
|
|
|
var mobile = RegexUtils.GetStringQuery(ref inputData, "mobile")?.Replace("'", "\\'");
|
|
var password = RegexUtils.GetStringQuery(ref inputData, "password")?.Replace("'", "\\'");
|
|
int r2 = 0;
|
|
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
|
|
|
|
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);
|
|
mySql.Close();
|
|
if (dt == null)
|
|
{
|
|
return "{\"code\":500,\"msg\":\"用户不存在\"}";
|
|
}
|
|
|
|
JArray jArr = new JArray();
|
|
|
|
JObject obj1 = new JObject();
|
|
obj1["describe"] = "貔貅管家";
|
|
obj1["client_id"] = "ad502ec19e0c49ab9df14f83494e153c";
|
|
obj1["client_secret"] = "bd52aba51737d03fc073711d386b3b0779d010ad";
|
|
obj1["market_id"] = 84862;
|
|
//https://fuwu.pinduoduo.com/service-market/auth?response_type=code&client_id=ad502ec19e0c49ab9df14f83494e153c&redirect_uri=http%3A%2F%2Fpo.e57.cn%2Flogin%3Fsource%3Dpdd_code_pixiu
|
|
//obj1["redirect_uri"] = "http%3A%2F%2Fpo.e57.cn%2Flogin%3Fsource%3Dpdd_code";
|
|
obj1["redirect_uri"] = "http%3A%2F%2Fpo.e57.cn%2Flogin%3Fsource%3Dpdd_code_pixiu";
|
|
obj1["is_current"] = false;
|
|
//jArr.Add(obj1);
|
|
|
|
JObject obj2 = new JObject();
|
|
obj2["describe"] = "小红椒商品管理";
|
|
obj2["client_id"] = "48e76c60853d47d8a4e2e631b6db26b5";
|
|
obj2["client_secret"] = "b2a5f9eeb36d192ed035f023eaf9ce5280aac397";
|
|
obj2["market_id"] = 84690;
|
|
obj2["redirect_uri"] = "http%3A%2F%2Fxtjpd.jiaotian.vip%2Fpdd_token.html";
|
|
obj2["is_current"] = true;
|
|
jArr.Add(obj2);
|
|
|
|
return "{\"code\":200,\"msg\":\"success\",\"data\":" + JsonUtils.SerializeObject(jArr) + "}";
|
|
}
|
|
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
|
}
|
|
|
|
public string GetShopClientInfo(string inputData, bool isAdmin = false)
|
|
{
|
|
if (!string.IsNullOrEmpty(inputData))
|
|
{
|
|
var time = 0;
|
|
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "time"), out time);
|
|
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");
|
|
if (string.IsNullOrEmpty(user_name))
|
|
{
|
|
return "{\"code\":50001,\"msg\":\"没有用户名\"}";
|
|
}
|
|
|
|
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 page = RegexUtils.GetStringQuery(ref inputData, "page").ParseToInt();
|
|
var page_size = RegexUtils.GetStringQuery(ref inputData, "page_size").ParseToInt();
|
|
|
|
if (page_size == 0)
|
|
page_size = 500;
|
|
|
|
|
|
string conn = "ConnKJD";
|
|
MysqlUtils mySql = new MysqlUtils(conn);
|
|
|
|
string sql = "SELECT COUNT(s.id) FROM bxx.shop_api_auth s WHERE 1=1";
|
|
|
|
//where子句
|
|
string where = "";
|
|
if (!string.IsNullOrWhiteSpace(shop_ids))
|
|
where += " and s.ShopId in (" + shop_ids + ")";
|
|
sql += where;
|
|
|
|
var count = mySql.ExecuteRowCount(sql);
|
|
|
|
DataTable dt;
|
|
if (count == 0)
|
|
{
|
|
dt = new DataTable();
|
|
}
|
|
else
|
|
{
|
|
sql = "SELECT * FROM bxx.shop_api_auth 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 (!string.IsNullOrEmpty(mySql.Message))
|
|
{
|
|
return "{\"code\":50001,\"msg\":\"查询失败:" + mySql.Message + "\"}";
|
|
}
|
|
|
|
if (dt != null)
|
|
{
|
|
List<AuthInfo> shopAuthList = new List<AuthInfo>();
|
|
foreach (DataRow row in dt.Rows)
|
|
{
|
|
AuthInfo auth = new AuthInfo
|
|
{
|
|
id = Convert.ToInt32(row["id"]),
|
|
AccessToken = row["AccessToken"].ToString(),
|
|
ApiAuthStatus = row["ApiAuthStatus"].ToString(),
|
|
AppKey = row["AppKey"].ToString(),
|
|
AppSecret = row["AppSecret"].ToString(),
|
|
ExpiresTime = row["ExpiresTime"].ParseToString().ParseToDateTime(),
|
|
RefreshToken = row["RefreshToken"].ToString(),
|
|
ShopId = row["ShopId"].ToString(),
|
|
UpdateTime = row["UpdateTime"].ParseToString().ParseToDateTime(),
|
|
};
|
|
shopAuthList.Add(auth);
|
|
}
|
|
var data = JsonUtils.SerializeObjectToString(shopAuthList);
|
|
return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"count\":" + count + "}";
|
|
}
|
|
}
|
|
return "{\"code\":19999,\"msg\":\"未知错误\"}";
|
|
}
|
|
|
|
public string AddMdyShopClientInfo(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\":\"没有用户名\"}";
|
|
}
|
|
|
|
string ShopId = RegexUtils.GetStringQuery(ref inputData, "ShopId")?.Replace("'", "\\'");
|
|
string AppKey = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "AppKey"))?.Replace("'", "\\'");
|
|
string AccessToken = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "AccessToken"))?.Replace("'", "\\'");
|
|
string RefreshToken = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "RefreshToken"))?.Replace("'", "\\'");
|
|
string AppSecret = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "AppSecret"))?.Replace("'", "\\'");
|
|
string ExpiresTime = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "ExpiresTime"))?.Replace("'", "\\'");
|
|
string ApiAuthStatus = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "ApiAuthStatus"))?.Replace("'", "\\'");
|
|
if (string.IsNullOrEmpty("ShopId"))
|
|
return "{\"code\":50001,\"msg\":\"没有店铺编号\"}";
|
|
if (string.IsNullOrEmpty("AppKey"))
|
|
return "{\"code\":50001,\"msg\":\"没有Api编号\"}";
|
|
if (string.IsNullOrEmpty("AccessToken"))
|
|
return "{\"code\":50001,\"msg\":\"没有令牌信息\"}";
|
|
|
|
string conn = "ConnKJD";
|
|
MysqlUtils mySql = new MysqlUtils(conn);
|
|
|
|
string sql = "SELECT ShopId,AppKey FROM `bxx`.`shop_api_auth` where ShopId='" + ShopId + "' and AppKey='" + AppKey + "'";
|
|
|
|
string where = "";
|
|
sql += where;
|
|
|
|
var dt = mySql.ExecuteDataTable(sql);
|
|
mySql.Close();
|
|
|
|
if (dt != null)
|
|
{
|
|
conn = Config("ConnKJD");
|
|
mySql = new MysqlUtils(conn);
|
|
if (dt.Rows.Count == 0)
|
|
{
|
|
sql = "INSERT INTO `bxx`.`shop_api_auth` (ShopId,AppKey,AccessToken,RefreshToken,AppSecret,ExpiresTime,ApiAuthStatus)" +
|
|
" VALUES (@ShopId,@AppKey,@AccessToken,@RefreshToken,@AppSecret,@ExpiresTime,@ApiAuthStatus);";
|
|
}
|
|
else
|
|
{
|
|
sql = "UPDATE `bxx`.`shop_api_auth` SET AccessToken=@AccessToken";
|
|
if (RefreshToken != null)
|
|
sql += ", RefreshToken=@RefreshToken ";
|
|
if (AppSecret != null)
|
|
sql += ", AppSecret=@AppSecret ";
|
|
if (ExpiresTime != null)
|
|
sql += ", ExpiresTime=@ExpiresTime ";
|
|
if (ApiAuthStatus != null)
|
|
sql += ", ApiAuthStatus=@ApiAuthStatus ";
|
|
sql += " WHERE ShopId=@ShopId and AppKey=@AppKey;";
|
|
}
|
|
|
|
List<MySqlParameter> paramLst = new List<MySqlParameter>();
|
|
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "ShopId", Value = ShopId, });
|
|
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "AppKey", Value = AppKey, });
|
|
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "AccessToken", Value = AccessToken.ParseToString(), });
|
|
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "RefreshToken", Value = RefreshToken.ParseToString(), });
|
|
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "AppSecret", Value = AppSecret.ParseToString(), });
|
|
paramLst.Add(new MySqlParameter() { DbType = DbType.DateTime, ParameterName = "ExpiresTime", Value = ExpiresTime.ParseToDateTime(), });
|
|
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "ApiAuthStatus", Value = ApiAuthStatus, });
|
|
|
|
mySql.ExecuteNonQuery(sql, paramLst.ToArray());
|
|
mySql.Close();
|
|
if (string.IsNullOrEmpty(mySql.Message))
|
|
{
|
|
return "{\"code\":200,\"msg\":\"success\",\"data\":\"\"}";
|
|
}
|
|
else
|
|
{
|
|
return "{\"code\":50003,\"msg\":\"" + mySql.Message + "\",\"data\":\"\"}";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return "{\"code\":50003,\"msg\":\"" + mySql.Message + "\",\"data\":\"\"}";
|
|
}
|
|
}
|
|
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
|
}
|
|
|
|
public string GetShop(string inputData, bool isAdmin = false)
|
|
{
|
|
if (!string.IsNullOrEmpty(inputData))
|
|
{
|
|
var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
|
|
var password = RegexUtils.GetStringQuery(ref inputData, "password");
|
|
var search_id = RegexUtils.GetStringQuery(ref inputData, "search_id");
|
|
var search_user_name = RegexUtils.GetStringQuery(ref inputData, "search_user_name");
|
|
var search_login_name = RegexUtils.GetStringQuery(ref inputData, "search_login_name");
|
|
var search_notes = RegexUtils.GetStringQuery(ref inputData, "search_notes");
|
|
var search_name = RegexUtils.GetStringQuery(ref inputData, "search_name");
|
|
var operate_sub_sa_name = RegexUtils.GetStringQuery(ref inputData, "operate_sub_sa_name")?.Replace("'", "\\'");
|
|
|
|
// 特殊处理一下修复客户端店铺导入没有立即登录导致的cookie串的bug
|
|
//var shop_ids = RegexUtils.GetStringQuery(ref inputData, "shop_ids")?.Replace("'", "");
|
|
var shop_ids = RegexUtils.GetStringQuery(ref inputData, "shop_ids");
|
|
if (shop_ids == "''")
|
|
shop_ids = "999999999999999";
|
|
shop_ids = 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 shop_notes = RegexUtils.GetStringQuery(ref inputData, "shop_notes");
|
|
if (!string.IsNullOrWhiteSpace(shop_notes))
|
|
{
|
|
List<string> shopNotesLst = shop_notes.Split(',').ToList();
|
|
shop_notes = "'" + 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.shop s WHERE 1=1";
|
|
|
|
//where子句
|
|
string where = "";
|
|
if (isAdmin)
|
|
where += " and (s.cookie='' or s.shop_id!='')";
|
|
if (!isAdmin)
|
|
where += " and (s.user_name='" + user_name + "' or s.sub_user_name like '%" + user_name + "%')";
|
|
if (!string.IsNullOrWhiteSpace(operate_sub_sa_name))
|
|
where += " and s.operate_sub_sa_name='" + operate_sub_sa_name + "'";
|
|
if (!string.IsNullOrWhiteSpace(search_user_name))
|
|
where += " and s.user_name like '%" + search_user_name + "%'";
|
|
if (!string.IsNullOrWhiteSpace(search_login_name))
|
|
where += " and s.login_name like '%" + search_login_name + "%'";
|
|
if (!string.IsNullOrWhiteSpace(search_notes))
|
|
where += " and s.notes like '%" + search_notes + "%'";
|
|
if (!string.IsNullOrWhiteSpace(search_id))
|
|
where += " and s.shop_id like '%" + search_id + "%'";
|
|
if (!string.IsNullOrWhiteSpace(search_name))
|
|
where += " and s.shop_account like '%" + search_name + "%'";
|
|
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(shop_notes))
|
|
where += " and s.notes in (" + shop_notes + ")";
|
|
sql += where;
|
|
|
|
var count = mySql.ExecuteRowCount(sql);
|
|
|
|
DataTable dt;
|
|
if (count == 0)
|
|
{
|
|
dt = new DataTable();
|
|
}
|
|
else
|
|
{
|
|
sql = "SELECT s.id,s.login_name,s.login_pass,s.cookie,s.cookie2,s.anti_contents,s.pddid,s.mall_id,s.shop_id,s.shop_account,s.sub_user_name," +
|
|
"s.user_name,s.company_name,s.notes,s.login_status,s.login_status2,c.add_product_remaining,c.add_product_month," +
|
|
"s.add_time,s.mdy_time,s.add_sub_sa_time,s.operate_sub_sa_name";
|
|
//sql += " FROM bxx.shop s WHERE 1=1";
|
|
sql += " FROM bxx.shop s LEFT JOIN bxx.shop_add_prod_count c ON s.shop_id=c.shop_id 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<ShopParam> shopList=new List<ShopParam>();
|
|
foreach (DataRow row in dt.Rows)
|
|
{
|
|
ShopParam shop = new ShopParam
|
|
{
|
|
id = Convert.ToInt32(row["id"]),
|
|
login_name = row["login_name"].ToString(),
|
|
login_pass = row["login_pass"].ToString(),
|
|
cookie = row["cookie"].ToString(),
|
|
cookie2 = row["cookie2"].ToString(),
|
|
anti_contents = row["anti_contents"].ToString(),
|
|
shop_id = row["shop_id"].ToString(),
|
|
shop_account = row["shop_account"].ToString(),
|
|
sub_user_name = row["sub_user_name"].ToString(),
|
|
user_name = row["user_name"].ToString(),
|
|
company_name = row["company_name"].ToString(),
|
|
notes = row["notes"].ToString(),
|
|
login_status = row["login_status"].ToString(),
|
|
login_status2 = row["login_status2"].ToString(),
|
|
add_product_remaining = row["add_product_remaining"].ParseToInt(),
|
|
add_product_month = row["add_product_month"].ParseToInt(),
|
|
operate_sub_sa_name = row["operate_sub_sa_name"].ParseToString(),
|
|
pddid = row["pddid"].ParseToString(),
|
|
mall_id = row["mall_id"].ParseToString(),
|
|
};
|
|
shopList.Add(shop);
|
|
}
|
|
|
|
//sql = "\r\nINSERT INTO bxx.shop_add_prod_count(shop_id,shop_account,add_product_remaining,add_product_month) VALUES ";
|
|
//foreach (var shop in shopList)
|
|
//{
|
|
// sql += "\r\n('" + shop.shop_id + "','" + shop.shop_account + "'," + shop.add_product_remaining + "," + shop.add_product_month + "),";
|
|
//}
|
|
//sql = sql.TrimEnd(',') + " \r\n";
|
|
//sql += "ON DUPLICATE KEY UPDATE " +
|
|
// "shop_account=VALUES(shop_account)," +
|
|
// "add_product_remaining=VALUES(add_product_remaining)," +
|
|
// "add_product_month=VALUES(add_product_month);";
|
|
//var result = mySql.ExecuteNonQuery(sql);
|
|
//mySql.Close();
|
|
|
|
int month = DateTime.Now.Month;
|
|
var shopMonthList = shopList.Where(s => s.add_product_month != month);
|
|
if (shopMonthList.Count() > 0)
|
|
{
|
|
int remainCount = 300;
|
|
var shopMonthIdList = shopMonthList.Select(s => s.id);
|
|
mySql = new MysqlUtils(conn);
|
|
string ids = string.Join(",", shopMonthIdList);
|
|
sql = "";
|
|
sql += "update bxx.shop set add_product_remaining=" + remainCount + ", add_product_month=" + month +
|
|
" where 1=1 and id in (" + ids + ");";
|
|
|
|
sql += "\r\nINSERT INTO bxx.shop_add_prod_count(shop_id,shop_account,add_product_remaining,add_product_month) VALUES ";
|
|
foreach (var shop in shopMonthList)
|
|
{
|
|
sql+= "\r\n('" + shop.shop_id + "','" + shop.shop_account + "'," + remainCount + "," + month + "),";
|
|
}
|
|
sql = sql.TrimEnd(',') + " \r\n";
|
|
sql += "ON DUPLICATE KEY UPDATE " +
|
|
"shop_account=VALUES(shop_account)," +
|
|
"add_product_remaining=VALUES(add_product_remaining)," +
|
|
"add_product_month=VALUES(add_product_month);";
|
|
var rst = mySql.ExecuteNonQuery(sql);
|
|
mySql.Close();
|
|
|
|
if (rst)
|
|
{
|
|
foreach (var shop in shopMonthList)
|
|
{
|
|
shop.add_product_month = month;
|
|
shop.add_product_remaining = remainCount;
|
|
}
|
|
}
|
|
}
|
|
var data = JsonUtils.SerializeObjectToString(shopList);
|
|
|
|
|
|
//return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"c\":\"" + EncrypUtil.Encryption(r2) + "\"}";
|
|
return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"count\":" + count + "}";
|
|
}
|
|
}
|
|
return "{\"code\":19999,\"msg\":\"未知错误\"}";
|
|
}
|
|
|
|
public string SubSaGetSelectProdShop(string inputData)
|
|
{
|
|
if (!string.IsNullOrEmpty(inputData))
|
|
{
|
|
var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
|
|
var password = RegexUtils.GetStringQuery(ref inputData, "password");
|
|
var search_id = RegexUtils.GetStringQuery(ref inputData, "search_id");
|
|
var search_user_name = RegexUtils.GetStringQuery(ref inputData, "search_user_name");
|
|
var search_login_name = RegexUtils.GetStringQuery(ref inputData, "search_login_name");
|
|
var search_notes = RegexUtils.GetStringQuery(ref inputData, "search_notes");
|
|
var search_name = RegexUtils.GetStringQuery(ref inputData, "search_name");
|
|
var operate_sub_sa_name = RegexUtils.GetStringQuery(ref inputData, "operate_sub_sa_name")?.Replace("'", "\\'");
|
|
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 shop_notes = RegexUtils.GetStringQuery(ref inputData, "shop_notes");
|
|
if (!string.IsNullOrWhiteSpace(shop_notes))
|
|
{
|
|
List<string> shopNotesLst = shop_notes.Split(',').ToList();
|
|
shop_notes = "'" + 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.shop s WHERE 1=1";
|
|
|
|
//where子句
|
|
string where = "";
|
|
if (!string.IsNullOrWhiteSpace(operate_sub_sa_name))
|
|
where += " and (s.shop_id in (SELECT DISTINCT shop_id From bxx.product_select WHERE operate_sub_sa_name='" + operate_sub_sa_name + "') or " +
|
|
"s.shop_id in (SELECT DISTINCT shop_id From bxx.third_product_select WHERE operate_sub_sa_name='" + operate_sub_sa_name + "'))";
|
|
where += " and (s.cookie='' or s.shop_id!='')";
|
|
//if (!string.IsNullOrWhiteSpace(operate_sub_sa_name))
|
|
// where += " and s.operate_sub_sa_name='" + operate_sub_sa_name + "'";
|
|
if (!string.IsNullOrWhiteSpace(search_user_name))
|
|
where += " and s.user_name like '%" + search_user_name + "%'";
|
|
if (!string.IsNullOrWhiteSpace(search_login_name))
|
|
where += " and s.login_name like '%" + search_login_name + "%'";
|
|
if (!string.IsNullOrWhiteSpace(search_notes))
|
|
where += " and s.notes like '%" + search_notes + "%'";
|
|
if (!string.IsNullOrWhiteSpace(search_id))
|
|
where += " and s.shop_id like '%" + search_id + "%'";
|
|
if (!string.IsNullOrWhiteSpace(search_name))
|
|
where += " and s.shop_account like '%" + search_name + "%'";
|
|
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(shop_notes))
|
|
where += " and s.notes in (" + shop_notes + ")";
|
|
sql += where;
|
|
|
|
var count = mySql.ExecuteRowCount(sql);
|
|
|
|
DataTable dt;
|
|
if (count == 0)
|
|
{
|
|
dt = new DataTable();
|
|
}
|
|
else
|
|
{
|
|
sql = "SELECT s.id,s.login_name,s.login_pass,s.cookie,s.cookie2,s.anti_contents,s.shop_id,s.shop_account,s.sub_user_name,s.user_name," +
|
|
"s.company_name,s.notes,s.login_status,s.login_status2,c.add_product_remaining,c.add_product_month,s.add_time,s.mdy_time," +
|
|
"s.add_sub_sa_time,s.operate_sub_sa_name";
|
|
sql += " FROM bxx.shop s LEFT JOIN bxx.shop_add_prod_count c ON s.shop_id=c.shop_id 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<ShopParam> shopList = new List<ShopParam>();
|
|
foreach (DataRow row in dt.Rows)
|
|
{
|
|
ShopParam shop = new ShopParam
|
|
{
|
|
id = Convert.ToInt32(row["id"]),
|
|
login_name = row["login_name"].ToString(),
|
|
login_pass = row["login_pass"].ToString(),
|
|
cookie = row["cookie"].ToString(),
|
|
cookie2 = row["cookie2"].ToString(),
|
|
anti_contents = row["anti_contents"].ToString(),
|
|
shop_id = row["shop_id"].ToString(),
|
|
shop_account = row["shop_account"].ToString(),
|
|
sub_user_name = row["sub_user_name"].ToString(),
|
|
user_name = row["user_name"].ToString(),
|
|
company_name = row["company_name"].ToString(),
|
|
notes = row["notes"].ToString(),
|
|
login_status = row["login_status"].ToString(),
|
|
login_status2 = row["login_status2"].ToString(),
|
|
add_product_remaining = row["add_product_remaining"].ParseToInt(),
|
|
add_product_month = row["add_product_month"].ParseToInt(),
|
|
operate_sub_sa_name = row["operate_sub_sa_name"].ParseToString(),
|
|
|
|
};
|
|
shopList.Add(shop);
|
|
}
|
|
|
|
//sql = "\r\nINSERT INTO bxx.shop_add_prod_count(shop_id,shop_account,add_product_remaining,add_product_month) VALUES ";
|
|
//foreach (var shop in shopList)
|
|
//{
|
|
// sql += "\r\n('" + shop.shop_id + "','" + shop.shop_account + "'," + shop.add_product_remaining + "," + shop.add_product_month + "),";
|
|
//}
|
|
//sql = sql.TrimEnd(',') + " \r\n";
|
|
//sql += "ON DUPLICATE KEY UPDATE " +
|
|
// "shop_account=VALUES(shop_account)," +
|
|
// "add_product_remaining=VALUES(add_product_remaining)," +
|
|
// "add_product_month=VALUES(add_product_month);";
|
|
//var result = mySql.ExecuteNonQuery(sql);
|
|
//mySql.Close();
|
|
|
|
int month = DateTime.Now.Month;
|
|
var shopMonthList = shopList.Where(s => s.add_product_month != month);
|
|
if (shopMonthList.Count() > 0)
|
|
{
|
|
int remainCount = 300;
|
|
var shopMonthIdList = shopMonthList.Select(s => s.id);
|
|
mySql = new MysqlUtils(conn);
|
|
string ids = string.Join(",", shopMonthIdList);
|
|
sql = "";
|
|
sql += "update bxx.shop set add_product_remaining=" + remainCount + ", add_product_month=" + month +
|
|
" where 1=1 and id in (" + ids + ");";
|
|
|
|
sql += "\r\nINSERT INTO bxx.shop_add_prod_count(shop_id,shop_account,add_product_remaining,add_product_month) VALUES ";
|
|
foreach (var shop in shopMonthList)
|
|
{
|
|
sql += "\r\n('" + shop.shop_id + "','" + shop.shop_account + "'," + remainCount + "," + month + "),";
|
|
}
|
|
sql = sql.TrimEnd(',') + " \r\n";
|
|
sql += "ON DUPLICATE KEY UPDATE " +
|
|
"shop_account=VALUES(shop_account)," +
|
|
"add_product_remaining=VALUES(add_product_remaining)," +
|
|
"add_product_month=VALUES(add_product_month);";
|
|
var rst = mySql.ExecuteNonQuery(sql);
|
|
mySql.Close();
|
|
|
|
if (rst)
|
|
{
|
|
foreach (var shop in shopMonthList)
|
|
{
|
|
shop.add_product_month = month;
|
|
shop.add_product_remaining = remainCount;
|
|
}
|
|
}
|
|
}
|
|
var data = JsonUtils.SerializeObjectToString(shopList);
|
|
|
|
|
|
//return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"c\":\"" + EncrypUtil.Encryption(r2) + "\"}";
|
|
return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"count\":" + count + "}";
|
|
}
|
|
}
|
|
return "{\"code\":19999,\"msg\":\"未知错误\"}";
|
|
}
|
|
|
|
|
|
|
|
public string UpdateAddProdRemaining(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");
|
|
var remainCount = RegexUtils.GetStringQuery(ref inputData, "remain_count");
|
|
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) + "'";
|
|
}
|
|
|
|
string conn = "ConnKJD";
|
|
MysqlUtils mySql = new MysqlUtils(conn);
|
|
string sql = "";
|
|
sql += "update bxx.shop_add_prod_count set add_product_remaining=" + remainCount +
|
|
" where 1=1 and shop_id in (" + shop_ids + ");";
|
|
|
|
var rst = mySql.ExecuteNonQuery(sql);
|
|
var msg = mySql.Message;
|
|
mySql.Close();
|
|
|
|
if (rst)
|
|
return "{\"code\":200,\"msg\":\"success\"}";
|
|
else
|
|
return "{\"code\":50000,\"msg\":\"" + msg + "\"}";
|
|
}
|
|
else
|
|
{
|
|
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
|
}
|
|
}
|
|
|
|
//获取一个手机登录号码下的所有店铺(以便有则更新,无则新增)
|
|
public string GetOneLoginNameShop(string inputData)
|
|
{
|
|
if (!string.IsNullOrEmpty(inputData))
|
|
{
|
|
var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
|
|
var login_name = RegexUtils.GetStringQuery(ref inputData, "login_name");
|
|
var password = RegexUtils.GetStringQuery(ref inputData, "password");
|
|
int r2 = 0;
|
|
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
|
|
|
|
string conn = "ConnKJD";
|
|
MysqlUtils mySql = new MysqlUtils(conn);
|
|
string sql = "select id,login_name,login_pass,cookie,cookie2,anti_contents,shop_id,shop_account,sub_user_name,user_name from bxx.shop where user_name='"
|
|
+ user_name + "' and login_name='" + login_name + "'";
|
|
|
|
var dt = mySql.ExecuteDataTable(sql);
|
|
mySql.Close();
|
|
if (dt != null)
|
|
{
|
|
List<ShopParam> shopList = new List<ShopParam>();
|
|
foreach (DataRow row in dt.Rows)
|
|
{
|
|
ShopParam shop = new ShopParam
|
|
{
|
|
id = Convert.ToInt32(row["id"]),
|
|
login_name = row["login_name"].ToString(),
|
|
login_pass = row["login_pass"].ToString(),
|
|
cookie = row["cookie"].ToString(),
|
|
cookie2 = row["cookie2"].ToString(),
|
|
anti_contents = row["anti_contents"].ToString(),
|
|
shop_id = row["shop_id"].ToString(),
|
|
shop_account = row["shop_account"].ToString(),
|
|
sub_user_name = row["sub_user_name"].ToString(),
|
|
user_name = row["user_name"].ToString(),
|
|
company_name = row["company_name"].ToString(),
|
|
notes = row["notes"].ToString(),
|
|
login_status = row["login_status"].ToString(),
|
|
};
|
|
shopList.Add(shop);
|
|
}
|
|
var data = JsonUtils.SerializeObjectToString(shopList);
|
|
return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"c\":\"" + EncrypUtil.Encryption(r2) + "\"}";
|
|
}
|
|
}
|
|
return "{\"code\":19999,\"msg\":\"未知错误\"}";
|
|
}
|
|
|
|
//获取一个手机登录号码下特定ID的店铺
|
|
public string GetOneIdShop(string inputData)
|
|
{
|
|
if (!string.IsNullOrEmpty(inputData))
|
|
{
|
|
var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
|
|
var login_name = RegexUtils.GetStringQuery(ref inputData, "login_name");
|
|
var shop_id = RegexUtils.GetStringQuery(ref inputData, "shop_id");
|
|
var password = RegexUtils.GetStringQuery(ref inputData, "password");
|
|
int r2 = 0;
|
|
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
|
|
|
|
string conn = "ConnKJD";
|
|
MysqlUtils mySql = new MysqlUtils(conn);
|
|
string sql = "select id,login_name,login_pass,cookie,cookie2,anti_contents,shop_id,shop_account,sub_user_name,user_name from bxx.shop where user_name='"
|
|
+ user_name + "' and login_name='" + login_name + "' and shop_id='" + shop_id + "'";
|
|
|
|
var dt = mySql.ExecuteDataTable(sql);
|
|
mySql.Close();
|
|
if (dt != null)
|
|
{
|
|
List<ShopParam> shopList = new List<ShopParam>();
|
|
foreach (DataRow row in dt.Rows)
|
|
{
|
|
ShopParam shop = new ShopParam
|
|
{
|
|
id = Convert.ToInt32(row["id"]),
|
|
login_name = row["login_name"].ToString(),
|
|
login_pass = row["login_pass"].ToString(),
|
|
cookie = row["cookie"].ToString(),
|
|
cookie2 = row["cookie2"].ToString(),
|
|
anti_contents = row["anti_contents"].ToString(),
|
|
shop_id = row["shop_id"].ToString(),
|
|
shop_account = row["shop_account"].ToString(),
|
|
sub_user_name = row["sub_user_name"].ToString(),
|
|
user_name = row["user_name"].ToString(),
|
|
company_name = row["company_name"].ToString(),
|
|
notes = row["notes"].ToString(),
|
|
login_status = row["login_status"].ToString(),
|
|
};
|
|
shopList.Add(shop);
|
|
}
|
|
var data = JsonUtils.SerializeObjectToString(shopList);
|
|
return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"c\":\"" + EncrypUtil.Encryption(r2) + "\"}";
|
|
}
|
|
}
|
|
return "{\"code\":19999,\"msg\":\"未知错误\"}";
|
|
}
|
|
|
|
public string AddShop(string inputData, bool isAdmin=false)
|
|
{
|
|
if (!string.IsNullOrEmpty(inputData))
|
|
{
|
|
string user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
|
|
if (isAdmin)
|
|
user_name = RegexUtils.GetStringQuery(ref inputData, "shop_user_name");
|
|
string login_name = RegexUtils.GetStringQuery(ref inputData, "login_name");
|
|
string login_pass = RegexUtils.GetStringQuery(ref inputData, "login_pass");
|
|
string sub_user_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sub_user_name"));
|
|
string cookie = RegexUtils.GetStringQuery(ref inputData, "cookie");
|
|
string cookie2 = RegexUtils.GetStringQuery(ref inputData, "cookie2");
|
|
string anti_contents = RegexUtils.GetStringQuery(ref inputData, "anti_contents");
|
|
string shop_id = RegexUtils.GetStringQuery(ref inputData, "shop_id");
|
|
string mall_id = RegexUtils.GetStringQuery(ref inputData, "mall_id");
|
|
string shop_account = RegexUtils.GetStringQuery(ref inputData, "shop_account");
|
|
string group_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "group_name"));
|
|
string notes = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "notes"));
|
|
int r2 = 0;
|
|
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
|
|
|
|
if (string.IsNullOrEmpty(user_name))
|
|
{
|
|
return "{\"code\":500,\"msg\":\"没有用户名\"}";
|
|
}
|
|
if (string.IsNullOrEmpty(login_name))
|
|
{
|
|
return "{\"code\":501,\"msg\":\"没有店铺登录名\"}";
|
|
}
|
|
|
|
string conn = "ConnKJD";
|
|
MysqlUtils mySql = new MysqlUtils(conn);
|
|
string sql = "";
|
|
if (string.IsNullOrEmpty(shop_id))
|
|
sql = "select exists (select 1 from bxx.shop where login_name='" + login_name + "' and user_name='" + user_name + "')";
|
|
else
|
|
sql = "select exists (select 1 from bxx.shop where login_name='" + login_name + "' and user_name='" + user_name +
|
|
"' and shop_id='" + shop_id + "')";
|
|
var exist = mySql.ExecuteFirstInt(sql);
|
|
if (exist>0)
|
|
{
|
|
mySql.Close();
|
|
return "{\"code\":500,\"msg\":\"店铺" + login_name +" " + shop_account + "已存在\"}";
|
|
}
|
|
|
|
sql = "insert into bxx.shop (login_name,login_pass,cookie,cookie2,anti_contents,shop_account,shop_id," +
|
|
"mall_id,sub_user_name,user_name,group_name,notes,add_time,mdy_time) " +
|
|
"values ('" + login_name + "','" + login_pass + "','" + cookie + "','" + cookie2 + "','" + anti_contents + "','" + shop_account + "','" + shop_id +
|
|
"','" + mall_id + "','" + sub_user_name + "','" + user_name + "','" + group_name + "','" + notes + "','" +
|
|
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\":200,\"msg\":\"success\"}";
|
|
}
|
|
}
|
|
return "{\"code\":19999,\"msg\":\"未知错误\"}";
|
|
}
|
|
|
|
public string MdyShop(string inputData, bool isAdmin=false)
|
|
{
|
|
if (!string.IsNullOrEmpty(inputData))
|
|
{
|
|
string user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
|
|
if (isAdmin)
|
|
user_name = RegexUtils.GetStringQuery(ref inputData, "shop_user_name");
|
|
string login_name = RegexUtils.GetStringQuery(ref inputData, "login_name");
|
|
string login_pass = RegexUtils.GetStringQuery(ref inputData, "login_pass");
|
|
string sub_user_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sub_user_name"));
|
|
//string cookie = RegexUtils.GetStringQuery(ref inputData, "cookie");
|
|
//string cookie2 = RegexUtils.GetStringQuery(ref inputData, "cookie2");
|
|
string anti_contents = RegexUtils.GetStringQuery(ref inputData, "anti_contents");
|
|
string new_shop_id = RegexUtils.GetStringQuery(ref inputData, "new_shop_id");
|
|
string old_shop_id = RegexUtils.GetStringQuery(ref inputData, "shop_id");
|
|
string mall_id = RegexUtils.GetStringQuery(ref inputData, "mall_id");
|
|
string shop_account = RegexUtils.GetStringQuery(ref inputData, "shop_account");
|
|
string group_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "group_name"));
|
|
string notes = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "notes"));
|
|
string login_status = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "login_status"));
|
|
|
|
int r2 = 0;
|
|
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
|
|
|
|
if (string.IsNullOrEmpty(user_name))
|
|
{
|
|
return "{\"code\":500,\"msg\":\"没有用户名\"}";
|
|
}
|
|
if (string.IsNullOrEmpty(login_name))
|
|
{
|
|
return "{\"code\":501,\"msg\":\"没有店铺登录名\"}";
|
|
}
|
|
|
|
string conn = "ConnKJD";
|
|
MysqlUtils mySql = new MysqlUtils(conn);
|
|
string sql = "update bxx.shop set";
|
|
if (login_pass != null)
|
|
sql += " login_pass='" + login_pass + "',";
|
|
//if (cookie != null)
|
|
// sql += " cookie='" + cookie + "',";
|
|
//if (cookie2 != null)
|
|
// sql += " cookie2='" + cookie2 + "',";
|
|
if (anti_contents != null)
|
|
sql += " anti_contents='" + anti_contents + "',";
|
|
if (new_shop_id != null)
|
|
sql += " shop_id='" + new_shop_id + "',";
|
|
if (mall_id != null)
|
|
sql += " mall_id='" + mall_id + "',";
|
|
if (shop_account != null)
|
|
sql += " shop_account='" + shop_account + "',";
|
|
if (sub_user_name != null)
|
|
sql += " sub_user_name='" + sub_user_name + "',";
|
|
if (group_name != null)
|
|
sql += " group_name='" + group_name + "',";
|
|
if (notes != null)
|
|
sql += " notes='" + notes + "',";
|
|
if (login_status != null)
|
|
sql += " login_status='" + login_status + "',";
|
|
sql = sql.TrimEnd(',');
|
|
sql += " where login_name='" + login_name + "' and (user_name='" + user_name + "' or sub_user_name like '%" + user_name + "%')";
|
|
if (!string.IsNullOrEmpty(old_shop_id))
|
|
sql += " and shop_id='" + old_shop_id + "'";
|
|
|
|
var rst = mySql.ExecuteNonQuery(sql);
|
|
mySql.Close();
|
|
if (rst)
|
|
{
|
|
return "{\"code\":200,\"msg\":\"success\"}";
|
|
}
|
|
}
|
|
return "{\"code\":19999,\"msg\":\"未知错误\"}";
|
|
}
|
|
|
|
public string MdyAntiContent(string inputData)
|
|
{
|
|
if (!string.IsNullOrEmpty(inputData))
|
|
{
|
|
string login_name = RegexUtils.GetStringQuery(ref inputData, "login_name");
|
|
string shop_id = RegexUtils.GetStringQuery(ref inputData, "shop_id");
|
|
string anti_contents = RegexUtils.GetStringQuery(ref inputData, "anti_contents");
|
|
|
|
int r2 = 0;
|
|
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
|
|
|
|
if (string.IsNullOrEmpty(login_name))
|
|
{
|
|
return "{\"code\":500,\"msg\":\"店铺没有登录名\"}";
|
|
}
|
|
|
|
string conn = "ConnKJD";
|
|
MysqlUtils mySql = new MysqlUtils(conn);
|
|
string sql = "update bxx.shop set";
|
|
if (anti_contents != null)
|
|
sql += " anti_contents='" + anti_contents + "',";
|
|
sql = sql.TrimEnd(',');
|
|
sql += " where login_name='" + login_name + "' and shop_id='" + shop_id + "';";
|
|
|
|
var rst = mySql.ExecuteNonQuery(sql);
|
|
mySql.Close();
|
|
if (rst)
|
|
{
|
|
return "{\"code\":200,\"msg\":\"success\"}";
|
|
}
|
|
}
|
|
return "{\"code\":19999,\"msg\":\"未知错误\"}";
|
|
}
|
|
|
|
public string MdyCookieAndLoginStatus(string inputData)
|
|
{
|
|
if (!string.IsNullOrEmpty(inputData))
|
|
{
|
|
string login_name = RegexUtils.GetStringQuery(ref inputData, "login_name");
|
|
string cookie = RegexUtils.GetStringQuery(ref inputData, "cookie");
|
|
string cookie2 = RegexUtils.GetStringQuery(ref inputData, "cookie2");
|
|
string login_status = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "login_status"));
|
|
string login_status2 = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "login_status2"));
|
|
string pddid = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "pddid"));
|
|
|
|
int r2 = 0;
|
|
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
|
|
|
|
if (string.IsNullOrWhiteSpace(login_name))
|
|
{
|
|
return "{\"code\":500,\"msg\":\"店铺没有登录名\"}";
|
|
}
|
|
|
|
string conn = "ConnKJD";
|
|
MysqlUtils mySql = new MysqlUtils(conn);
|
|
string sql = "update bxx.shop set";
|
|
if (cookie != null)
|
|
sql += " cookie='" + cookie + "',";
|
|
if (cookie2 != null)
|
|
sql += " cookie2='" + cookie2 + "',";
|
|
if (login_status != null)
|
|
sql += " login_status='" + login_status + "',";
|
|
if (login_status2 != null)
|
|
sql += " login_status2='" + login_status2 + "',";
|
|
if (pddid != null)
|
|
sql += " pddid='" + pddid + "',";
|
|
sql = sql.TrimEnd(',');
|
|
sql += " where login_name='" + login_name + "'";
|
|
|
|
var rst = mySql.ExecuteNonQuery(sql);
|
|
mySql.Close();
|
|
if (rst)
|
|
{
|
|
return "{\"code\":200,\"msg\":\"success\"}";
|
|
}
|
|
}
|
|
return "{\"code\":19999,\"msg\":\"未知错误\"}";
|
|
}
|
|
|
|
|
|
public string DelShop(string inputData, bool isAdmin=false)
|
|
{
|
|
if (!string.IsNullOrEmpty(inputData))
|
|
{
|
|
var login_name = RegexUtils.GetStringQuery(ref inputData, "login_name");
|
|
var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
|
|
if (isAdmin)
|
|
user_name = RegexUtils.GetStringQuery(ref inputData, "shop_user_name");
|
|
var shop_id = RegexUtils.GetStringQuery(ref inputData, "shop_id");
|
|
var password = RegexUtils.GetStringQuery(ref inputData, "password");
|
|
int r2 = 0;
|
|
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
|
|
|
|
if (string.IsNullOrEmpty(user_name))
|
|
{
|
|
return "{\"code\":500,\"msg\":\"没有用户名\"}";
|
|
}
|
|
if (string.IsNullOrEmpty(login_name))
|
|
{
|
|
return "{\"code\":501,\"msg\":\"没有店铺登录名\"}";
|
|
}
|
|
|
|
string conn = "ConnKJD";
|
|
MysqlUtils mySql = new MysqlUtils(conn);
|
|
string sql = "delete from bxx.shop where user_name='" + user_name + "' and login_name='" + login_name + "'";
|
|
if (!string.IsNullOrEmpty(shop_id))
|
|
sql += " and shop_id='" + shop_id + "'";
|
|
|
|
var rst = mySql.ExecuteNonQuery(sql);
|
|
mySql.Close();
|
|
if (rst)
|
|
{
|
|
return "{\"code\":200,\"msg\":\"success\"}";
|
|
}
|
|
}
|
|
return "{\"code\":19999,\"msg\":\"未知错误\"}";
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设置店铺的二级超管
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public string SetShopSubSa(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 id = RegexUtils.GetStringQuery(ref inputData, "db_id")?.Replace("'", "\\'");
|
|
var login_name = RegexUtils.GetStringQuery(ref inputData, "shop_login_name")?.Replace("'", "\\'");
|
|
var operate_sub_sa_name = RegexUtils.GetStringQuery(ref inputData, "operate_sub_sa_name")?.Replace("'", "\\'");
|
|
|
|
if (string.IsNullOrEmpty(id) && string.IsNullOrEmpty(login_name))
|
|
{
|
|
return "{\"code\":50002,\"msg\":\"未选择任何待上传\"}";
|
|
}
|
|
|
|
string conn = "ConnKJD";
|
|
MysqlUtils mySql = new MysqlUtils(conn);
|
|
string sql = "update bxx.shop set";
|
|
if (operate_sub_sa_name != null)
|
|
sql += " operate_sub_sa_name='" + operate_sub_sa_name + "',";
|
|
sql += " add_sub_sa_time='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',";
|
|
sql = sql.TrimEnd(',');
|
|
if (!string.IsNullOrEmpty(id))
|
|
sql += " where id in (" + id + ")";
|
|
else if (!string.IsNullOrEmpty(login_name))
|
|
sql += " where login_name in ('" + login_name.Replace(",", "','") + "')";
|
|
else
|
|
sql += " where 1=2";
|
|
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 E57GetPddShopToken(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 mall_id = RegexUtils.GetStringQuery(ref inputData, "mall_id")?.Replace("'", "\\'");
|
|
var url = "https://po.e57.cn/prod-api/api/sys-api/system/open/api/shop/info/forPdd?mallId=" + mall_id;
|
|
|
|
var tokenRst = HttpUtils.e57GetResponse(url, "");
|
|
if (!tokenRst.Contains("\"code\":0"))
|
|
tokenRst = HttpUtils.e57GetResponse(url, "");
|
|
return tokenRst;
|
|
}
|
|
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
|
}
|
|
|
|
|
|
public string GetWeiDianShop(string inputData, bool isAdmin = false)
|
|
{
|
|
if (!string.IsNullOrEmpty(inputData))
|
|
{
|
|
var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
|
|
var password = RegexUtils.GetStringQuery(ref inputData, "password");
|
|
var search_id = RegexUtils.GetStringQuery(ref inputData, "search_id");
|
|
var search_user_name = RegexUtils.GetStringQuery(ref inputData, "search_user_name");
|
|
var search_login_name = RegexUtils.GetStringQuery(ref inputData, "search_login_name");
|
|
var search_notes = RegexUtils.GetStringQuery(ref inputData, "search_notes");
|
|
var search_name = RegexUtils.GetStringQuery(ref inputData, "search_name");
|
|
var operate_sub_sa_name = RegexUtils.GetStringQuery(ref inputData, "operate_sub_sa_name")?.Replace("'", "\\'");
|
|
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 shop_notes = RegexUtils.GetStringQuery(ref inputData, "shop_notes");
|
|
if (!string.IsNullOrWhiteSpace(shop_notes))
|
|
{
|
|
List<string> shopNotesLst = shop_notes.Split(',').ToList();
|
|
shop_notes = "'" + 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 weidian.shop s WHERE 1=1";
|
|
|
|
//where子句
|
|
string where = "";
|
|
if (isAdmin)
|
|
where += " and (s.cookie='' or s.shop_id!='')";
|
|
if (!isAdmin)
|
|
where += " and (s.user_name='" + user_name + "' or s.sub_user_name like '%" + user_name + "%')";
|
|
if (!string.IsNullOrWhiteSpace(operate_sub_sa_name))
|
|
where += " and s.operate_sub_sa_name='" + operate_sub_sa_name + "'";
|
|
if (!string.IsNullOrWhiteSpace(search_user_name))
|
|
where += " and s.user_name like '%" + search_user_name + "%'";
|
|
if (!string.IsNullOrWhiteSpace(search_login_name))
|
|
where += " and s.login_name like '%" + search_login_name + "%'";
|
|
if (!string.IsNullOrWhiteSpace(search_notes))
|
|
where += " and s.notes like '%" + search_notes + "%'";
|
|
if (!string.IsNullOrWhiteSpace(search_id))
|
|
where += " and s.shop_id like '%" + search_id + "%'";
|
|
if (!string.IsNullOrWhiteSpace(search_name))
|
|
where += " and s.shop_account like '%" + search_name + "%'";
|
|
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(shop_notes))
|
|
where += " and s.notes in (" + shop_notes + ")";
|
|
sql += where;
|
|
|
|
var count = mySql.ExecuteRowCount(sql);
|
|
|
|
DataTable dt;
|
|
if (count == 0)
|
|
{
|
|
dt = new DataTable();
|
|
}
|
|
else
|
|
{
|
|
sql = "SELECT s.id,s.login_name,s.login_pass,s.cookie,s.cookie2,s.wd_token,s.mall_id,s.shop_id,s.shop_account,s.sub_user_name," +
|
|
"s.user_name,s.company_name,s.notes,s.login_status,s.login_status2," +
|
|
"s.add_time,s.mdy_time,s.add_sub_sa_time,s.operate_sub_sa_name";
|
|
sql += " FROM weidian.shop 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 (!string.IsNullOrEmpty(mySql.Message))
|
|
{
|
|
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}";
|
|
}
|
|
if (dt != null)
|
|
{
|
|
List<ShopParam> shopList = new List<ShopParam>();
|
|
foreach (DataRow row in dt.Rows)
|
|
{
|
|
ShopParam shop = new ShopParam
|
|
{
|
|
id = Convert.ToInt32(row["id"]),
|
|
login_name = row["login_name"].ToString(),
|
|
login_pass = row["login_pass"].ToString(),
|
|
cookie = row["cookie"].ToString(),
|
|
cookie2 = row["cookie2"].ToString(),
|
|
wd_token = row["wd_token"].ToString(),
|
|
shop_id = row["shop_id"].ToString(),
|
|
shop_account = row["shop_account"].ToString(),
|
|
sub_user_name = row["sub_user_name"].ToString(),
|
|
user_name = row["user_name"].ToString(),
|
|
company_name = row["company_name"].ToString(),
|
|
notes = row["notes"].ToString(),
|
|
login_status = row["login_status"].ToString(),
|
|
login_status2 = row["login_status2"].ToString(),
|
|
operate_sub_sa_name = row["operate_sub_sa_name"].ParseToString(),
|
|
mall_id = row["mall_id"].ParseToString(),
|
|
};
|
|
shopList.Add(shop);
|
|
}
|
|
|
|
var data = JsonUtils.SerializeObjectToString(shopList);
|
|
return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"count\":" + count + "}";
|
|
}
|
|
}
|
|
return "{\"code\":19999,\"msg\":\"未知错误\"}";
|
|
}
|
|
|
|
public string AddWeiDianShop(string inputData, bool isAdmin = false)
|
|
{
|
|
if (!string.IsNullOrEmpty(inputData))
|
|
{
|
|
string user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
|
|
if (isAdmin)
|
|
user_name = RegexUtils.GetStringQuery(ref inputData, "shop_user_name");
|
|
string login_name = RegexUtils.GetStringQuery(ref inputData, "login_name");
|
|
string login_pass = RegexUtils.GetStringQuery(ref inputData, "login_pass");
|
|
string sub_user_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sub_user_name"));
|
|
string cookie = RegexUtils.GetStringQuery(ref inputData, "cookie");
|
|
string cookie2 = RegexUtils.GetStringQuery(ref inputData, "cookie2");
|
|
string wd_token = RegexUtils.GetStringQuery(ref inputData, "wd_token");
|
|
string shop_id = RegexUtils.GetStringQuery(ref inputData, "shop_id");
|
|
string mall_id = RegexUtils.GetStringQuery(ref inputData, "mall_id");
|
|
string shop_account = RegexUtils.GetStringQuery(ref inputData, "shop_account");
|
|
string group_name = RegexUtils.GetStringQuery(ref inputData, "group_name");
|
|
string notes = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "notes"));
|
|
int r2 = 0;
|
|
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
|
|
|
|
if (string.IsNullOrEmpty(user_name))
|
|
{
|
|
return "{\"code\":500,\"msg\":\"没有用户名\"}";
|
|
}
|
|
if (string.IsNullOrEmpty(login_name))
|
|
{
|
|
return "{\"code\":501,\"msg\":\"没有店铺登录名\"}";
|
|
}
|
|
|
|
string conn = "ConnKJD";
|
|
MysqlUtils mySql = new MysqlUtils(conn);
|
|
string sql = "";
|
|
if (string.IsNullOrEmpty(shop_id))
|
|
sql = "select exists (select 1 from weidian.shop where login_name='" + login_name + "' and user_name='" + user_name + "')";
|
|
else
|
|
sql = "select exists (select 1 from weidian.shop where login_name='" + login_name + "' and user_name='" + user_name +
|
|
"' and shop_id='" + shop_id + "')";
|
|
var exist = mySql.ExecuteFirstInt(sql);
|
|
if (exist > 0)
|
|
{
|
|
mySql.Close();
|
|
//return "{\"code\":500,\"msg\":\"店铺" + login_name + " " + shop_account + "已存在\"}";
|
|
return MdyWeiDianShop(inputData, isAdmin);
|
|
}
|
|
|
|
sql = "insert into weidian.shop (login_name,login_pass,cookie,cookie2,wd_token,shop_account,shop_id," +
|
|
"mall_id,sub_user_name,user_name,group_name,notes,add_time,mdy_time) " +
|
|
"values ('" + login_name + "','" + login_pass + "','" + cookie + "','" + cookie2 + "','" + wd_token + "','" + shop_account + "','" + shop_id +
|
|
"','" + mall_id + "','" + sub_user_name + "','" + user_name + "','" + group_name + "','" + notes + "','" +
|
|
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\":200,\"msg\":\"success\"}";
|
|
}
|
|
else
|
|
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}";
|
|
}
|
|
return "{\"code\":19999,\"msg\":\"未知错误\"}";
|
|
}
|
|
|
|
public string MdyWeiDianShop(string inputData, bool isAdmin = false)
|
|
{
|
|
if (!string.IsNullOrEmpty(inputData))
|
|
{
|
|
string user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
|
|
if (isAdmin)
|
|
user_name = RegexUtils.GetStringQuery(ref inputData, "shop_user_name");
|
|
string login_name = RegexUtils.GetStringQuery(ref inputData, "login_name");
|
|
string login_pass = RegexUtils.GetStringQuery(ref inputData, "login_pass");
|
|
string sub_user_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sub_user_name"));
|
|
string cookie = RegexUtils.GetStringQuery(ref inputData, "cookie");
|
|
string cookie2 = RegexUtils.GetStringQuery(ref inputData, "cookie2");
|
|
string wd_token = RegexUtils.GetStringQuery(ref inputData, "wd_token");
|
|
string new_shop_id = RegexUtils.GetStringQuery(ref inputData, "new_shop_id");
|
|
string old_shop_id = RegexUtils.GetStringQuery(ref inputData, "shop_id");
|
|
string mall_id = RegexUtils.GetStringQuery(ref inputData, "mall_id");
|
|
string shop_account = RegexUtils.GetStringQuery(ref inputData, "shop_account");
|
|
string group_name = RegexUtils.GetStringQuery(ref inputData, "group_name");
|
|
string notes = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "notes"));
|
|
string login_status = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "login_status"));
|
|
|
|
int r2 = 0;
|
|
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
|
|
|
|
if (string.IsNullOrEmpty(user_name))
|
|
{
|
|
return "{\"code\":500,\"msg\":\"没有用户名\"}";
|
|
}
|
|
if (string.IsNullOrEmpty(login_name))
|
|
{
|
|
return "{\"code\":501,\"msg\":\"没有店铺登录名\"}";
|
|
}
|
|
|
|
string conn = "ConnKJD";
|
|
MysqlUtils mySql = new MysqlUtils(conn);
|
|
string sql = "update weidian.shop set";
|
|
if (login_pass != null)
|
|
sql += " login_pass='" + login_pass + "',";
|
|
if (cookie != null)
|
|
sql += " cookie='" + cookie + "',";
|
|
if (cookie2 != null)
|
|
sql += " cookie2='" + cookie2 + "',";
|
|
if (wd_token != null)
|
|
sql += " wd_token='" + wd_token + "',";
|
|
if (new_shop_id != null)
|
|
sql += " shop_id='" + new_shop_id + "',";
|
|
if (mall_id != null)
|
|
sql += " mall_id='" + mall_id + "',";
|
|
if (shop_account != null)
|
|
sql += " shop_account='" + shop_account + "',";
|
|
if (sub_user_name != null)
|
|
sql += " sub_user_name='" + sub_user_name + "',";
|
|
if (group_name != null)
|
|
sql += " group_name='" + group_name + "',";
|
|
if (notes != null)
|
|
sql += " notes='" + notes + "',";
|
|
if (login_status != null)
|
|
sql += " login_status='" + login_status + "',";
|
|
sql = sql.TrimEnd(',');
|
|
sql += " where login_name='" + login_name + "' and (user_name='" + user_name + "' or sub_user_name like '%" + user_name + "%')";
|
|
if (!string.IsNullOrEmpty(old_shop_id))
|
|
sql += " and shop_id='" + old_shop_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 MdyWeiDianShopCookie(string inputData, bool isAdmin = false)
|
|
{
|
|
if (!string.IsNullOrEmpty(inputData))
|
|
{
|
|
string user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
|
|
if (isAdmin)
|
|
user_name = RegexUtils.GetStringQuery(ref inputData, "shop_user_name");
|
|
string shop_id = RegexUtils.GetStringQuery(ref inputData, "shop_id");
|
|
string wd_token = RegexUtils.GetStringQuery(ref inputData, "wd_token");
|
|
string cookie = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "cookie"));
|
|
string login_status = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "login_status"));
|
|
|
|
int r2 = 0;
|
|
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
|
|
|
|
if (string.IsNullOrEmpty(user_name))
|
|
{
|
|
return "{\"code\":500,\"msg\":\"没有用户名\"}";
|
|
}
|
|
if (string.IsNullOrEmpty(shop_id))
|
|
{
|
|
return "{\"code\":501,\"msg\":\"没有店铺信息\"}";
|
|
}
|
|
if (string.IsNullOrEmpty(cookie) && string.IsNullOrEmpty(login_status))
|
|
{
|
|
return "{\"code\":501,\"msg\":\"cookie和登录状态不能全为空\"}";
|
|
}
|
|
|
|
string conn = "ConnKJD";
|
|
MysqlUtils mySql = new MysqlUtils(conn);
|
|
string sql = "update weidian.shop set";
|
|
if (cookie != null)
|
|
sql += " cookie='" + cookie + "',";
|
|
if (wd_token != null)
|
|
sql += " wd_token='" + wd_token + "',";
|
|
if (login_status != null)
|
|
sql += " login_status='" + login_status + "',";
|
|
sql = sql.TrimEnd(',');
|
|
sql += " where shop_id='" + shop_id + "'";
|
|
|
|
var rst = mySql.ExecuteNonQuery(sql);
|
|
mySql.Close();
|
|
if (rst)
|
|
{
|
|
return "{\"code\":200,\"msg\":\"success\"}";
|
|
}
|
|
}
|
|
return "{\"code\":19999,\"msg\":\"未知错误\"}";
|
|
}
|
|
|
|
public string DelWeiDianShop(string inputData, bool isAdmin = false)
|
|
{
|
|
if (!string.IsNullOrEmpty(inputData))
|
|
{
|
|
string user_name = RegexUtils.GetStringQuery(ref inputData, "user_name")?.Replace("'", "\\'");
|
|
if (isAdmin)
|
|
user_name = RegexUtils.GetStringQuery(ref inputData, "shop_user_name")?.Replace("'", "\\'");
|
|
string shop_id = RegexUtils.GetStringQuery(ref inputData, "shop_id")?.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(shop_id))
|
|
{
|
|
return "{\"code\":501,\"msg\":\"没有指定要删除的店铺\"}";
|
|
}
|
|
|
|
string conn = "ConnKJD";
|
|
MysqlUtils mySql = new MysqlUtils(conn);
|
|
string sql = "delete from weidian.shop where user_name='" + user_name + "' and shop_id='" + shop_id + "'";
|
|
|
|
var rst = mySql.ExecuteNonQuery(sql);
|
|
mySql.Close();
|
|
if (rst)
|
|
{
|
|
return "{\"code\":200,\"msg\":\"success\"}";
|
|
}
|
|
}
|
|
return "{\"code\":19999,\"msg\":\"未知错误\"}";
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|