using StoreHub.KJDWebService.Models;
using StoreHub.KJDWebService.Services;
using StoreHub.Framework.Repositorys;
using Microsoft.Extensions.Configuration;
using StoreHub.KJDWebService.Models.ShopModel;
using StoreHub.KJDWebService.Models.WxModel;
using StoreHub.KJDWebService.Commons;
using MySql.Data.MySqlClient;
using NaiBa.Util.Extension;
using NaiBa.Util.Helper;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Threading;
namespace StoreHub.KJDWebService.Services
{
public class WXProductService : ServiceBase
{
private readonly BXXProductService _bXXProductService;
public WXProductService(SqlRepository sqlRepository, IConfiguration configuration, BXXProductService bXXProductService) : base(sqlRepository, configuration)
{
_bXXProductService = bXXProductService;
}
public string WXGetPDDProductList(string inputData, bool isDetail = false)
{
return _bXXProductService.GetProductList(inputData, isDetail);
}
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 = "ConnKJD";
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 _bXXProductService.GetProductMainCates(inputData);
}
///
/// 随机获取商品(无详情) 随机添加到上传列表所以不需要获取详情
///
///
///
public string WXGetPDDProductListRandom(string inputData)
{
return _bXXProductService.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 = "ConnKJD";
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 productLst = new List();
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 _bXXProductService.MdyProduct(inputData);
}
public string MdyBestSaleProd(string inputData)
{
return _bXXProductService.MdyBestSaleProd(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 = "ConnKJD";
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 = "ConnKJD";
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") == "true";
string conn = "ConnKJD";
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 prodSecretIdMapLst = new List();
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 = "ConnKJD";
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 = "ConnKJD";
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 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 = "ConnKJD";
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 = Config("ConnKJD");
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 paramLst = new List();
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\":\"输入为空\"}";
}
///
/// 上货实时获取聚水潭等外部平台售后地址
///
///
///
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 = "ConnKJD";
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\":\"输入为空\"}";
}
public string WXGetRandomAfterSaleList(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 type = RegexUtils.GetStringQuery(ref inputData, "type")?.Replace("'", "\\'");
string isDel = RegexUtils.GetStringQuery(ref inputData, "isDel")?.Replace("'", "\\'");
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "SELECT count(*) FROM `wxxd`.`after_sale` where 1=1";
string where = "";
if (type != null)
where += " and type='" + type + "'";
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 RAND() limit " + Math.Max(0, page - 1) * page_size + "," + page_size + ";";
dt = mySql.ExecuteDataTable(sql);
}
mySql.Close();
if (dt != null)
{
try
{
List WXAddressInfoLst = new List();
foreach (DataRow row in dt.Rows)
{
WXAddressInfoLst.Add(new StoreHub.KJDWebService.Models.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 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 = "ConnKJD";
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 WXAddressInfoLst = new List();
foreach (DataRow row in dt.Rows)
{
WXAddressInfoLst.Add(new StoreHub.KJDWebService.Models.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 = "ConnKJD";
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 = "ConnKJD";
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 = Config("ConnKJD");
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 paramLst = new List();
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 = "ConnKJD";
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 WXAddMdyCommissionRate(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
if (!WXUserService.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 = "ConnKJD";
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 = Config("ConnKJD");
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 paramLst = new List();
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 (!WXUserService.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 = "ConnKJD";
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 WXAddMdyQualificationImage(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
if (!WXUserService.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 img_md5 = RegexUtils.GetStringQuery(ref inputData, "img_md5")?.Replace("'", "\\'");
string img_base64 = RegexUtils.GetStringQuery(ref inputData, "img_base64")?.Replace("'", "\\'");
string img_thumb_base64 = RegexUtils.GetStringQuery(ref inputData, "img_thumb_base64")?.Replace("'", "\\'");
string txt_margin = RegexUtils.GetStringQuery(ref inputData, "txt_margin")?.Replace("'", "\\'");
if (string.IsNullOrEmpty(img_md5))
return "{\"code\":50001,\"msg\":\"没有图片码\"}";
if (string.IsNullOrEmpty("product_name"))
return "{\"code\":50001,\"msg\":\"没有图片\"}";
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "INSERT INTO wxxd.wx_qualification_image (img_md5,img_base64,img_thumb_base64,txt_margin) VALUES " +
" ('" + img_md5 + "','" + img_base64 + "','" + img_thumb_base64 + "','" + txt_margin + "')" +
" ON DUPLICATE KEY UPDATE img_base64=VALUES(img_base64),img_thumb_base64=VALUES(img_thumb_base64),txt_margin=VALUES(txt_margin);";
var rst = mySql.ExecuteAffectedRows(sql);
mySql.Close();
if (!mySql.Message.IsNullOrEmpty())
{
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}";
}
else if (rst < 1)
{
return "{\"code\":500,\"msg\":\"未新增或更新\"}";
}
return "{\"code\":200,\"msg\":\"success\"}";
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string WXGetQualificationImage(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
if (!WXUserService.GetSign(inputData))
return "{\"code\":999,\"msg\":\"校验失败\"}";
int page = RegexUtils.GetStringQuery(ref inputData, "page").ParseToInt(1);
int page_size = RegexUtils.GetStringQuery(ref inputData, "page_size").ParseToInt(200);
string img_md5 = RegexUtils.GetStringQuery(ref inputData, "img_md5")?.Replace("'", "\\'");
string cat_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "cat_name"))?.Replace("'", "\\'");
string is_detail = RegexUtils.GetStringQuery(ref inputData, "is_detail")?.Replace("'", "\\'");
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "SELECT * FROM wxxd.wx_qualification_image where 1=1";
string where = "";
if (!string.IsNullOrEmpty(img_md5))
where += " and img_md5 in ('" + img_md5.Replace(",", "','") + "')";
if (!string.IsNullOrEmpty(cat_name))
where += " and cat_name in ('" + cat_name.Replace(",", "','") + "')";
sql += where;
sql += " ORDER BY id DESC";
sql += " LIMIT " + (page - 1) * page_size + "," + page_size + ";";
var dt = mySql.ExecuteDataTable(sql);
mySql.Close();
if (dt != null)
{
JArray jArr = new JArray();
List wxQualificationImageInfos = new List();
try
{
foreach (DataRow row in dt.Rows)
{
var img = new wx_qualification_image_info()
{
id = row["id"].ParseToInt(),
cat_name = row["cat_name"].ParseToString(),
img_md5 = row["img_md5"].ParseToString(),
img_thumb_base64 = row["img_thumb_base64"].ParseToNullableString(),
txt_margin = row["txt_margin"].ParseToNullableString(),
add_time = row["add_time"].ParseToString().ParseToDateTime(),
mdy_time = row["mdy_time"].ParseToString().ParseToDateTime(),
};
if (is_detail == "true")
img.img_base64 = row["img_base64"].ParseToNullableString();
wxQualificationImageInfos.Add(img);
}
return "{\"code\":200,\"msg\":\"success\",\"data\":" + JsonUtils.SerializeObject(wxQualificationImageInfos) + "}";
}
catch (Exception ex)
{
return "{\"code\":50002,\"msg\":\"" + ex.Message + "\",\"data\":[]}";
}
}
else
{
return "{\"code\":50003,\"msg\":\"" + mySql.Message + "\",\"data\":[]}";
}
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string WXDelQualificationImage(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
if (!WXUserService.GetSign(inputData))
return "{\"code\":999,\"msg\":\"校验失败\"}";
string img_md5 = RegexUtils.GetStringQuery(ref inputData, "img_md5")?.Replace("'", "\\'");
string id = RegexUtils.GetStringQuery(ref inputData, "id")?.Replace("'", "\\'");
if (id.IsNullOrZero() && img_md5.IsNullOrEmpty())
{
return "{\"code\":50001,\"msg\":\"图片id不能为空\"}";
}
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "delete FROM wxxd.wx_qualification_image where 1=1";
string where = "";
if (!string.IsNullOrEmpty(img_md5))
where += " and img_md5 in ('" + img_md5.Replace(",", "','") + "')";
if (!id.IsNullOrZero())
where += " and id in (" + id + ")";
sql += where + ";";
var rows = mySql.ExecuteAffectedRows(sql);
mySql.Close();
if(!string.IsNullOrEmpty(mySql.Message))
{
return "{\"code\":50002,\"msg\":\"" + mySql.Message + "\"}";
}
return "{\"code\":200,\"msg\":\"success\",\"affected_rows\":" + rows + "}";
}
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 + "\"}";
}
}
}
}