1688上传类目转换等优化 充值用户服务充值和用户续费店铺功能
This commit is contained in:
1 parent
ecb291e3d7
commit
aab73b978f
56 files changed
+4532
-1748
No files matched your search
@@ -1,5 +1,6 @@
|
||||
using KJD_Web.Model;
|
||||
using KJD_Web.Utils;
|
||||
using MySql.Data.MySqlClient;
|
||||
using Mysqlx.Crud;
|
||||
using NaiBa.Util.Extension;
|
||||
using System;
|
||||
@@ -9,6 +10,7 @@ using System.Linq;
|
||||
using System.Net;
|
||||
using System.Reflection;
|
||||
using System.Web;
|
||||
using System.Web.ApplicationServices;
|
||||
using System.Web.Security;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
@@ -507,35 +509,60 @@ namespace KJD_Web.BLL.WXXD
|
||||
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
||||
}
|
||||
|
||||
public string UpdateUserPointsTest(string inputData)
|
||||
public string AddUserTopUpMsg(string inputData)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(inputData))
|
||||
{
|
||||
if (!GetSign(inputData))
|
||||
return "{\"code\":999,\"msg\":\"校验失败\"}";
|
||||
|
||||
var id = RegexUtils.GetStringQuery(ref inputData, "id")?.Replace("'", "\\'");
|
||||
var delta_points = RegexUtils.GetStringQuery(ref inputData, "delta_points")?.Replace("'", "\\'");
|
||||
int r2 = 0;
|
||||
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
|
||||
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 msg = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "msg"))?.Replace("'", "\\'");
|
||||
if (string.IsNullOrEmpty(user_name))
|
||||
return "{\"code\":501,\"msg\":\"请输入用户名\"}";
|
||||
if (string.IsNullOrEmpty(msg))
|
||||
return "{\"code\":501,\"msg\":\"请输入充值备注信息\"}";
|
||||
|
||||
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
||||
MysqlUtils mySql = new MysqlUtils(conn);
|
||||
string sql = "";
|
||||
//sql = "select * from wxxd.user where parent_user_name='"
|
||||
// + user_name + "'";
|
||||
sql = "update wxxd.user set";
|
||||
if (!string.IsNullOrEmpty(delta_points))
|
||||
sql += " points=points+" + delta_points.ParseToInt() + ",";
|
||||
sql = sql.TrimEnd(',');
|
||||
sql += " where id=" + id + "";
|
||||
|
||||
string sql;
|
||||
sql = "INSERT INTO wxxd.user_points_top_up_msg (nick_name,user_name,msg) " +
|
||||
"VALUES ('" + nick_name + "','" + user_name + "','" + msg + "');";
|
||||
var rst = mySql.ExecuteNonQuery(sql);
|
||||
mySql.Close();
|
||||
if (rst)
|
||||
{
|
||||
if (!rst)
|
||||
return "{\"code\":501,\"msg\":\"" + mySql.Message + "\"}";
|
||||
else
|
||||
return "{\"code\":200,\"msg\":\"success\"}";
|
||||
}
|
||||
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
||||
}
|
||||
|
||||
public string UpdateUserTopUpMsg(string inputData)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(inputData))
|
||||
{
|
||||
if (!GetSign(inputData))
|
||||
return "{\"code\":999,\"msg\":\"校验失败\"}";
|
||||
|
||||
var id = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "id"))?.Replace("'", "\\'");
|
||||
var op_rst = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "op_rst"))?.Replace("'", "\\'");
|
||||
if (string.IsNullOrEmpty(id))
|
||||
return "{\"code\":501,\"msg\":\"请输入要修改的记录\"}";
|
||||
if (string.IsNullOrEmpty(op_rst))
|
||||
return "{\"code\":501,\"msg\":\"请输入操作结果\"}";
|
||||
|
||||
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
||||
MysqlUtils mySql = new MysqlUtils(conn);
|
||||
string sql;
|
||||
sql = "UPDATE wxxd.user_points_top_up_msg SET op_rst='" + op_rst + "' WHERE id='" + id + "';";
|
||||
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\":\"输入为空\"}";
|
||||
}
|
||||
@@ -554,7 +581,7 @@ namespace KJD_Web.BLL.WXXD
|
||||
|
||||
var user_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "update_user_name"))?.Replace("'", "\\'");
|
||||
var user_nick = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "update_user_nick"))?.Replace("'", "\\'");
|
||||
var delta_points = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "delta_points"))?.ParseToInt();
|
||||
var delta_points = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "delta_points")).ParseToInt();
|
||||
var option_type = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "option_type"))?.Replace("'", "\\'");
|
||||
var operator_type = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "operator_type"))?.Replace("'", "\\'");
|
||||
var operator_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "operator_name"))?.Replace("'", "\\'");
|
||||
@@ -563,66 +590,158 @@ namespace KJD_Web.BLL.WXXD
|
||||
|
||||
if (string.IsNullOrEmpty(user_name) || string.IsNullOrEmpty(user_nick))
|
||||
{
|
||||
return "{\"code\":500,\"msg\":\"充值对象不能为空\"}";
|
||||
return "{\"code\":500,\"msg\":\"操作对象不能为空\"}";
|
||||
}
|
||||
if (delta_points.IsNullOrZero())
|
||||
if (delta_points <= 0 && option_type == "续费")
|
||||
{
|
||||
return "{\"code\":500,\"msg\":\"充值金额不合法\"}";
|
||||
return "{\"code\":500,\"msg\":\"续费金额错误,需大于0\"}";
|
||||
}
|
||||
if (delta_points == 0)
|
||||
{
|
||||
return "{\"code\":500,\"msg\":\"操作金额错误,不能等于0\"}";
|
||||
}
|
||||
if (string.IsNullOrEmpty(option_type) || string.IsNullOrEmpty(operator_type) || string.IsNullOrEmpty(operator_name))
|
||||
{
|
||||
return "{\"code\":500,\"msg\":\"操作或操作者信息不合法\"}";
|
||||
return "{\"code\":500,\"msg\":\"操作或操作者信息错误\"}";
|
||||
}
|
||||
if (option_type != "充值" && option_type != "续费")
|
||||
{
|
||||
return "{\"code\":500,\"msg\":\"操作类型错误\"}";
|
||||
}
|
||||
|
||||
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
||||
MysqlUtils mySql = new MysqlUtils(conn);
|
||||
MysqlUtils mySql = new MysqlUtils(conn, true);
|
||||
string sql;
|
||||
int userPoints = 0;
|
||||
int newUserPoints = 0;
|
||||
|
||||
#region 计算是否余额不足
|
||||
sql = "SELECT points FROM `wxxd`.`user` WHERE user_name='" + user_name + "'";
|
||||
userPoints = mySql.ExecuteFirstInt(sql);
|
||||
newUserPoints = userPoints;
|
||||
if (!string.IsNullOrEmpty(mySql.Message))
|
||||
{
|
||||
mySql.RollBack();
|
||||
mySql.Close();
|
||||
return "{\"code\":501,\"msg\":\"" + mySql.Message + "\"}";
|
||||
}
|
||||
if (option_type == "续费")
|
||||
{
|
||||
if (delta_points <= 0 || delta_points % 30 > 0)
|
||||
{
|
||||
mySql.RollBack();
|
||||
mySql.Close();
|
||||
return "{\"code\":501,\"msg\":\"续费点数必须是30的整倍数\"}";
|
||||
}
|
||||
else if (userPoints < delta_points)
|
||||
{
|
||||
mySql.RollBack();
|
||||
mySql.Close();
|
||||
return "{\"code\":500,\"msg\":\"余额不足\"}";
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
sql = "UPDATE `wxxd`.`user` SET";
|
||||
if (option_type == "充值")
|
||||
{
|
||||
sql += " points=points+" + delta_points.ParseToInt() + ",";
|
||||
newUserPoints = userPoints + delta_points.ParseToInt();
|
||||
}
|
||||
else
|
||||
{
|
||||
sql += " points=points-" + delta_points.ParseToInt() + ",";
|
||||
newUserPoints = userPoints - delta_points.ParseToInt();
|
||||
}
|
||||
sql = sql.TrimEnd(',');
|
||||
sql += " WHERE user_name='" + user_name + "' AND points=" + userPoints + ";";
|
||||
var changePointsRst = mySql.ExecuteAffectedRows(sql);
|
||||
if (!string.IsNullOrEmpty(mySql.Message))
|
||||
{
|
||||
mySql.RollBack();
|
||||
mySql.Close();
|
||||
return "{\"code\":501,\"msg\":\"" + mySql.Message + "\"}";
|
||||
}
|
||||
else if (changePointsRst <= 0)
|
||||
{
|
||||
mySql.RollBack();
|
||||
mySql.Close();
|
||||
return "{\"code\":500,\"msg\":\"账户已发生改变,请刷新账户后重新操作\"}";
|
||||
}
|
||||
|
||||
sql = " INSERT INTO wxxd.user_points_record(user_name,user_nick,points,option_type,operator_type,operator_name,shop_id,shop_account)";
|
||||
sql += " VALUES(@user_name,@user_nick,@points,@option_type,@operator_type,@operator_name,@shop_id,@shop_account);";
|
||||
List<MySqlParameter> paramLst = new List<MySqlParameter>();
|
||||
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "user_name", Value = user_name, });
|
||||
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "user_nick", Value = user_nick, });
|
||||
paramLst.Add(new MySqlParameter() { DbType = DbType.Int32, ParameterName = "points", Value = delta_points, });
|
||||
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "option_type", Value = option_type, });
|
||||
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "operator_type", Value = operator_type, });
|
||||
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "operator_name", Value = operator_name, });
|
||||
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "shop_id", Value = shop_id, });
|
||||
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "shop_account", Value = shop_account, });
|
||||
var addOptionRst = mySql.ExecuteAffectedRows(sql, paramLst.ToArray());
|
||||
if (!string.IsNullOrEmpty(mySql.Message))
|
||||
{
|
||||
mySql.RollBack();
|
||||
mySql.Close();
|
||||
return "{\"code\":501,\"msg\":\"" + mySql.Message + "\"}";
|
||||
}
|
||||
else if (addOptionRst <= 0)
|
||||
{
|
||||
mySql.RollBack();
|
||||
mySql.Close();
|
||||
return "{\"code\":500,\"msg\":\"新增操作记录失败,请稍候重试\"}";
|
||||
}
|
||||
|
||||
int expireTime = 0;
|
||||
int newExpireTime = 0;
|
||||
if (option_type == "续费")
|
||||
{
|
||||
sql = "SELECT expire_time FROM `wxxd`.`user_points_shop_expire` WHERE shop_id='" + shop_id + "';";
|
||||
expireTime = mySql.ExecuteFirstInt(sql);
|
||||
if (!string.IsNullOrEmpty(mySql.Message))
|
||||
{
|
||||
mySql.RollBack();
|
||||
mySql.Close();
|
||||
return "{\"code\":501,\"msg\":\"" + mySql.Message + "\"}";
|
||||
}
|
||||
|
||||
if (expireTime == 0)
|
||||
{
|
||||
newExpireTime = TimeUtils.DateTimeToTimestampSeconds(DateTime.Now.AddMonths(delta_points.ParseToInt() / 30));
|
||||
sql = " INSERT INTO `wxxd`.`user_points_shop_expire` (shop_id,expire_time)" +
|
||||
" VALUES ('" + shop_id + "'," + newExpireTime + ");";
|
||||
}
|
||||
else
|
||||
{
|
||||
DateTime expireDateTime = TimeUtils.StampToDateTime(expireTime);
|
||||
if (expireDateTime < DateTime.Now)
|
||||
expireDateTime = DateTime.Now.AddMonths(delta_points.ParseToInt() / 30);
|
||||
else
|
||||
expireDateTime = expireDateTime.AddMonths(delta_points.ParseToInt() / 30);
|
||||
newExpireTime = TimeUtils.DateTimeToTimestampSeconds(expireDateTime);
|
||||
|
||||
sql = "UPDATE `wxxd`.`user_points_shop_expire` set expire_time=" + newExpireTime + " WHERE shop_id='" + shop_id + "' AND expire_time=" + expireTime;
|
||||
}
|
||||
var renewalRst = mySql.ExecuteAffectedRows(sql);
|
||||
if (!string.IsNullOrEmpty(mySql.Message))
|
||||
{
|
||||
mySql.RollBack();
|
||||
mySql.Close();
|
||||
return "{\"code\":501,\"msg\":\"" + mySql.Message + "\"}";
|
||||
}
|
||||
else if (renewalRst <= 0)
|
||||
{
|
||||
mySql.RollBack();
|
||||
mySql.Close();
|
||||
return "{\"code\":500,\"msg\":\"店铺已发生改变,请刷新店铺后重新操作\"}";
|
||||
}
|
||||
}
|
||||
|
||||
mySql.Commit();
|
||||
mySql.Close();
|
||||
//////string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
||||
//////MysqlUtils mySql = new MysqlUtils(conn);
|
||||
//////string sql = "";
|
||||
//////sql += " START TRANSACTION";
|
||||
//////sql += " SELECT * FROM wxxd.user WHERE user_name='" + user_name + "' FOR UPDATE;";
|
||||
//////sql += " INSERT INTO wxxd.user_points_record(user_name,user_nick,points,option_type,operator_type,operator_name,shop_id,shop_account)";
|
||||
//////sql += " VALUES()";
|
||||
//////sql += " UPDATE wxxd.user SET points = points + delta_points";
|
||||
|
||||
////////INSERT INTO TableB(column1, column2)
|
||||
////////SELECT A.column1, 'some_value' AS column2
|
||||
////////FROM TableA A
|
||||
////////WHERE A.value > 100;
|
||||
|
||||
//////sql = "select points from wxxd.user where user_name='" + user_name + "'";
|
||||
//////var rst1 = mySql.ExecuteFirstInt(sql);
|
||||
|
||||
|
||||
//sql = "UPDATE wxxd.user SET";
|
||||
//if (option_type == "充值")
|
||||
// sql += " points=points+" + delta_points.ParseToInt() + ",";
|
||||
//else
|
||||
// sql += " points=points-" + delta_points.ParseToInt() + ",";
|
||||
//sql = sql.TrimEnd(',');
|
||||
//sql += " where id=" + id + "";
|
||||
//-
|
||||
//if (!string.IsNullOrEmpty(notes))
|
||||
// sql += " notes='" + notes + "',";
|
||||
//if (!string.IsNullOrEmpty(sa_level))
|
||||
// sql += " sa_level=" + sa_level + ",";
|
||||
//if (authority != null)
|
||||
// sql += " authority='" + authority + "',";
|
||||
//sql = sql.TrimEnd(',');
|
||||
//sql += " where id=" + id + "";
|
||||
|
||||
//var rst = mySql.ExecuteNonQuery(sql);
|
||||
//mySql.Close();
|
||||
//if (rst)
|
||||
//{
|
||||
// return "{\"code\":200,\"msg\":\"success\"}";
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}";
|
||||
//}
|
||||
return "{\"code\":200,\"msg\":\"success\"}";
|
||||
return "{\"code\":200,\"msg\":\"success\",\"newExpireTime\":" + newExpireTime + ",\"newUserPoints\":" + newUserPoints + "}";
|
||||
}
|
||||
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user