Files
KJD_WebService/KJDService/KJD_WebService/BLL/WXXD/WXProductManage.cs
T

1329 lines
68 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using KJD_Web.Model;
using KJD_Web.Model.ShopModel;
using KJD_Web.Utils;
using MySql.Data.MySqlClient;
using Mysqlx.Crud;
using NaiBa.Util.Extension;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Threading;
using System.Web;
using System.Web.Security;
using System.Web.UI.HtmlControls;
namespace KJD_Web.BLL.WXXD
{
public class WXProductManage
{
public string WXGetPDDProductList(string inputData, bool isDetail = false)
{
return new BLL.BXX.BXXProductManage().GetProductList(inputData, isDetail);
//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("'","\\'");
// var password = RegexUtils.GetStringQuery(ref inputData, "password")?.Replace("'", "\\'");
// var search_spu = RegexUtils.GetStringQuery(ref inputData, "search_spu")?.Replace("'", "\\'");
// var search_skc = RegexUtils.GetStringQuery(ref inputData, "search_skc")?.Replace("'", "\\'");
// var search_cat = RegexUtils.GetStringQuery(ref inputData, "search_cat")?.Replace("'", "\\'");
// var search_ext_code = RegexUtils.GetStringQuery(ref inputData, "search_ext_code")?.Replace("'", "\\'");
// var search_prod_name = RegexUtils.GetStringQuery(ref inputData, "search_prod_name")?.Replace("'", "\\'");
// var search_group = RegexUtils.GetStringQuery(ref inputData, "search_group")?.Replace("'", "\\'");
// var search_notes = RegexUtils.GetStringQuery(ref inputData, "search_notes")?.Replace("'", "\\'");
// var search_db_ids = RegexUtils.GetStringQuery(ref inputData, "search_db_ids")?.Replace("'", "\\'");
// var get_select_count = RegexUtils.GetStringQuery(ref inputData, "get_select_count")?.Replace("'", "\\'");
// var select_shop_id = RegexUtils.GetStringQuery(ref inputData, "select_shop_id")?.Replace("'", "\\'");
// var from_shop_id = RegexUtils.GetStringQuery(ref inputData, "from_shop_id")?.Replace("'", "\\'");
// var sort_field = RegexUtils.GetStringQuery(ref inputData, "sort_field")?.Replace("'", "\\'");
// int page = RegexUtils.GetStringQuery(ref inputData, "page").ParseToInt();
// int page_size= RegexUtils.GetStringQuery(ref inputData, "page_size").ParseToInt(50);
// string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
// MysqlUtils mySql = new MysqlUtils(conn);
// string sql = "select count(id) from bxx.product p where p.is_del=0";
// string where = "";
// if (!string.IsNullOrWhiteSpace(search_spu))
// where += " and p.spu_id like '%" + search_spu + "%'";
// if (!string.IsNullOrWhiteSpace(search_skc))
// where += " and p.skc_id like '%" + search_skc + "%'";
// if (!string.IsNullOrWhiteSpace(search_cat))
// where += " and p.cat_name like '%" + search_cat + "%'";
// if (!string.IsNullOrWhiteSpace(search_ext_code))
// where += " and p.ext_code like '%" + search_ext_code + "%'";
// if (!string.IsNullOrWhiteSpace(search_prod_name))
// where += " and p.product_name like '%" + search_prod_name + "%'";
// if (!string.IsNullOrWhiteSpace(search_group))
// where += " and p.group like '%" + search_group + "%'";
// if (!string.IsNullOrWhiteSpace(search_notes))
// where += " and p.notes like '%" + search_notes + "%'";
// if (!string.IsNullOrEmpty(from_shop_id))
// where += " and p.from_shop_id ='" + from_shop_id + "'";
// if (!string.IsNullOrEmpty(search_db_ids))
// where += " and p.id in (" + search_db_ids + ")";
// sql += where;
// var count = mySql.ExecuteRowCount(sql);
// DataTable dt;
// if (count == 0)
// {
// dt = new DataTable();
// }
// else
// {
// if (isDetail)
// sql = "select p.*,s.img_base64,s.img_url,e.ext_code_price from bxx.product p" +
// " left join bxx.sku_img_replace s ON p.sku_img_replace_id=s.id" +
// " LEFT JOIN bxx.ext_code_price e ON p.ext_code=e.ext_code" +
// " where p.is_del=0";
// else if (string.IsNullOrEmpty(get_select_count))
// sql = "select p.id,p.from_shop_id,p.spu_id,p.skc_id,p.main_cat_id,p.main_cat_name,p.cat_id,p.cat_name,p.price_text,p.ext_code,p.product_name,p.main_img,p.notes," +
// " p.add_time,p.mdy_time,p.select_total_count,p.fission_words,p.head_words,p.end_words,p.sku_img_replace_id,p.group,p.product_get_type,s.img_url,e.ext_code_price" +
// " FROM bxx.product p " +
// " left join bxx.sku_img_replace s ON p.sku_img_replace_id=s.id" +
// " LEFT JOIN bxx.ext_code_price e ON p.ext_code=e.ext_code" +
// " where p.is_del=0";
// else
// sql = "SELECT p.id,p.from_shop_id,p.spu_id,p.skc_id,p.main_cat_id,p.main_cat_name,p.cat_id,p.cat_name,p.price_text,p.ext_code,p.product_name,p.main_img,p.notes," +
// " p.add_time,p.mdy_time,p.select_total_count,p.fission_words,p.head_words,p.end_words,p.sku_img_replace_id,p.group,p.product_get_type,s.img_url,COUNT(se.id) AS select_count," +
// " e.ext_code_price" +
// " FROM bxx.product p left join bxx.sku_img_replace s ON p.sku_img_replace_id=s.id LEFT JOIN bxx.product_select se ON p.id=se.out_product_id AND se.shop_id='" + select_shop_id + "' " +
// " LEFT JOIN bxx.ext_code_price e ON p.ext_code=e.ext_code" +
// " WHERE p.is_del=0";
// //where子句
// sql += where;
// if (!isDetail && !string.IsNullOrEmpty(get_select_count))
// sql += " group by p.id";
// if (sort_field == "select_total_count")
// sql += " order by p.select_total_count desc, p.id desc";
// else
// sql += " order by p.id desc";
// sql += " limit " + Math.Max(page - 1, 0) * page_size + "," + page_size;
// dt = mySql.ExecuteDataTable(sql);
// }
// mySql.Close();
// if (dt != null)
// {
// try
// {
// List<DBProductResultParam> productLst = new List<DBProductResultParam>();
// foreach (DataRow row in dt.Rows)
// {
// DBProductResultParam prod = new DBProductResultParam
// {
// id = Convert.ToInt32(row["id"]),
// from_shop_id = row["from_shop_id"].ToString(),
// skc_id = row["skc_id"].ToString(),
// spu_id = row["spu_id"].ToString(),
// cat_id = row["cat_id"].ToString(),
// cat_name = row["cat_name"].ToString(),
// product_name = row["product_name"].ToString(),
// main_img = row["main_img"].ToString(),
// ext_code = row["ext_code"].ToString(),
// ext_code_price = row["ext_code_price"].IsNullOrEmpty() ? new int?() : row["ext_code_price"].ParseToInt(),
// price_text = row["price_text"].ToString(),
// //product_json = row["product_json"].ToString(),
// //size_json = row["size_json"].ToString(),
// add_time = Convert.ToDateTime(row["add_time"]),
// mdy_time = Convert.ToDateTime(row["mdy_time"]),
// notes = row["notes"].ToString(),
// group = row["group"].ToString(),
// select_total_count = row["select_total_count"].ParseToInt(),
// end_words = row["end_words"].ParseToString(),
// fission_words = row["fission_words"].ParseToString(),
// head_words = row["head_words"].ParseToString(),
// sku_img_replace_id = row["sku_img_replace_id"].ParseToInt(),
// sku_img_replace_url = row["img_url"].ToString(),
// product_get_type_text = row["product_get_type"].ToString(),
// };
// if (isDetail)
// {
// prod.product_json = row["product_json"].ToString();
// prod.size_json = row["size_json"].ToString();
// prod.sku_edit_json = row["sku_edit_json"].ToString();
// prod.sku_img_replace_base64 = row["img_base64"].ToString();
// //prod.sku_img_replace_url = row["img_url"].ToString();
// }
// if (!string.IsNullOrEmpty(get_select_count))
// {
// prod.select_count = row["select_count"].ParseToInt();
// }
// productLst.Add(prod);
// }
// var data = JsonUtils.SerializerObjectToString(productLst);
// return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"count\":" + count + "}";
// }
// 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 WXGetPDDProductGroups(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\":\"没有用户名\"}";
}
int page = RegexUtils.GetStringQuery(ref inputData, "page").ParseToInt();
int page_size = RegexUtils.GetStringQuery(ref inputData, "page_size").ParseToInt(50);
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "SELECT DISTINCT p.group FROM `bxx`.`product` p where p.is_del=0";
string where = "";
sql += where;
var dt = mySql.ExecuteDataTable(sql);
mySql.Close();
if (dt != null)
{
try
{
string group_data = "";
foreach (DataRow row in dt.Rows)
{
group_data += row["group"].ToString() + ",";
}
var data = group_data.Trim(',');
return "{\"code\":200,\"msg\":\"success\",\"data\":\"" + data + "\"}";
}
catch (Exception ex)
{
return "{\"code\":50002,\"msg\":\"" + ex.Message + "\",\"data\":\"\"}";
}
}
else
{
return "{\"code\":50003,\"msg\":\"" + mySql.Message + "\",\"data\":\"\"}";
}
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string WXGetPDDProductCates(string inputData)
{
return new BXX.BXXProductManage().GetProductMainCates(inputData);
}
/// <summary>
/// 随机获取商品(无详情) 随机添加到上传列表所以不需要获取详情
/// </summary>
/// <param name="inputData"></param>
/// <returns></returns>
public string WXGetPDDProductListRandom(string inputData)
{
return new BXX.BXXProductManage().GetProductListRandom(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("'", "\\'");
var password = RegexUtils.GetStringQuery(ref inputData, "password")?.Replace("'", "\\'");
var in_ext_codes = RegexUtils.GetStringQuery(ref inputData, "in_ext_codes")?.Replace("'", "\\'");
var in_skc_ids = RegexUtils.GetStringQuery(ref inputData, "in_skc_ids")?.Replace("'", "\\'");
var in_groups = RegexUtils.GetStringQuery(ref inputData, "in_groups")?.Replace("'", "\\'");
var in_cates = RegexUtils.GetStringQuery(ref inputData, "in_cates")?.Replace("'", "\\'");
int page = RegexUtils.GetStringQuery(ref inputData, "page").ParseToInt();
int page_size = RegexUtils.GetStringQuery(ref inputData, "page_size").ParseToInt(50);
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "select count(id) from bxx.product p where p.is_del=0";
string where = "";
if (!string.IsNullOrEmpty(in_ext_codes))
{
in_ext_codes = "'" + string.Join("','", in_ext_codes.Split(new string[] { ",", ",", " " }, StringSplitOptions.RemoveEmptyEntries)) + "'";
where += " and p.ext_code in (" + in_ext_codes + ")";
}
if (!string.IsNullOrEmpty(in_skc_ids))
{
in_skc_ids = "'" + string.Join("','", in_skc_ids.Split(new string[] { ",", ",", " " }, StringSplitOptions.RemoveEmptyEntries)) + "'";
where += " and p.skc_id in (" + in_skc_ids + ")";
}
if (!string.IsNullOrEmpty(in_groups))
{
in_groups = "'" + string.Join("','", in_groups.Split(new string[] { ",", ",", " " }, StringSplitOptions.RemoveEmptyEntries)) + "'";
where += " and p.group in (" + in_groups + ")";
}
if (!string.IsNullOrEmpty(in_cates))
{
in_cates = "'" + string.Join("','", in_cates.Split(new string[] { ",", ",", " " }, StringSplitOptions.RemoveEmptyEntries)) + "'";
where += " and (p.cat_name in (" + in_cates + ") or p.main_cat_name in (" + in_cates + "))";
}
sql += where;
var count = mySql.ExecuteRowCount(sql);
DataTable dt;
if (count == 0)
{
dt = new DataTable();
}
else
{
sql = "select p.id,p.from_shop_id,p.spu_id,p.skc_id,p.main_cat_id,p.main_cat_name,p.cat_id,p.cat_name,p.price_text,p.ext_code," +
"p.product_name,p.main_img,p.group,p.notes,p.add_time,p.mdy_time,p.select_total_count," +
"p.fission_words,p.head_words,p.end_words from bxx.product p where p.is_del=0";
//where子句
sql += where;
sql += " ORDER BY RAND()";
sql += " limit " + Math.Max(page - 1, 0) * page_size + "," + page_size;
dt = mySql.ExecuteDataTable(sql);
}
mySql.Close();
if (dt != null)
{
try
{
List<DBProductResultParam> productLst = new List<DBProductResultParam>();
foreach (DataRow row in dt.Rows)
{
DBProductResultParam prod = new DBProductResultParam
{
id = Convert.ToInt32(row["id"]),
from_shop_id = row["from_shop_id"].ToString(),
skc_id = row["skc_id"].ToString(),
spu_id = row["spu_id"].ToString(),
cat_id = row["cat_id"].ToString(),
cat_name = row["cat_name"].ToString(),
main_cat_id = row["main_cat_id"].ToString(),
main_cat_name = row["main_cat_name"].ToString(),
price_text = row["price_text"].ToString(),
product_name = row["product_name"].ToString(),
main_img = row["main_img"].ToString(),
ext_code = row["ext_code"].ToString(),
//product_json = row["product_json"].ToString(),
//size_json = row["size_json"].ToString(),
add_time = Convert.ToDateTime(row["add_time"]),
mdy_time = Convert.ToDateTime(row["mdy_time"]),
group = row["group"].ToString(),
notes = row["notes"].ToString(),
select_total_count = row["select_total_count"].ParseToInt(),
end_words = row["end_words"].ParseToString(),
fission_words = row["fission_words"].ParseToString(),
head_words = row["head_words"].ParseToString(),
};
productLst.Add(prod);
}
var data = JsonUtils.SerializerObjectToString(productLst);
return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"count\":" + count + "}";
}
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 WXMdyPDDProduct(string inputData)
{
return new BXX.BXXProductManage().MdyProduct(inputData);
}
public string WXAddSecretSpuIdShopIdMap(string inputData)
{
return "{\"code\":500,\"msg\":\"接口已作废\"}";
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 up_secret_spu_id = RegexUtils.GetStringQuery(ref inputData, "up_secret_spu_id")?.Replace("'", "\\'");
if (string.IsNullOrEmpty(up_secret_spu_id))
{
return "{\"code\":500,\"msg\":\"缺少商品编号1\"}";
}
var index = RegexUtils.GetStringQuery(ref inputData, "index").ParseToNullableLong();
if (index == null)
index = up_secret_spu_id.ParseToLong() % 1024;
var up_spu_id = RegexUtils.GetStringQuery(ref inputData, "up_spu_id")?.Replace("'", "\\'");
if (string.IsNullOrEmpty(up_spu_id))
{
return "{\"code\":500,\"msg\":\"缺少商品编号2\"}";
}
var shop_id = RegexUtils.GetStringQuery(ref inputData, "shop_id")?.Replace("'", "\\'");
if (string.IsNullOrEmpty(shop_id))
{
return "{\"code\":500,\"msg\":\"缺少店铺编号\"}";
}
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "select id from wxxd_product_shop_map.product_shop_map_" + index.ParseToString().PadLeft(4, '0') +
" where up_secret_spu_id='" + up_secret_spu_id + "' and shop_id='" + shop_id + "';";
DataTable dt = mySql.ExecuteDataTable(sql);
if (!string.IsNullOrEmpty(mySql.Message) || dt == null || dt.Rows == null)
{
mySql.Close();
return "{\"code\":500,\"msg\":\"失败:" + mySql.Message + "\"}";
}
if (dt.Rows.Count > 0)
{
mySql.Close();
return "{\"code\":200,\"msg\":\"数据已存在\"}";
}
sql = "insert into wxxd_product_shop_map.product_shop_map_" + index.ParseToString().PadLeft(4, '0') +
" (up_secret_spu_id,up_spu_id,shop_id) " +
" values ('" + up_secret_spu_id + "','" + up_spu_id + "','" + shop_id + "');";
mySql.ExecuteNonQuery(sql);
mySql.Close();
if (mySql.Message.IsNullOrEmpty())
{
return "{\"code\":200,\"msg\":\"成功\"}";
}
else
{
return "{\"code\":500,\"msg\":\"失败:" + mySql.Message + "\"}";
}
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string WXAddSecretIdUpMap(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 up_secret_spu_id = RegexUtils.GetStringQuery(ref inputData, "up_secret_spu_id")?.Replace("'", "\\'");
if (string.IsNullOrEmpty(up_secret_spu_id))
{
return "{\"code\":500,\"msg\":\"缺少商品编号1\"}";
}
var index = RegexUtils.GetStringQuery(ref inputData, "index").ParseToNullableLong();
if (index == null)
index = Math.Abs(up_secret_spu_id.GetHashCode()) % 1024;
var up_spu_id = RegexUtils.GetStringQuery(ref inputData, "up_spu_id")?.Replace("'", "\\'");
if (string.IsNullOrEmpty(up_spu_id))
{
return "{\"code\":500,\"msg\":\"缺少商品编号2\"}";
}
var shop_id = RegexUtils.GetStringQuery(ref inputData, "shop_id")?.Replace("'", "\\'");
if (string.IsNullOrEmpty(shop_id))
{
return "{\"code\":500,\"msg\":\"缺少店铺编号\"}";
}
var price_max = RegexUtils.GetStringQuery(ref inputData, "price_max")?.Replace("'", "\\'");
if (string.IsNullOrEmpty(price_max))
{
return "{\"code\":500,\"msg\":\"缺少最高价格\"}";
}
var price_min = RegexUtils.GetStringQuery(ref inputData, "price_min")?.Replace("'", "\\'");
if (string.IsNullOrEmpty(price_min))
{
return "{\"code\":500,\"msg\":\"缺少最低价格\"}";
}
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "insert into wxxd_product_up_map.product_up_map_" + index.ParseToString().PadLeft(4, '0') +
" (up_secret_spu_id,up_spu_id,shop_id,price_min,price_max) " +
" values ('" + up_secret_spu_id + "','" + up_spu_id + "','" + shop_id + "'," + price_min + "," + price_max + ");";
mySql.ExecuteNonQuery(sql);
mySql.Close();
if (mySql.Message.IsNullOrEmpty())
{
return "{\"code\":200,\"msg\":\"成功\"}";
}
else
{
return "{\"code\":500,\"msg\":\"失败:" + mySql.Message + "\"}";
}
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string WXGetSecretSpuIdShopIdMapList(string inputData)
{
var timeCalc = DateTime.Now;
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 up_secret_spu_id = RegexUtils.GetStringQuery(ref inputData, "up_secret_spu_id")?.Replace("'", "\\'");
if (string.IsNullOrEmpty(up_secret_spu_id))
{
return "{\"code\":500,\"msg\":\"缺少商品编号1\"}";
}
var index = RegexUtils.GetStringQuery(ref inputData, "index").ParseToNullableLong();
if (index == null)
index = up_secret_spu_id.ParseToLong() % 1024;
int page = RegexUtils.GetStringQuery(ref inputData, "page").ParseToInt();
int page_size = RegexUtils.GetStringQuery(ref inputData, "page_size").ParseToInt(50);
var shop_id = RegexUtils.GetStringQuery(ref inputData, "shop_id")?.Replace("'", "\\'");
var is_not_count = (RegexUtils.GetStringQuery(ref inputData, "is_not_count")?.Replace("'", "\\'")).ParseToBool();
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
MysqlUtils mySql = new MysqlUtils(conn);
int count = 0;
string sql = "";
if (!is_not_count)
{
sql = "select count(*) from wxxd_product_shop_map.product_shop_map_" + index.ParseToString().PadLeft(4, '0') +
" where up_secret_spu_id='" + up_secret_spu_id;
if (!shop_id.IsNullOrEmpty())
sql += "' and shop_id='" + shop_id + "'";
sql += ";";
count = mySql.ExecuteRowCount(sql);
Thread.Sleep(100);
}
DataTable dt;
if (count == 0 && !is_not_count)
{
dt = new DataTable();
}
else
{
sql = "select * from wxxd_product_shop_map.product_shop_map_" + index.ParseToString().PadLeft(4, '0') +
" where up_secret_spu_id='" + up_secret_spu_id;
if (!shop_id.IsNullOrEmpty())
sql += "' and shop_id='" + shop_id + "'";
sql += " order by add_time desc";
sql += " limit " + Math.Max(page - 1, 0) * page_size + "," + page_size;
dt = mySql.ExecuteDataTable(sql);
mySql.Close();
if (!string.IsNullOrEmpty(mySql.Message) || dt == null)
{
Thread.Sleep(1000);
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\",\"data\":[],\"count\":" + 0 + "}";
}
}
if (dt != null)
{
try
{
List<WxProdSecretSpuIdShopIdMapParam> prodSecretIdMapLst = new List<WxProdSecretSpuIdShopIdMapParam>();
foreach (DataRow row in dt.Rows)
{
WxProdSecretSpuIdShopIdMapParam idMap = new WxProdSecretSpuIdShopIdMapParam
{
id = Convert.ToInt32(row["id"]),
up_secret_spu_id = row["up_secret_spu_id"].ToString(),
up_spu_id = row["up_spu_id"].ToString(),
shop_id = row["shop_id"].ToString(),
add_time = Convert.ToDateTime(row["add_time"]),
//mdy_time = Convert.ToDateTime(row["mdy_time"]),
};
prodSecretIdMapLst.Add(idMap);
}
var data = JsonUtils.SerializeObjectToString(prodSecretIdMapLst);
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 SetRandomCompanyProductConfig(string inputData)
{
var timeCalc = DateTime.Now;
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\":50000,\"msg\":\"用户不存在\"}";
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
MysqlUtils mySql = new MysqlUtils(conn);
string product_group = RegexUtils.GetStringQuery(ref inputData, "product_group")?.Replace("'", "\\'");
string product_interval = RegexUtils.GetStringQuery(ref inputData, "product_interval")?.Replace("'", "\\'");
string is_on = RegexUtils.GetStringQuery(ref inputData, "is_on")?.Replace("'", "\\'");
string sql = "update wxxd.product_com_random set ";
if (product_group != null)
sql += "product_group='" + product_group + "',";
if (product_interval != null)
sql += "product_interval=" + product_interval + ",";
if (is_on != null)
sql += "is_on=" + is_on + ",";
sql = sql.TrimEnd(',');
sql += " where 1=1;";
var rst = mySql.ExecuteNonQuery(sql);
mySql.Close();
if (string.IsNullOrEmpty(mySql.Message))
{
return "{\"code\":200,\"msg\":\"success\"}";
}
else
{
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}";
}
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string GetRandomCompanyProductConfig(string inputData)
{
var timeCalc = DateTime.Now;
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\":50000,\"msg\":\"用户不存在\"}";
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "select p.* from wxxd.product_com_random p" +
" where 1=1;";
var dt = mySql.ExecuteDataTable(sql);
mySql.Close();
if (dt != null)
{
try
{
string product_group = dt.Rows[0]["product_group"].ParseToString();
string product_interval = dt.Rows[0]["product_interval"].ParseToString();
string is_on = dt.Rows[0]["is_on"].ParseToString();
var seconds = (DateTime.Now - timeCalc).TotalSeconds.ToString("0.000");
return "{\"code\":200,\"msg\":\"success\"" +
",\"product_group\":\"" + product_group + "\"" +
",\"product_interval\":" + product_interval +
",\"is_on\":" + is_on +
",\"seconds\":" + seconds + "}";
}
catch (Exception ex)
{
return "{\"code\":500,\"msg\":\"" + ex.Message + "\"}";
}
}
else
{
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}";
}
}
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)
{
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\":\"没有用户名\"}";
}
//int page = RegexUtils.GetStringQuery(ref inputData, "page").ParseToInt();
//int page_size = RegexUtils.GetStringQuery(ref inputData, "page_size").ParseToInt(50);
string coid = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "coid"))?.Replace("'", "\\'");
string after_sale_json = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "after_sale_json"))?.Replace("'", "\\'");
if (string.IsNullOrEmpty(coid))
return "{\"code\":50001,\"msg\":\"没有售后编号\"}";
if (string.IsNullOrEmpty(after_sale_json))
return "{\"code\":50001,\"msg\":\"没有售后信息\"}";
string supplier_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "supplier_name"))?.Replace("'", "\\'");
string type = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "type"))?.Replace("'", "\\'");
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "SELECT coid FROM `wxxd`.`after_sale` where coid='" + coid + "' and is_del=0";
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 `wxxd`.`after_sale` (coid,after_sale_json,supplier_name,type) VALUES (@coid,@after_sale_json,@supplier_name,@type);";
}
else
{
sql = "UPDATE `wxxd`.`after_sale` SET after_sale_json=@after_sale_json";
if (supplier_name != null)
sql += ", supplier_name=@supplier_name ";
if (type != null)
sql += ", type=@type ";
sql += " WHERE coid=@coid and is_del=0;";
}
List<MySqlParameter> paramLst = new List<MySqlParameter>();
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "coid", Value = coid, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "after_sale_json", Value = after_sale_json, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "supplier_name", Value = supplier_name.ParseToString(), });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "type", Value = type.IsNullOrEmpty() ? "jst" : type, });
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\":\"输入为空\"}";
}
/// <summary>
/// 上货实时获取聚水潭等外部平台售后地址
/// </summary>
/// <param name="inputData"></param>
/// <returns></returns>
public string WXGetAfterSale(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\":\"没有用户名\"}";
}
//int page = RegexUtils.GetStringQuery(ref inputData, "page").ParseToInt();
//int page_size = RegexUtils.GetStringQuery(ref inputData, "page_size").ParseToInt(50);
string coid = RegexUtils.GetStringQuery(ref inputData, "coid")?.Replace("'", "\\'");
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "SELECT * FROM `wxxd`.`after_sale` where coid='" + coid + "' and is_del=0";
string where = "";
sql += where;
var dt = mySql.ExecuteDataTable(sql);
mySql.Close();
if (dt != null)
{
try
{
string group_data = "";
foreach (DataRow row in dt.Rows)
{
group_data += row["after_sale_json"].ToString();
break;
}
var data = group_data.Trim(',');
if (data.IsNullOrEmpty())
data = "\"\"";
return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + "}";
}
catch (Exception ex)
{
return "{\"code\":50002,\"msg\":\"" + ex.Message + "\",\"data\":\"\"}";
}
}
else
{
return "{\"code\":50003,\"msg\":\"" + mySql.Message + "\",\"data\":\"\"}";
}
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
/// <summary>
/// 聚水潭等外部平台售后列表
/// </summary>
/// <param name="inputData"></param>
/// <returns></returns>
public string WXGetAfterSaleList(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
var timeCalc = DateTime.Now;
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\":\"没有用户名\"}";
}
int page = RegexUtils.GetStringQuery(ref inputData, "page").ParseToInt();
int page_size = RegexUtils.GetStringQuery(ref inputData, "page_size").ParseToInt(50);
string coid = RegexUtils.GetStringQuery(ref inputData, "coid")?.Replace("'", "\\'");
string type = RegexUtils.GetStringQuery(ref inputData, "type")?.Replace("'", "\\'");
string supplier_name = RegexUtils.GetStringQuery(ref inputData, "supplier_name")?.Replace("'", "\\'");
string detail = RegexUtils.GetStringQuery(ref inputData, "detail")?.Replace("'", "\\'");
string isDel = RegexUtils.GetStringQuery(ref inputData, "isDel")?.Replace("'", "\\'");
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "SELECT count(*) FROM `wxxd`.`after_sale` where 1=1";
string where = "";
if (coid != null)
where += " and coid='" + coid + "'";
if (type != null)
where += " and type='" + type + "'";
if (supplier_name != null)
where += " and supplier_name='" + supplier_name + "'";
if (detail != null)
where += " and after_sale_json like '%" + detail + "%'";
if (isDel == "true")
where += " and is_del>0";
else
where += " and is_del=0";
sql += where;
sql += ";";
var count = 0;
count = mySql.ExecuteRowCount(sql);
DataTable dt;
if (count == 0)
{
dt = new DataTable();
}
else
{
sql = "SELECT * FROM `wxxd`.`after_sale` 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<WXAddressInfo> WXAddressInfoLst = new List<WXAddressInfo>();
foreach (DataRow row in dt.Rows)
{
WXAddressInfoLst.Add(new WXAddressInfo()
{
id = row["id"].ParseToInt(),
after_sale_json = row["after_sale_json"].ParseToString(),
coid = row["coid"].ParseToString(),
supplier_name = row["supplier_name"].ParseToString(),
type = row["type"].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(WXAddressInfoLst, 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 WXDelAddress(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
var timeCalc = DateTime.Now;
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 coid = RegexUtils.GetStringQuery(ref inputData, "coid");
if (string.IsNullOrEmpty(coid))
{
return "{\"code\":50002,\"msg\":\"没有售后地址编号\"}";
}
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
MysqlUtils mySql = new MysqlUtils(conn);
//string sql = "delete from wxxd.after_sale where coid='" + coid + "' and is_del=false";
string sql = "update wxxd.after_sale set is_del=" + RandomUtils.GetId(1, Int32.MaxValue) + " where coid='" + coid + "' and is_del=false";
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 WXAddMdyShippingTemplate(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\":\"没有用户名\"}";
}
//int page = RegexUtils.GetStringQuery(ref inputData, "page").ParseToInt();
//int page_size = RegexUtils.GetStringQuery(ref inputData, "page_size").ParseToInt(50);
string coid = RegexUtils.GetStringQuery(ref inputData, "coid")?.Replace("'", "\\'");
string shipping_template_json = RegexUtils.GetStringQuery(ref inputData, "shipping_template_json")?.Replace("'", "\\'");
if (string.IsNullOrEmpty("coid"))
return "{\"code\":50001,\"msg\":\"没有运费编号\"}";
if (string.IsNullOrEmpty("shipping_template_json"))
return "{\"code\":50001,\"msg\":\"没有运费信息\"}";
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "SELECT * FROM `wxxd`.`shipping_template` where coid='" + coid + "'";
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 `wxxd`.`shipping_template` (coid,shipping_template_json) VALUES (@coid,@shipping_template_json);";
}
else
{
sql = "UPDATE `wxxd`.`shipping_template` SET shipping_template_json=@shipping_template_json WHERE coid=@coid;";
}
List<MySqlParameter> paramLst = new List<MySqlParameter>();
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "coid", Value = coid, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "shipping_template_json", Value = shipping_template_json, });
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 WXGetShippingTemplate(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\":\"没有用户名\"}";
}
//int page = RegexUtils.GetStringQuery(ref inputData, "page").ParseToInt();
//int page_size = RegexUtils.GetStringQuery(ref inputData, "page_size").ParseToInt(50);
string coid = RegexUtils.GetStringQuery(ref inputData, "coid")?.Replace("'", "\\'");
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "SELECT * FROM `wxxd`.`shipping_template` where coid='" + coid + "'";
string where = "";
sql += where;
var dt = mySql.ExecuteDataTable(sql);
mySql.Close();
if (dt != null)
{
try
{
string group_data = "";
foreach (DataRow row in dt.Rows)
{
group_data += row["shipping_template_json"].ToString();
break;
}
var data = group_data.Trim(',');
if (data.IsNullOrEmpty())
data = "\"\"";
return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + "}";
}
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)
{
if (string.IsNullOrEmpty(inputData))
return "{\"code\":19999,\"msg\":\"输入为空\"}";
var time = RegexUtils.GetStringQuery(ref inputData, "time").ParseToInt();
string time1 = RegexUtils.GetStringQuery(ref inputData, "code");
if (time1 != EncrypUtil.Encryption(time))
return "{\"code\":50000,\"msg\":\"校验失败\"}";
// 供应商id
string coid = RegexUtils.GetStringQuery(ref inputData, "coid")?.Replace("'", "\\'");
try
{
// 获取运费模板
//"https://po.e57.cn/prod-api/api/sys-api/system/open/api/freightTemplate/list?warehouseNum=10361546";
var urlShip = "https://po.e57.cn/prod-api/api/sys-api/system/open/api/freightTemplate/list?warehouseNum=" + coid;
var shipRst = HttpUtils.e57GetResponse(urlShip, "");
return shipRst;
}
catch (Exception ex)
{
return "{\"code\":50001,\"msg\":\"" + ex.Message + "\"}";
}
}
public string E57AfterSale(string inputData)
{
if (string.IsNullOrEmpty(inputData))
return "{\"code\":19999,\"msg\":\"输入为空\"}";
var time = RegexUtils.GetStringQuery(ref inputData, "time").ParseToInt();
string time1 = RegexUtils.GetStringQuery(ref inputData, "code");
if (time1 != EncrypUtil.Encryption(time))
return "{\"code\":50000,\"msg\":\"校验失败\"}";
// 供应商id
string coid = RegexUtils.GetStringQuery(ref inputData, "coid")?.Replace("'", "\\'");
try
{
// 获取推单售后地址
//https://po.e57.cn/prod-api/api/sys-api/system/open/api/afterSale/info?warehouseNum=10361546&shopId=46568955
var urlAfter = "https://po.e57.cn/prod-api/api/sys-api/system/open/api/afterSale/info?warehouseNum=" + coid;
var shipRst = HttpUtils.e57GetResponse(urlAfter, "");
return shipRst;
}
catch (Exception ex)
{
return "{\"code\":50001,\"msg\":\"" + ex.Message + "\"}";
}
}
}
}