微信小店地址管理

This commit is contained in:
wule committed 2026-05-02 10:15:04 +08:00
1 parent 0c5ebf421e
commit 5ac8eb2571
29 files changed
+1489 -378

No files matched your search

@@ -683,180 +683,6 @@ namespace KJD_Web.BLL.WXXD
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string WXAddMdyShopDefaultAfterSale(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
if (!WXUserManage.GetSign(inputData))
return "{\"code\":999,\"msg\":\"校验失败\"}";
// 软件用户名
string user_id = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "user_name"))?.Replace("'", "\\'");
string shop_id = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "shop_id"))?.Replace("'", "\\'");
string province_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "province_name"))?.Replace("'", "\\'");
string city_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "city_name"))?.Replace("'", "\\'");
string county_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "county_name"))?.Replace("'", "\\'");
string detail_info = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "detail_info"))?.Replace("'", "\\'");
string tel_number = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "tel_number"))?.Replace("'", "\\'");
// 收件人
string user_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "receiver"))?.Replace("'", "\\'");
if (string.IsNullOrEmpty("user_id"))
return "{\"code\":500,\"msg\":\"缺少用户编号\"}";
if (string.IsNullOrEmpty("after_sale_json"))
return "{\"code\":500,\"msg\":\"缺少店铺编号\"}";
if (string.IsNullOrEmpty("province_name") || string.IsNullOrEmpty("city_name") || string.IsNullOrEmpty("county_name") || string.IsNullOrEmpty("detail_info"))
return "{\"code\":500,\"msg\":\"省市区或详细地址不完整\"}";
if (string.IsNullOrEmpty("user_name"))
return "{\"code\":500,\"msg\":\"缺少收件人\"}";
if (string.IsNullOrEmpty("tel_number"))
return "{\"code\":500,\"msg\":\"缺少收件人电话\"}";
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "SELECT 1 FROM `wxxd`.`wx_shop_default_address` where user_id='" + user_id + "' AND shop_id='" + shop_id + "'";
string where = "";
sql += where;
var exist = mySql.ExecuteFirstInt(sql);
if (!mySql.Message.IsNullOrEmpty())
{
mySql.Close();
return "{\"code\":501,\"msg\":\"" + mySql.Message + "\"}";
}
if (exist == 0)
{
sql = " INSERT INTO `wxxd`.`wx_shop_default_address` (user_id,shop_id,province_name,city_name,county_name,detail_info,tel_number,user_name)" +
" VALUES (@user_id,@shop_id,@province_name,@city_name,@county_name,@detail_info,@tel_number,@user_name);";
}
else
{
sql = "UPDATE `wxxd`.`wx_shop_default_address` SET ";
if (province_name != null)
sql += " province_name=@province_name,";
if (city_name != null)
sql += " city_name=@city_name,";
if (county_name != null)
sql += " county_name=@county_name,";
if (detail_info != null)
sql += " detail_info=@detail_info,";
if (tel_number != null)
sql += " tel_number=@tel_number,";
if (user_name != null)
sql += " user_name=@user_name,";
sql = sql.TrimEnd(',');
sql += " WHERE user_id=@user_id and shop_id=@shop_id;";
}
List<MySqlParameter> paramLst = new List<MySqlParameter>();
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "province_name", Value = province_name, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "city_name", Value = city_name, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "county_name", Value = county_name, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "detail_info", Value = detail_info, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "tel_number", Value = tel_number, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "user_name", Value = user_name, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "user_id", Value = user_id, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "shop_id", Value = shop_id, });
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\":\"\"}";
}
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string WXGetShopDefaultAfterSaleList(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
var timeCalc = DateTime.Now;
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(200);
string user_id = RegexUtils.GetStringQuery(ref inputData, "user_name")?.Replace("'", "\\'");
string shop_ids = RegexUtils.GetStringQuery(ref inputData, "shop_ids")?.Replace("'", "\\'");
string not_count = RegexUtils.GetStringQuery(ref inputData, "not_count")?.Replace("'", "\\'");
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "";
var count = 0;
sql = "SELECT count(*) FROM `wxxd`.`wx_shop_default_address` where 1=1";
string where = "";
if (user_id != null)
where += " and user_id='" + user_id + "'";
if (shop_ids != null)
where += " and shop_ids IN ('" + shop_ids.Replace(",", "','") + "')";
sql += where;
sql += ";";
if (not_count != "true")
count = mySql.ExecuteRowCount(sql);
DataTable dt;
if (count == 0 && not_count != "true")
{
dt = new DataTable();
}
else
{
sql = "SELECT * FROM `wxxd`.`wx_shop_default_address` where 1=1";
sql += where;
sql += " order by id desc limit " + Math.Max(0, page - 1) * page_size + "," + page_size + ";";
dt = mySql.ExecuteDataTable(sql);
}
mySql.Close();
if (dt != null)
{
try
{
List<WXShopDefaultAddressInfo> WXShopDefaultAddressInfoLst = new List<WXShopDefaultAddressInfo>();
foreach (DataRow row in dt.Rows)
{
WXShopDefaultAddressInfoLst.Add(new WXShopDefaultAddressInfo()
{
id = row["id"].ParseToInt(),
city_name = row["city_name"].ParseToString(),
county_name = row["county_name"].ParseToString(),
detail_info = row["detail_info"].ParseToString(),
province_name = row["province_name"].ParseToString(),
shop_id = row["shop_id"].ParseToString(),
tel_number = row["tel_number"].ParseToString(),
user_id = row["user_id"].ParseToString(),
user_name = row["user_name"].ParseToString(),
add_time = Convert.ToDateTime(row["add_time"]),
mdy_time = Convert.ToDateTime(row["mdy_time"]),
});
}
JsonSerializerSettings jsonSetting = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore };
var data = JsonUtils.SerializeObjectToString(WXShopDefaultAddressInfoLst, jsonSetting);
var seconds = (DateTime.Now - timeCalc).TotalSeconds.ToString("0.000");
return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"count\":" + count + ",\"seconds\":" + seconds + "}";
}
catch (Exception ex)
{
return "{\"code\":500,\"msg\":\"" + ex.Message + "\",\"data\":[],\"count\":" + 0 + "}";
}
}
else
{
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\",\"data\":[],\"count\":" + 0 + "}";
}
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string WXAddMdyAfterSale(string inputData)
{
@@ -1,14 +1,17 @@
using KJD_Web.Model;
using KJD_Web.Model.ShopModel;
using KJD_Web.Utils;
using MySql.Data.MySqlClient;
using MySqlX.XDevAPI;
using NaiBa.Util.Extension;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Security.Cryptography;
using System.Web;
using System.Web.Security;
@@ -784,6 +787,219 @@ namespace KJD_Web.BLL.WXXD
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string WXAddMdyShopDefaultAddress(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
if (!WXUserManage.GetSign(inputData))
return "{\"code\":999,\"msg\":\"校验失败\"}";
// 软件用户名
string user_id = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "user_name"))?.Replace("'", "\\'");
string shop_id = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "shop_id"))?.Replace("'", "\\'");
string province_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "province_name"))?.Replace("'", "\\'");
string city_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "city_name"))?.Replace("'", "\\'");
string county_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "county_name"))?.Replace("'", "\\'");
string detail_info = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "detail_info"))?.Replace("'", "\\'");
string tel_number = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "tel_number"))?.Replace("'", "\\'");
// 收件人
string user_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "receiver"))?.Replace("'", "\\'");
if (string.IsNullOrEmpty("user_id"))
return "{\"code\":500,\"msg\":\"缺少用户编号\"}";
if (string.IsNullOrEmpty("after_sale_json"))
return "{\"code\":500,\"msg\":\"缺少店铺编号\"}";
if (string.IsNullOrEmpty("province_name") || string.IsNullOrEmpty("city_name") || string.IsNullOrEmpty("county_name") || string.IsNullOrEmpty("detail_info"))
return "{\"code\":500,\"msg\":\"省市区或详细地址不完整\"}";
if (string.IsNullOrEmpty("user_name"))
return "{\"code\":500,\"msg\":\"缺少收件人\"}";
if (string.IsNullOrEmpty("tel_number"))
return "{\"code\":500,\"msg\":\"缺少收件人电话\"}";
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "SELECT 1 FROM `wxxd`.`wx_shop_default_address` where user_id='" + user_id + "' AND shop_id='" + shop_id + "'";
string where = "";
sql += where;
var exist = mySql.ExecuteFirstInt(sql);
if (!mySql.Message.IsNullOrEmpty())
{
mySql.Close();
return "{\"code\":501,\"msg\":\"" + mySql.Message + "\"}";
}
if (exist == 0)
{
sql = " INSERT INTO `wxxd`.`wx_shop_default_address` (user_id,shop_id,province_name,city_name,county_name,detail_info,tel_number,user_name)" +
" VALUES (@user_id,@shop_id,@province_name,@city_name,@county_name,@detail_info,@tel_number,@user_name);";
}
else
{
sql = "UPDATE `wxxd`.`wx_shop_default_address` SET ";
if (province_name != null)
sql += " province_name=@province_name,";
if (city_name != null)
sql += " city_name=@city_name,";
if (county_name != null)
sql += " county_name=@county_name,";
if (detail_info != null)
sql += " detail_info=@detail_info,";
if (tel_number != null)
sql += " tel_number=@tel_number,";
if (user_name != null)
sql += " user_name=@user_name,";
sql = sql.TrimEnd(',');
sql += " WHERE user_id=@user_id and shop_id=@shop_id;";
}
List<MySqlParameter> paramLst = new List<MySqlParameter>();
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "province_name", Value = province_name, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "city_name", Value = city_name, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "county_name", Value = county_name, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "detail_info", Value = detail_info, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "tel_number", Value = tel_number, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "user_name", Value = user_name, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "user_id", Value = user_id, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "shop_id", Value = shop_id, });
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\":\"\"}";
}
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string WXGetShopDefaultAddressList(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
var timeCalc = DateTime.Now;
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(200);
string user_id = RegexUtils.GetStringQuery(ref inputData, "user_name")?.Replace("'", "\\'");
string shop_ids = RegexUtils.GetStringQuery(ref inputData, "shop_ids")?.Replace("'", "\\'");
string not_count = RegexUtils.GetStringQuery(ref inputData, "not_count")?.Replace("'", "\\'");
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "";
var count = -1;
sql = "SELECT count(*) FROM `wxxd`.`wx_shop_default_address` where 1=1";
string where = "";
if (user_id != null)
where += " and user_id='" + user_id + "'";
if (shop_ids != null)
where += " and shop_id IN ('" + shop_ids.Replace(",", "','") + "')";
sql += where;
sql += ";";
if (not_count != "true")
count = mySql.ExecuteRowCount(sql);
DataTable dt;
if (count == 0)
{
dt = new DataTable();
}
else
{
sql = "SELECT * FROM `wxxd`.`wx_shop_default_address` where 1=1";
sql += where;
sql += " order by id desc limit " + Math.Max(0, page - 1) * page_size + "," + page_size + ";";
dt = mySql.ExecuteDataTable(sql);
}
mySql.Close();
if (dt != null)
{
try
{
List<WXShopDefaultAddressInfo> WXShopDefaultAddressInfoLst = new List<WXShopDefaultAddressInfo>();
foreach (DataRow row in dt.Rows)
{
WXShopDefaultAddressInfoLst.Add(new WXShopDefaultAddressInfo()
{
id = row["id"].ParseToInt(),
city_name = row["city_name"].ParseToString(),
county_name = row["county_name"].ParseToString(),
detail_info = row["detail_info"].ParseToString(),
province_name = row["province_name"].ParseToString(),
shop_id = row["shop_id"].ParseToString(),
tel_number = row["tel_number"].ParseToString(),
user_id = row["user_id"].ParseToString(),
user_name = row["user_name"].ParseToString(),
add_time = Convert.ToDateTime(row["add_time"]),
mdy_time = Convert.ToDateTime(row["mdy_time"]),
});
}
JsonSerializerSettings jsonSetting = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore };
var data = JsonUtils.SerializeObjectToString(WXShopDefaultAddressInfoLst, jsonSetting);
var seconds = (DateTime.Now - timeCalc).TotalSeconds.ToString("0.000");
return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"count\":" + count + ",\"seconds\":" + seconds + "}";
}
catch (Exception ex)
{
return "{\"code\":500,\"msg\":\"" + ex.Message + "\",\"data\":[],\"count\":" + 0 + "}";
}
}
else
{
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\",\"data\":[],\"count\":" + 0 + "}";
}
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string WXDelShopDefaultAddress(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
var timeCalc = DateTime.Now;
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(200);
string user_id = RegexUtils.GetStringQuery(ref inputData, "user_name")?.Replace("'", "\\'");
string shop_ids = RegexUtils.GetStringQuery(ref inputData, "shop_ids")?.Replace("'", "\\'");
if (shop_ids.IsNullOrEmpty() || user_id.IsNullOrEmpty())
{
return "{\"code\":500,\"msg\":\"店铺编号不能为空\"}";
}
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "";
sql = "Delete FROM `wxxd`.`wx_shop_default_address` where user_id = '" + user_id + "' AND shop_id in ('" + shop_ids.Replace(",", "','") + "')";
sql += ";";
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 E57GetWxTokens(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
@@ -8,7 +8,7 @@
<IISExpressWindowsAuthentication />
<IISExpressUseClassicPipelineMode />
<UseGlobalApplicationHostFile />
<LastActiveSolutionConfig>Debug|Any CPU</LastActiveSolutionConfig>
<LastActiveSolutionConfig>Release|Any CPU</LastActiveSolutionConfig>
<ProjectView>ShowAllFiles</ProjectView>
</PropertyGroup>
<ProjectExtensions>
@@ -197,29 +197,6 @@ namespace KJD_Web
Context.Response.End();
}
[WebMethod]
public void wx_add_mdy_shop_default_after_sale()
{
string jsontext = GetRequestJsonString();
var result = jsontext;
result = new WXProductManage().WXAddMdyShopDefaultAfterSale(jsontext);
Context.Response.Write(result);
Context.Response.End();
}
[WebMethod]
public void wx_get_shop_default_after_sale_list()
{
string jsontext = GetRequestJsonString();
var result = jsontext;
result = new WXProductManage().WXGetShopDefaultAfterSaleList(jsontext);
Context.Response.Write(result);
Context.Response.End();
}
[WebMethod]
public void wx_add_mdy_after_sale()
{
@@ -311,6 +311,47 @@ namespace KJD_Web
Context.Response.End();
}
/// <summary>
/// 修改店铺默认(售后)地址
/// </summary>
[WebMethod]
public void wx_add_mdy_shop_default_address()
{
string jsontext = GetRequestJsonString();
var result = jsontext;
result = new WXShopManage().WXAddMdyShopDefaultAddress(jsontext);
Context.Response.Write(result);
Context.Response.End();
}
/// <summary>
/// 查询店铺默认(售后)地址
/// </summary>
[WebMethod]
public void wx_get_shop_default_address_list()
{
string jsontext = GetRequestJsonString();
var result = jsontext;
result = new WXShopManage().WXGetShopDefaultAddressList(jsontext);
Context.Response.Write(result);
Context.Response.End();
}
[WebMethod]
public void wx_del_shop_default_address()
{
string jsontext = GetRequestJsonString();
var result = jsontext;
result = new WXShopManage().WXDelShopDefaultAddress(jsontext);
Context.Response.Write(result);
Context.Response.End();
}
[WebMethod]
public void e57_get_wx_tokens()
{