1打包逻辑优化 2代理逻辑优化 3新的拼多多数据格式支持

This commit is contained in:
wule committed 2026-07-08 12:17:47 +08:00
1 parent f703e15f11
commit 554d1f4b4f
30 files changed
+1400 -82

No files matched your search

@@ -24,9 +24,10 @@ namespace KJD_Web.BLL.WXXD
return "{\"code\":50000,\"msg\":\"校验失败\"}";
var erp_shop_id_in = RegexUtils.GetStringQuery(ref inputData, "erp_shop_id_in")?.Replace("'", "\\'");
if (erp_shop_id_in.IsNullOrEmpty())
var erp_order_id_in = RegexUtils.GetStringQuery(ref inputData, "erp_order_id_in")?.Replace("'", "\\'");
if (erp_shop_id_in.IsNullOrEmpty() && erp_order_id_in.IsNullOrEmpty())
{
return "{\"code\":500,\"msg\":\"未指定店铺\"}";
return "{\"code\":500,\"msg\":\"未指定店铺和订单\"}";
}
var query_status = RegexUtils.GetStringQuery(ref inputData, "query_status")?.Replace("'", "\\'");
var purchase_status = RegexUtils.GetStringQuery(ref inputData, "purchase_status")?.Replace("'", "\\'");
@@ -46,6 +47,8 @@ namespace KJD_Web.BLL.WXXD
string where = "";
if (!string.IsNullOrWhiteSpace(erp_shop_id_in))
where += " and o.shop_id in (" + erp_shop_id_in + ")";
if (!string.IsNullOrWhiteSpace(erp_order_id_in))
where += " and o.order_id in ('" + erp_order_id_in.Replace(",", "','") + "')";
if (!string.IsNullOrWhiteSpace(query_status))
where += " and o.status = " + query_status;
if (!string.IsNullOrWhiteSpace(purchase_status))
@@ -825,5 +828,42 @@ namespace KJD_Web.BLL.WXXD
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string WXUpdateErpSoftRemark(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
if (!WXUserManage.GetSign(inputData))
return "{\"code\":999,\"msg\":\"校验失败\"}";
var timeCalc = DateTime.Now;
string order_id = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "order_id"))?.Replace("'", "\\'");
string soft_remark = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "soft_remark"))?.Replace("'", "\\'");
if (string.IsNullOrEmpty(order_id))
return "{\"code\":500,\"msg\":\"订单ID不能为空\"}";
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "";
var count = -1;
sql = " update `erp`.`oms_wei_order` set ";
if (!string.IsNullOrEmpty(soft_remark))
sql += " soft_remark=" + soft_remark + ",";
sql = sql.TrimEnd(',');
sql += " where order_id = '" + order_id + "';";
count = mySql.ExecuteAffectedRows(sql);
mySql.Close();
if (!string.IsNullOrEmpty(mySql.Message))
{
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\",\"affected_rows\":" + count + "}";
}
return "{\"code\":200,\"msg\":\"success\",\"affected_rows\":" + count + "}";
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
}
}
@@ -100,6 +100,8 @@ namespace KJD_Web.BLL.WXXD
forbidden_page = row.Table.Columns.Contains("forbidden_page") ? row["forbidden_page"].ParseToString() : "",
parent_user_name = row["parent_user_name"].ToString(),
points = row.Table.Columns.Contains("points") ? row["points"].ParseToInt() : 0,
balance = row.Table.Columns.Contains("balance") ? row["balance"].ParseToDecimal() : 0,
recharge_amount_total = row.Table.Columns.Contains("recharge_amount_total") ? row["recharge_amount_total"].ParseToDecimal() : 0,
shop_points_per_month = row.Table.Columns.Contains("shop_points_per_month") ? row["shop_points_per_month"].ParseToInt() : 30,
};
var main_authority = row.Table.Columns.Contains("main_authority") ? row["main_authority"].ParseToString() : "";
@@ -344,6 +346,7 @@ namespace KJD_Web.BLL.WXXD
var group_id = RegexUtils.GetStringQuery(ref inputData, "group_id")?.Replace("'", "\\'");
var search = RegexUtils.GetStringQuery(ref inputData, "search")?.Replace("'", "\\'");
var sa_level = RegexUtils.GetStringQuery(ref inputData, "sa_level")?.Replace("'", "\\'");
var user_name_in = RegexUtils.GetStringQuery(ref inputData, "user_name_in")?.Replace("'", "\\'");
var search_user_name = RegexUtils.GetStringQuery(ref inputData, "search_user_name")?.Replace("'", "\\'");
var search_nick_name = RegexUtils.GetStringQuery(ref inputData, "search_nick_name")?.Replace("'", "\\'");
var search_company_name = RegexUtils.GetStringQuery(ref inputData, "search_company_name")?.Replace("'", "\\'");
@@ -362,6 +365,8 @@ namespace KJD_Web.BLL.WXXD
where += " AND u.group_id=" + group_id;
if (!string.IsNullOrEmpty(sa_level))
where += " AND u.sa_level=" + sa_level;
if (!string.IsNullOrEmpty(user_name_in))
where += " AND u.user_name in ('" + user_name_in.Replace(",", "','") + "')";
if (!string.IsNullOrEmpty(search_user_name))
where += " AND u.user_name like '%" + search_user_name + "%'";
if (!string.IsNullOrEmpty(search_nick_name))
@@ -424,6 +429,8 @@ namespace KJD_Web.BLL.WXXD
authority = row.Table.Columns.Contains("authority") ? row["authority"].ParseToString() : "",
forbidden_page = row.Table.Columns.Contains("forbidden_page") ? row["forbidden_page"].ParseToString() : "",
points = row.Table.Columns.Contains("points") ? row["points"].ParseToInt() : 0,
balance = row.Table.Columns.Contains("balance") ? row["balance"].ParseToDecimal() : 0,
recharge_amount_total = row.Table.Columns.Contains("recharge_amount_total") ? row["recharge_amount_total"].ParseToDecimal() : 0,
shop_points_per_month = row.Table.Columns.Contains("shop_points_per_month") ? row["shop_points_per_month"].ParseToInt() : 30,
};
var main_authority = row.Table.Columns.Contains("main_authority") ? row["main_authority"].ParseToString() : "";
@@ -821,6 +828,215 @@ namespace KJD_Web.BLL.WXXD
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
/// <summary>
/// 增加或减少用户积分
/// </summary>
/// <param name="inputData"></param>
/// <returns></returns>
public string UpdateUserBalance(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
if (!GetSign(inputData))
return "{\"code\":999,\"msg\":\"校验失败\"}";
var user_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "update_user_name"))?.Replace("'", "\\'");
var user_nick = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "update_user_nick"))?.Replace("'", "\\'");
var delta_balance = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "delta_balance")).ParseToDecimal();
var option_type = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "option_type"))?.Replace("'", "\\'");
var operator_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "operator_name"))?.Replace("'", "\\'");
if (string.IsNullOrEmpty(user_name) || string.IsNullOrEmpty(user_nick))
{
return "{\"code\":500,\"msg\":\"操作对象不能为空\"}";
}
if (delta_balance <= 0 && option_type == "消费")
{
return "{\"code\":500,\"msg\":\"消费金额错误,需大于0\"}";
}
if (delta_balance == 0)
{
return "{\"code\":500,\"msg\":\"操作金额错误,不能等于0\"}";
}
if (string.IsNullOrEmpty(option_type) || string.IsNullOrEmpty(operator_name))
{
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, true);
string sql;
decimal balance = 0;
decimal recharge_amount_total = 0;
decimal newBalance = 0;
decimal newRechargeAmountTotal = 0;
int shopPointsPerMonth = 30;
#region 计算是否余额不足
sql = "SELECT balance,recharge_amount_total FROM `wxxd`.`user` WHERE user_name='" + user_name + "'";
var dataRow = mySql.ExecuteDataTableRow(sql);
if (!string.IsNullOrEmpty(mySql.Message))
{
mySql.RollBack();
mySql.Close();
return "{\"code\":501,\"msg\":\"" + mySql.Message + "\"}";
}
if (dataRow == null)
{
mySql.RollBack();
mySql.Close();
return "{\"code\":501,\"msg\":\"用户不存在\"}";
}
try
{
balance = dataRow["balance"].ParseToDecimal();
newBalance = balance;
recharge_amount_total = dataRow["recharge_amount_total"].ParseToDecimal();
newRechargeAmountTotal = recharge_amount_total;
}
catch
{
}
//if (option_type == "消费")
//{
// sql = "SELECT shop_points_per_month FROM `wxxd`.`user` WHERE user_name='" + user_name + "'";
// shopPointsPerMonth = mySql.ExecuteFirstInt(sql); // 店铺消费一个月的点数,默认30,可以设置为其他值
// if (!string.IsNullOrEmpty(mySql.Message))
// {
// mySql.RollBack();
// mySql.Close();
// return "{\"code\":501,\"msg\":\"" + mySql.Message + "\"}";
// }
// shopPointsPerMonth = Math.Max(30, shopPointsPerMonth);
// if (delta_balance <= 0 || delta_balance % shopPointsPerMonth > 0)
// {
// mySql.RollBack();
// mySql.Close();
// return "{\"code\":501,\"msg\":\"消费点数必须是" + shopPointsPerMonth + "的整倍数\"}";
// }
// else if (balance < delta_balance)
// {
// mySql.RollBack();
// mySql.Close();
// return "{\"code\":500,\"msg\":\"余额不足\"}";
// }
//}
#endregion
sql = "UPDATE `wxxd`.`user` SET";
if (option_type == "充值")
{
newBalance = balance + delta_balance;
sql += " balance=" + newBalance + ",";
newRechargeAmountTotal = recharge_amount_total + delta_balance;
sql += " recharge_amount_total=" + newRechargeAmountTotal + ",";
}
else
{
newBalance = balance - delta_balance.ParseToInt();
sql += " balance=" + newBalance + ",";
}
sql = sql.TrimEnd(',');
sql += " WHERE user_name='" + user_name + "' AND balance=" + balance + " AND recharge_amount_total=" + recharge_amount_total + ";";
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\":\"" + option_type + "失败,账户余额已发生改变,请刷新账户后重新操作\"}";
}
sql = " INSERT INTO wxxd.user_payment_record(type,amount,balance,user_name,create_by,create_time,update_by,update_time,counterparty_account_name)";
sql += " VALUES(@type,@amount,@balance,@user_name,@create_by,@create_time,@update_by,@update_time,@counterparty_account_name);";
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.Decimal, ParameterName = "amount", Value = delta_balance, });
paramLst.Add(new MySqlParameter() { DbType = DbType.Decimal, ParameterName = "balance", Value = newBalance, });
paramLst.Add(new MySqlParameter() { DbType = DbType.Int32, ParameterName = "type", Value = option_type == "充值" ? 1 : 0, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "create_by", Value = operator_name, });
paramLst.Add(new MySqlParameter() { DbType = DbType.DateTime, ParameterName = "create_time", Value = DateTime.Now, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "update_by", Value = operator_name, });
paramLst.Add(new MySqlParameter() { DbType = DbType.DateTime, ParameterName = "update_time", Value = DateTime.Now, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "counterparty_account_name", Value = operator_name, });
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_balance.ParseToInt() / shopPointsPerMonth));
// 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_balance.ParseToInt() / shopPointsPerMonth);
// else
// expireDateTime = expireDateTime.AddMonths(delta_balance.ParseToInt() / shopPointsPerMonth);
// 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();
return "{\"code\":200,\"msg\":\"success\",\"newRechargeAmountTotal\":" + newRechargeAmountTotal + ",\"newBalance\":" + newBalance + "}";
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string ChangePassword(string inputData)
{
if (!GetSign(inputData))
@@ -135,6 +135,7 @@
<Compile Include="Model\WxModel\oms_wei_order.cs" />
<Compile Include="Model\WxModel\oms_wei_order_item.cs" />
<Compile Include="Model\WxModel\oms_wei_refund.cs" />
<Compile Include="Model\WxModel\user_payment_record.cs" />
<Compile Include="Model\WxModel\WXBuyUrlNotesInfo.cs" />
<Compile Include="Model\WxModel\WXClientProductInfoLite.cs" />
<Compile Include="Model\WxModel\WXGetEditProductInfoLite.cs" />
@@ -70,6 +70,8 @@ namespace KJD_Web.Model
/// 用户积分点数
/// </summary>
public int points { get; set; }
public decimal balance { get; set; }
public decimal recharge_amount_total { get; set; }
/// <summary>
/// 单店铺续费1个月消耗的点数
/// </summary>
@@ -0,0 +1,66 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace KJD_Web.Model.WxModel
{
public class user_payment_record
{
public long id { get; set; }
public int? type { get; set; }
/// <summary>
/// 充值或花费的金额(元)
/// </summary>
public decimal amount { get; set; }
/// <summary>
/// 充值或花费后的当前账户余额(元)
/// </summary>
public decimal balance { get; set; }
/// <summary>
/// 账户名
/// </summary>
public string user_name { get; set; }
/// <summary>
/// 平台编码
/// </summary>
public string platform_code { get; set; }
/// <summary>
/// 订单id
/// </summary>
public string order_id { get; set; }
/// <summary>
/// 售后单id
/// </summary>
public long? after_sale_id { get; set; }
/// <summary>
/// 创建人
/// </summary>
public string create_by { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime create_time { get; set; }
/// <summary>
/// 修改人
/// </summary>
public string update_by { get; set; }
/// <summary>
/// 修改时间
/// </summary>
public DateTime update_time { get; set; }
/// <summary>
/// 是否已删除
/// </summary>
public int? is_deleted { get; set; }
/// <summary>
/// 备注
/// </summary>
public string remark { get; set; }
/// <summary>
/// 扣款的对方账户名称
/// </summary>
public string counterparty_account_name { get; set; }
}
}
@@ -49,6 +49,11 @@ namespace KJD_Web
}
}
[WebMethod]
public void get_erp_order_list()
{
get_order_list();
}
[WebMethod]
public void get_order_list()
{
@@ -61,8 +66,11 @@ namespace KJD_Web
Context.Response.End();
}
[WebMethod]
public void get_erp_order_item_list()
{
get_order_item_list();
}
[WebMethod]
public void get_order_item_list()
{
@@ -75,6 +83,11 @@ namespace KJD_Web
Context.Response.End();
}
[WebMethod]
public void get_erp_refund_list()
{
get_refund_list();
}
[WebMethod]
public void get_refund_list()
{
@@ -142,7 +155,7 @@ namespace KJD_Web
Context.Response.End();
}
/// <summary>
/// 修改中转仓取号状态
/// 修改中转仓取号状态 临时补救
/// </summary>
[WebMethod]
public void wx_update_erp_allocated_order_no()
@@ -155,5 +168,18 @@ namespace KJD_Web
Context.Response.Write(result);
Context.Response.End();
}
[WebMethod]
public void wx_update_erp_soft_remark()
{
string jsontext = GetRequestJsonString();
var result = jsontext;
result = new WXOrderManage().WXUpdateErpSoftRemark(jsontext);
Context.Response.Write(result);
Context.Response.End();
}
}
}
@@ -186,6 +186,18 @@ namespace KJD_Web
Context.Response.Write(result);
Context.Response.End();
}
[WebMethod]
public void update_user_balance()
{
string jsontext = GetRequestJsonString();
var result = jsontext;
result = new WXUserManage().UpdateUserBalance(jsontext);
Context.Response.Write(result);
Context.Response.End();
}
[WebMethod]
public void get_wx_sale_assistant_cookie()