1688上传类目转换等优化 充值用户服务充值和用户续费店铺功能
This commit is contained in:
1 parent
ecb291e3d7
commit
aab73b978f
56 files changed
+4532
-1748
No files matched your search
@@ -4,7 +4,9 @@ using KJD_Web.Utils;
|
||||
using MySql.Data.MySqlClient;
|
||||
using Mysqlx.Crud;
|
||||
using NaiBa.Util.Extension;
|
||||
using NaiBa.Util.Helper;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
@@ -1193,6 +1195,122 @@ namespace KJD_Web.BLL.WXXD
|
||||
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
||||
}
|
||||
|
||||
public string WXAddMdyCommissionRate(string inputData)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(inputData))
|
||||
{
|
||||
if (!WXUserManage.GetSign(inputData))
|
||||
return "{\"code\":999,\"msg\":\"校验失败\"}";
|
||||
|
||||
//int page = RegexUtils.GetStringQuery(ref inputData, "page").ParseToInt();
|
||||
//int page_size = RegexUtils.GetStringQuery(ref inputData, "page_size").ParseToInt(50);
|
||||
string spu_id = RegexUtils.GetStringQuery(ref inputData, "spu_id")?.Replace("'", "\\'");
|
||||
string product_name = RegexUtils.GetStringQuery(ref inputData, "product_name")?.Replace("'", "\\'");
|
||||
int? commission_rate = RegexUtils.GetStringQuery(ref inputData, "commission_rate").ParseToNullableInt();
|
||||
if (string.IsNullOrEmpty("spu_id"))
|
||||
return "{\"code\":50001,\"msg\":\"没有商品Id\"}";
|
||||
if (string.IsNullOrEmpty("product_name"))
|
||||
return "{\"code\":50001,\"msg\":\"没有商品名称\"}";
|
||||
|
||||
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
||||
MysqlUtils mySql = new MysqlUtils(conn);
|
||||
|
||||
string sql = "SELECT * FROM `bxx`.`product_wx_commission_rate` where spu_id='" + spu_id + "'";
|
||||
|
||||
string where = "";
|
||||
sql += where;
|
||||
|
||||
var dt = mySql.ExecuteDataTable(sql);
|
||||
mySql.Close();
|
||||
|
||||
if (dt != null)
|
||||
{
|
||||
conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
||||
mySql = new MysqlUtils(conn);
|
||||
if (dt.Rows.Count == 0)
|
||||
{
|
||||
sql = "INSERT INTO `bxx`.`product_wx_commission_rate` (spu_id,product_name,commission_rate) VALUES (@spu_id,@product_name,@commission_rate);";
|
||||
}
|
||||
else
|
||||
{
|
||||
sql = "UPDATE `bxx`.`product_wx_commission_rate` SET product_name=@product_name,commission_rate=@commission_rate WHERE spu_id=@spu_id;";
|
||||
}
|
||||
|
||||
List<MySqlParameter> paramLst = new List<MySqlParameter>();
|
||||
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "spu_id", Value = spu_id, });
|
||||
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "product_name", Value = product_name, });
|
||||
paramLst.Add(new MySqlParameter() { DbType = DbType.Int32, ParameterName = "commission_rate", Value = commission_rate, });
|
||||
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 WXGetCommissionRate(string inputData)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(inputData))
|
||||
{
|
||||
if (!WXUserManage.GetSign(inputData))
|
||||
return "{\"code\":999,\"msg\":\"校验失败\"}";
|
||||
|
||||
//int page = RegexUtils.GetStringQuery(ref inputData, "page").ParseToInt();
|
||||
//int page_size = RegexUtils.GetStringQuery(ref inputData, "page_size").ParseToInt(50);
|
||||
string spu_ids = RegexUtils.GetStringQuery(ref inputData, "spu_ids")?.Replace("'", "\\'");
|
||||
|
||||
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
||||
MysqlUtils mySql = new MysqlUtils(conn);
|
||||
|
||||
string sql = "SELECT * FROM `bxx`.`product_wx_commission_rate` where spu_id in ('" + spu_ids.Replace(",", "','") + "')";
|
||||
|
||||
string where = "";
|
||||
sql += where;
|
||||
|
||||
var dt = mySql.ExecuteDataTable(sql);
|
||||
mySql.Close();
|
||||
|
||||
if (dt != null)
|
||||
{
|
||||
JArray jArr = new JArray();
|
||||
try
|
||||
{
|
||||
foreach (DataRow row in dt.Rows)
|
||||
{
|
||||
JObject jObj = new JObject();
|
||||
jObj["id"] = row["id"].ToString();
|
||||
jObj["product_name"] = row["product_name"].ToString();
|
||||
jObj["commission_rate"] = row["commission_rate"].ParseToNullableInt();
|
||||
jObj["add_time"] = Convert.ToDateTime(row["add_time"]);
|
||||
jObj["mdy_time"] = Convert.ToDateTime(row["mdy_time"]);
|
||||
jArr.Add(jObj);
|
||||
}
|
||||
return "{\"code\":200,\"msg\":\"success\",\"data\":" + JsonUtils.SerializeObject(jArr) + "}";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return "{\"code\":50002,\"msg\":\"" + ex.Message + "\",\"data\":[]}";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return "{\"code\":50003,\"msg\":\"" + mySql.Message + "\",\"data\":[]}";
|
||||
}
|
||||
}
|
||||
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
||||
}
|
||||
|
||||
|
||||
public string E57GetFreightTemplate(string inputData)
|
||||
{
|
||||
|
||||
@@ -5,6 +5,7 @@ using KJD_Web.Utils;
|
||||
using MySql.Data.MySqlClient;
|
||||
using MySqlX.XDevAPI;
|
||||
using NaiBa.Util.Extension;
|
||||
using NaiBa.Util.Helper;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
@@ -12,10 +13,12 @@ using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Security.Cryptography;
|
||||
using System.Web;
|
||||
using System.Web.Security;
|
||||
using System.Web.UI.HtmlControls;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
namespace KJD_Web.BLL.WXXD
|
||||
{
|
||||
@@ -35,6 +38,8 @@ namespace KJD_Web.BLL.WXXD
|
||||
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("'", "");
|
||||
var is_show_expire = RegexUtils.GetStringQuery(ref inputData, "is_show_expire")?.ParseToBool();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(shop_ids))
|
||||
{
|
||||
List<string> shopIdLst = shop_ids.Split(',').ToList();
|
||||
@@ -58,13 +63,32 @@ namespace KJD_Web.BLL.WXXD
|
||||
|
||||
if (page_size == 0)
|
||||
page_size = 50;
|
||||
int r2 = 0;
|
||||
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
|
||||
|
||||
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
||||
MysqlUtils mySql = new MysqlUtils(conn);
|
||||
string sql;
|
||||
bool isPayUser = false;
|
||||
if (!isAdmin)
|
||||
{
|
||||
sql = "select u.authority,uu.authority as main_authority " +
|
||||
"FROM wxxd.user u LEFT JOIN wxxd.user uu ON uu.user_name=u.parent_user_name where u.user_name='"
|
||||
+ user_name + "'";
|
||||
|
||||
string sql = "SELECT COUNT(s.id) FROM wxxd.shop s WHERE 1=1";
|
||||
var dtRow = mySql.ExecuteDataTableRow(sql);
|
||||
if (!string.IsNullOrEmpty(mySql.Message))
|
||||
{
|
||||
mySql.Close();
|
||||
return "{\"code\":501,\"msg\":\"" + mySql.Message + "\",\"data\":null}";
|
||||
}
|
||||
if (dtRow == null)
|
||||
{
|
||||
mySql.Close();
|
||||
return "{\"code\":501,\"msg\":\"" + mySql.Message + "\",\"data\":null}";
|
||||
}
|
||||
isPayUser = dtRow["authority"].ToString().Contains("充值用户") || dtRow["main_authority"].ToString().Contains("充值用户");
|
||||
}
|
||||
|
||||
sql = "SELECT COUNT(*) FROM wxxd.shop s WHERE 1=1";
|
||||
|
||||
//where子句
|
||||
string where = "";
|
||||
@@ -101,7 +125,8 @@ namespace KJD_Web.BLL.WXXD
|
||||
}
|
||||
else
|
||||
{
|
||||
sql = "SELECT s.*,se.expire_time FROM wxxd.shop s" +
|
||||
sql = " SELECT s.*,se.expire_time " +
|
||||
" FROM wxxd.shop s" +
|
||||
" LEFT JOIN wxxd.user_points_shop_expire se ON s.shop_id=se.shop_id" +
|
||||
" WHERE 1=1";
|
||||
sql += where; // where 子句
|
||||
@@ -112,9 +137,14 @@ namespace KJD_Web.BLL.WXXD
|
||||
}
|
||||
|
||||
mySql.Close();
|
||||
if (!string.IsNullOrEmpty(mySql.Message))
|
||||
{
|
||||
return "{\"code\":501,\"msg\":\"" + mySql.Message + "\",\"data\":null}";
|
||||
}
|
||||
if (dt != null)
|
||||
{
|
||||
List<ShopParam> shopList=new List<ShopParam>();
|
||||
List<ShopParam> shopList = new List<ShopParam>();
|
||||
List<ShopParam> allShopList = new List<ShopParam>();
|
||||
foreach (DataRow row in dt.Rows)
|
||||
{
|
||||
ShopParam shop = new ShopParam
|
||||
@@ -139,63 +169,24 @@ namespace KJD_Web.BLL.WXXD
|
||||
openid = row["openid"].ParseToString(),
|
||||
group_name = row["group_name"].ParseToString(),
|
||||
add_time = row["add_time"].IsNullOrEmpty() ? DateTime.MinValue : Convert.ToDateTime(row["add_time"]),
|
||||
expire_time = row["expire_time"].IsNullOrEmpty() ? null : (int?)row["expire_time"].ParseToInt(),
|
||||
//mdy_time = row["mdy_time"].IsNullOrEmpty() ? DateTime.MinValue : Convert.ToDateTime(row["mdy_time"]),
|
||||
expire_time = row["expire_time"].ParseToInt(),
|
||||
};
|
||||
if (shop.shop_id == "wx2543ce37a0009883")
|
||||
{
|
||||
var exp = row["expire_time"].ParseToString();
|
||||
}
|
||||
var expire_datetime = TimeUtils.StampToDateTime(shop.expire_time.Value);
|
||||
if (isPayUser && expire_datetime < DateTime.Now)
|
||||
shop.is_point_shop_expire = true;
|
||||
|
||||
shopList.Add(shop);
|
||||
}
|
||||
|
||||
//sql = "\r\nINSERT INTO wxxd.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 wxxd.shop set add_product_remaining=" + remainCount + ", add_product_month=" + month +
|
||||
// " where 1=1 and id in (" + ids + ");";
|
||||
|
||||
// sql += "\r\nINSERT INTO wxxd.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);
|
||||
var valid_data = JsonUtils.SerializeObjectToString(shopList);
|
||||
var all_data = JsonUtils.SerializeObjectToString(allShopList);
|
||||
var seconds = (DateTime.Now - timeCalc).TotalSeconds.ToString("0.000");
|
||||
|
||||
//return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"c\":\"" + EncrypUtil.Encryption(r2) + "\"}";
|
||||
return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"count\":" + count + ",\"seconds\":" + seconds + "}";
|
||||
return "{\"code\":200,\"msg\":\"success\",\"data\":" + valid_data + ",\"count\":" + count + ",\"seconds\":" + seconds + "}";
|
||||
}
|
||||
}
|
||||
return "{\"code\":19999,\"msg\":\"未知错误\"}";
|
||||
|
||||
@@ -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\":\"输入为空\"}";
|
||||
}
|
||||
|
||||
@@ -68,7 +68,9 @@ namespace KJD_Web.Model.ShopModel
|
||||
public string ad_login_status { get; set; }
|
||||
public DateTime? jit_expire_time { get; set; }
|
||||
public int? expire_time { get; set; }
|
||||
public DateTime? add_time { get; set; }
|
||||
public DateTime add_time { get; set; }
|
||||
//public DateTime mdy_time { get; set; }
|
||||
public bool? is_point_shop_expire { get; set; } = false;
|
||||
}
|
||||
|
||||
public class AuthInfo
|
||||
|
||||
@@ -288,6 +288,28 @@ namespace KJD_Web
|
||||
Context.Response.Write(result);
|
||||
Context.Response.End();
|
||||
}
|
||||
[WebMethod]
|
||||
public void wx_add_mdy_commission_rate()
|
||||
{
|
||||
string jsontext = GetRequestJsonString();
|
||||
|
||||
var result = jsontext;
|
||||
result = new WXProductManage().WXAddMdyCommissionRate(jsontext);
|
||||
|
||||
Context.Response.Write(result);
|
||||
Context.Response.End();
|
||||
}
|
||||
[WebMethod]
|
||||
public void wx_get_commission_rate()
|
||||
{
|
||||
string jsontext = GetRequestJsonString();
|
||||
|
||||
var result = jsontext;
|
||||
result = new WXProductManage().WXGetCommissionRate(jsontext);
|
||||
|
||||
Context.Response.Write(result);
|
||||
Context.Response.End();
|
||||
}
|
||||
|
||||
[WebMethod]
|
||||
public void e57_get_freight_template()
|
||||
|
||||
@@ -175,6 +175,18 @@ namespace KJD_Web
|
||||
Context.Response.End();
|
||||
}
|
||||
|
||||
[WebMethod]
|
||||
public void update_user_points()
|
||||
{
|
||||
string jsontext = GetRequestJsonString();
|
||||
|
||||
var result = jsontext;
|
||||
result = new WXUserManage().UpdateUserPoints(jsontext);
|
||||
|
||||
Context.Response.Write(result);
|
||||
Context.Response.End();
|
||||
}
|
||||
|
||||
[WebMethod]
|
||||
public void get_wx_sale_assistant_cookie()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user