3860 lines
213 KiB
C#
3860 lines
213 KiB
C#
using StoreHub.KJDWebService.Services;
|
||
using StoreHub.Framework.Repositorys;
|
||
using Microsoft.Extensions.Configuration;
|
||
using StoreHub.KJDWebService.Models;
|
||
using StoreHub.KJDWebService.Models.ShopModel;
|
||
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.Drawing;
|
||
using System.IO;
|
||
using System.Linq;
|
||
using System.Reflection;
|
||
using System.Threading;
|
||
|
||
namespace StoreHub.KJDWebService.Services
|
||
{
|
||
public class BXXProductService : ServiceBase
|
||
{
|
||
public BXXProductService(SqlRepository sqlRepository, IConfiguration configuration) : base(sqlRepository, configuration)
|
||
{
|
||
}
|
||
string GetProductTableName(string inputData)
|
||
{
|
||
var tableName = "bxx.product";
|
||
//var add_user_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "add_user_name"))?.Replace("'", "\\'");
|
||
//if (add_user_name != null && add_user_name != "admin")
|
||
//{
|
||
// var tableId = RegexUtils.GetStringQuery(ref inputData, "table_id").ParseToNullableLong();
|
||
// if (tableId == null && add_user_name.ParseToNullableLong() is long userIdLong)
|
||
// tableId = userIdLong % 1024;
|
||
// if (tableId == null)
|
||
// tableId = Math.Abs(add_user_name.GetHashCode()) % 1024;
|
||
// tableName = "pdb.product_" + tableId;
|
||
//}
|
||
return tableName;
|
||
}
|
||
public string AddProduct(string inputData)
|
||
{
|
||
if (!string.IsNullOrEmpty(inputData))
|
||
{
|
||
var time = 0;
|
||
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "time"), out time);
|
||
string time1 = RegexUtils.GetStringQuery(ref inputData, "code");
|
||
if (time1 != EncrypUtil.Encryption(time))
|
||
return "{\"code\":50000,\"msg\":\"校验失败\"}";
|
||
|
||
string user_name = RegexUtils.GetStringQuery(ref inputData, "user_name")?.Replace("'", "\\'");
|
||
string from_shop_id = RegexUtils.GetStringQuery(ref inputData, "from_shop_id")?.Replace("'", "\\'");
|
||
string from_shop_name = RegexUtils.GetStringQuery(ref inputData, "from_shop_name")?.Replace("'", "\\'");
|
||
string offline_supplier_id = RegexUtils.GetStringQuery(ref inputData, "offline_supplier_id")?.Replace("'", "\\'");
|
||
string offline_supplier_name = RegexUtils.GetStringQuery(ref inputData, "offline_supplier_name")?.Replace("'", "\\'");
|
||
string spu_id = RegexUtils.GetStringQuery(ref inputData, "spu_id")?.Replace("'", "\\'");
|
||
//厂商直采聚水潭商品使用skcid存储coid数据
|
||
string skc_id = RegexUtils.GetStringQuery(ref inputData, "skc_id")?.Replace("'", "\\'"); // skcId,聚水潭商品为coid
|
||
string real_coid = RegexUtils.GetStringQuery(ref inputData, "real_coid")?.Replace("'", "\\'"); // 聚水潭爆款专区真实商家coid,供应商直采商品该字段留空
|
||
string real_spu_id = RegexUtils.GetStringQuery(ref inputData, "real_spu_id")?.Replace("'", "\\'"); // 聚水潭爆款专区真实商家spuid,供应商直采商品该字段留空
|
||
string price_text = RegexUtils.GetStringQuery(ref inputData, "price_text")?.Replace("'", "\\'");
|
||
string main_cat_id = RegexUtils.GetStringQuery(ref inputData, "main_cat_id")?.Replace("'", "\\'");
|
||
string main_cat_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "main_cat_name"))?.Replace("'", "\\'");
|
||
string cat_id = RegexUtils.GetStringQuery(ref inputData, "cat_id");
|
||
string cat_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "cat_name"))?.Replace("'", "\\'");
|
||
string ext_code = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "ext_code"))?.Replace("'", "\\'");
|
||
string product_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "product_name"))?.Replace("'", "\\'");
|
||
string product_json = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "product_json"));
|
||
string size_json = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "size_json"));
|
||
string main_img = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "main_img"))?.Replace("'", "\\'");
|
||
string group = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "group"))?.Replace("'", "\\'");
|
||
string notes = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "notes"))?.Replace("'", "\\'");
|
||
string product_get_type = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "product_get_type"))?.Replace("'", "\\'");
|
||
int? sale_count = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sale_count"))?.ParseToNullableInt();
|
||
string sale_count_text = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sale_count_text"))?.Replace("'", "\\'");
|
||
string distribution_set = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "distribution_set"))?.Replace("'", "\\'");
|
||
string add_user_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "add_user_name"))?.Replace("'", "\\'");
|
||
string special_prod_type = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "special_prod_type"))?.Replace("'", "\\'");
|
||
if (special_prod_type != "爆款数据")
|
||
special_prod_type = "普通商品";
|
||
string view_uv = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "view_uv"))?.Replace("'", "\\'"); // 爆款数据产品曝光数量
|
||
string add_hot_version = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "add_hot_version"))?.Replace("'", "\\'");
|
||
if (special_prod_type == "爆款数据" && product_get_type == "微信店采" && add_hot_version != "v3")
|
||
{
|
||
return "{\"code\":666,\"msg\":\"当前版本已失效,请更新软件\"}";
|
||
}
|
||
|
||
if (string.IsNullOrEmpty(product_get_type))
|
||
{
|
||
product_get_type = "母店采集";
|
||
}
|
||
|
||
if (string.IsNullOrEmpty(user_name))
|
||
{
|
||
return "{\"code\":500,\"msg\":\"没有用户名\"}";
|
||
}
|
||
if (add_user_name != null && add_user_name != "admin")
|
||
{
|
||
Thread.Sleep(1000);
|
||
}
|
||
|
||
string conn = "ConnKJD";
|
||
MysqlUtils mySql = new MysqlUtils(conn);
|
||
|
||
string tableName = GetProductTableName(inputData);
|
||
string sql = "";
|
||
|
||
if (add_user_name != null && add_user_name != "admin")
|
||
{
|
||
sql = "select count(*) from " + tableName + " where is_del=0 and add_user_name='" + add_user_name + "'";
|
||
var count = mySql.ExecuteRowCount(sql);
|
||
if (!string.IsNullOrEmpty(mySql.Message) || count > 100000)
|
||
{
|
||
mySql.Close();
|
||
return "{\"code\":500,\"msg\":\"产品数据库已达上限10万,请删除旧数据后重新添加新商品\"}";
|
||
}
|
||
}
|
||
|
||
int ban_wx = 0;
|
||
int ban_pdd = 0;
|
||
if (product_get_type == "厂商直采")
|
||
{
|
||
if (real_coid != null)
|
||
sql = "select ban_wx,ban_pdd from bxx.jst_supplier_ban_platform where coid=" + real_coid;
|
||
else if (skc_id != null)
|
||
sql = "select ban_wx,ban_pdd from bxx.jst_supplier_ban_platform where coid=" + skc_id;
|
||
var dtr = mySql.ExecuteDataTableRow(sql);
|
||
if (!string.IsNullOrEmpty(mySql.Message))
|
||
{
|
||
mySql.Close();
|
||
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}";
|
||
}
|
||
else if (dtr != null)
|
||
{
|
||
ban_wx = dtr["ban_wx"].ParseToInt();
|
||
ban_pdd = dtr["ban_pdd"].ParseToInt();
|
||
}
|
||
}
|
||
|
||
sql = "INSERT INTO " + tableName + " (";
|
||
sql += "from_shop_id,from_shop_name,offline_supplier_id,offline_supplier_name,spu_id,skc_id,real_coid,real_spu_id,main_cat_id,main_cat_name,cat_id,";
|
||
sql += "cat_name,price_text,product_name,ext_code,main_img,product_json,size_json,notes,product_get_type,";
|
||
if (sale_count != null)
|
||
{
|
||
sql += "sale_count,";
|
||
}
|
||
sql += "sale_count_text,special_prod_type,";
|
||
sql += "distribution_set,ban_wx,ban_pdd,add_time,mdy_time,";
|
||
if (add_user_name != null)
|
||
sql += "add_user_name,";
|
||
if (group != null)
|
||
sql += "`group`,";
|
||
if (!string.IsNullOrWhiteSpace(view_uv))
|
||
sql += "view_uv,";
|
||
sql = sql.TrimEnd(',');
|
||
sql += ") ";
|
||
sql += "values ('" + from_shop_id + "','" + from_shop_name + "','" + offline_supplier_id + "','" + offline_supplier_name + "','" + spu_id + "','" +
|
||
skc_id + "','" + real_coid + "','" + real_spu_id + "','" + main_cat_id + "','" + main_cat_name + "','" + cat_id + "','" + cat_name + "','" +
|
||
price_text + "','" + product_name + "','" + ext_code + "','" + main_img + "',@product_json,@size_json,'" + notes + "','" + product_get_type + "',";
|
||
if (sale_count != null)
|
||
{
|
||
sql += "'" + sale_count + "',";
|
||
}
|
||
sql += "'" + sale_count_text + "','" + special_prod_type + "'," + distribution_set.ParseToInt() + "," + ban_wx + "," + ban_pdd + ",";
|
||
sql += "'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',";
|
||
sql += "'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',";
|
||
if (add_user_name != null)
|
||
sql += "'" + add_user_name + "',";
|
||
if (group != null)
|
||
sql += "'" + group + "',";
|
||
if (!string.IsNullOrWhiteSpace(view_uv))
|
||
sql += "" + view_uv + ",";
|
||
sql = sql.TrimEnd(',');
|
||
sql += ");";
|
||
|
||
List<MySqlParameter> paramLst = new List<MySqlParameter>();
|
||
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "product_json", Value = product_json, });
|
||
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "size_json", Value = size_json, });
|
||
var rst = mySql.ExecuteNonQuery(sql, paramLst.ToArray());
|
||
mySql.Close();
|
||
if (rst)
|
||
{
|
||
return "{\"code\":200,\"msg\":\"success\"}";
|
||
}
|
||
else
|
||
{
|
||
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}";
|
||
}
|
||
}
|
||
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
||
}
|
||
|
||
public string MdyProduct(string inputData)
|
||
{
|
||
if (!string.IsNullOrEmpty(inputData))
|
||
{
|
||
var time = 0;
|
||
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "time"), out time);
|
||
string time1 = RegexUtils.GetStringQuery(ref inputData, "code");
|
||
if (time1 != EncrypUtil.Encryption(time))
|
||
return "{\"code\":50000,\"msg\":\"校验失败\"}";
|
||
|
||
string user_name = RegexUtils.GetStringQuery(ref inputData, "user_name")?.Replace("'", "\\'");
|
||
string from_shop_id = RegexUtils.GetStringQuery(ref inputData, "from_shop_id")?.Replace("'", "\\'");
|
||
string from_shop_name = RegexUtils.GetStringQuery(ref inputData, "from_shop_name")?.Replace("'", "\\'");
|
||
string offline_supplier_id = RegexUtils.GetStringQuery(ref inputData, "offline_supplier_id")?.Replace("'", "\\'");
|
||
string offline_supplier_name = RegexUtils.GetStringQuery(ref inputData, "offline_supplier_name")?.Replace("'", "\\'");
|
||
string spu_id = RegexUtils.GetStringQuery(ref inputData, "spu_id")?.Replace("'", "\\'");
|
||
string skc_id = RegexUtils.GetStringQuery(ref inputData, "skc_id")?.Replace("'", "\\'"); // skcId,聚水潭商品为coid
|
||
string real_coid = RegexUtils.GetStringQuery(ref inputData, "real_coid")?.Replace("'", "\\'"); // 聚水潭爆款专区真实商家coid,供应商直采商品该字段留空
|
||
string real_spu_id = RegexUtils.GetStringQuery(ref inputData, "real_spu_id")?.Replace("'", "\\'"); // 聚水潭爆款专区真实商家spuid,供应商直采商品该字段留空
|
||
string secret_spu_id = RegexUtils.GetStringQuery(ref inputData, "secret_spu_id")?.Replace("'", "\\'");
|
||
string price_text = RegexUtils.GetStringQuery(ref inputData, "price_text")?.Replace("'", "\\'");
|
||
string main_cat_id = RegexUtils.GetStringQuery(ref inputData, "main_cat_id")?.Replace("'", "\\'");
|
||
string main_cat_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "main_cat_name"))?.Replace("'", "\\'");
|
||
string cat_id = RegexUtils.GetStringQuery(ref inputData, "cat_id")?.Replace("'", "\\'");
|
||
string cat_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "cat_name"))?.Replace("'", "\\'");
|
||
string ext_code = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "ext_code"))?.Replace("'", "\\'");
|
||
string product_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "product_name"))?.Replace("'", "\\'");
|
||
string product_json = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "product_json"));
|
||
string size_json = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "size_json"));
|
||
string main_img = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "main_img"))?.Replace("'", "\\'");
|
||
string group = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "group"))?.Replace("'", "\\'");
|
||
string notes = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "notes"))?.Replace("'", "\\'");
|
||
int? sale_count = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sale_count"))?.ParseToNullableInt();
|
||
string sale_count_text = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sale_count_text"))?.Replace("'", "\\'");
|
||
string wx_safe_status = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "wx_safe_status"))?.Replace("'", "\\'");
|
||
string special_prod_type = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "special_prod_type"))?.Replace("'", "\\'");
|
||
if (!string.IsNullOrEmpty(special_prod_type) && special_prod_type != "爆款数据")
|
||
special_prod_type = "普通商品";
|
||
string wx_cat_1 = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "wx_cat_1"))?.Replace("'", "\\'");
|
||
string wx_cat_2 = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "wx_cat_2"))?.Replace("'", "\\'");
|
||
string wx_cat_3 = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "wx_cat_3"))?.Replace("'", "\\'");
|
||
string wx_cat_leaf = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "wx_cat_leaf"))?.Replace("'", "\\'");
|
||
string delivery_fee_set = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "delivery_fee_set"))?.Replace("'", "\\'");
|
||
string after_sale_set = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "after_sale_set"))?.Replace("'", "\\'");
|
||
string distribution_set = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "distribution_set"))?.Replace("'", "\\'");
|
||
string send_to_out_server = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "send_to_out_server"))?.Replace("'", "\\'");
|
||
string sku_edit_json = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sku_edit_json"))?.Replace("'", "\\'");
|
||
string sku_secret_json = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sku_secret_json"))?.Replace("'", "\\'");
|
||
string wx_img_map_json = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "wx_img_map_json"))?.Replace("'", "\\'");
|
||
string problem_prod_data = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "problem_prod_data"))?.Replace("'", "\\'");
|
||
string is_relation = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "is_relation"))?.Replace("'", "\\'");
|
||
string view_uv = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "view_uv"))?.Replace("'", "\\'"); // 产品曝光数量
|
||
string product_get_type = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "product_get_type"))?.Replace("'", "\\'");
|
||
string add_hot_version = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "add_hot_version"))?.Replace("'", "\\'");
|
||
if (special_prod_type == "爆款数据" && product_get_type == "微信店采" && add_hot_version != "v3")
|
||
{
|
||
return "{\"code\":666,\"msg\":\"当前版本已失效,请更新软件\"}";
|
||
}
|
||
|
||
if (string.IsNullOrEmpty(user_name))
|
||
{
|
||
return "{\"code\":500,\"msg\":\"没有用户名\"}";
|
||
}
|
||
|
||
string conn = "ConnKJD";
|
||
MysqlUtils mySql = new MysqlUtils(conn);
|
||
|
||
string tableName = GetProductTableName(inputData);
|
||
string sql = "";
|
||
|
||
sql = "update " + tableName + " p set";
|
||
if (from_shop_id != null)
|
||
sql += " p.from_shop_id='" + from_shop_id + "',";
|
||
if (from_shop_name != null)
|
||
sql += " p.from_shop_name='" + from_shop_name + "',";
|
||
if (offline_supplier_id != null)
|
||
sql += " p.offline_supplier_id='" + offline_supplier_id + "',";
|
||
if (offline_supplier_name != null)
|
||
sql += " p.offline_supplier_name='" + offline_supplier_name + "',";
|
||
if (main_cat_id != null)
|
||
sql += " p.main_cat_id='" + main_cat_id + "',";
|
||
if (main_cat_name != null)
|
||
sql += " p.main_cat_name='" + main_cat_name + "',";
|
||
if (cat_id != null)
|
||
sql += " p.cat_id='" + cat_id + "',";
|
||
if (cat_name != null)
|
||
sql += " p.cat_name='" + cat_name + "',";
|
||
if (price_text != null)
|
||
sql += " p.price_text='" + price_text + "',";
|
||
if (product_name != null)
|
||
sql += " p.product_name='" + product_name + "',";
|
||
if (ext_code != null)
|
||
sql += " p.ext_code='" + ext_code + "',";
|
||
if (secret_spu_id != null)
|
||
sql += " p.secret_spu_id='" + secret_spu_id + "',";
|
||
if (main_img != null)
|
||
sql += " p.main_img='" + main_img + "',";
|
||
if (product_json != null)
|
||
sql += " p.product_json=@product_json,";
|
||
if (size_json != null)
|
||
sql += " p.size_json=@size_json,";
|
||
if (group != null)
|
||
sql += " p.group='" + group + "',";
|
||
if (notes != null)
|
||
sql += " p.notes='" + notes + "',";
|
||
if (sale_count != null)
|
||
sql += " p.sale_count='" + sale_count + "',";
|
||
if (sale_count_text != null)
|
||
sql += " p.sale_count_text='" + sale_count_text + "',";
|
||
if (wx_safe_status != null)
|
||
sql += " p.wx_safe_status='" + wx_safe_status + "',";
|
||
if (special_prod_type != null && special_prod_type != "")
|
||
sql += " p.special_prod_type='" + special_prod_type + "',";
|
||
if (wx_cat_1 != null)
|
||
sql += " p.wx_cat_1=" + wx_cat_1 + ",";
|
||
if (wx_cat_2 != null)
|
||
sql += " p.wx_cat_2=" + wx_cat_2 + ",";
|
||
if (wx_cat_3 != null)
|
||
sql += " p.wx_cat_3=" + wx_cat_3 + ",";
|
||
if (wx_cat_leaf != null)
|
||
sql += " p.wx_cat_leaf=" + wx_cat_leaf + ",";
|
||
if (delivery_fee_set != null)
|
||
sql += " p.delivery_fee_set=" + delivery_fee_set + ",";
|
||
if (after_sale_set != null)
|
||
sql += " p.after_sale_set=" + after_sale_set + ",";
|
||
if (distribution_set != null)
|
||
sql += " p.distribution_set=" + distribution_set + ",";
|
||
if (send_to_out_server != null)
|
||
sql += " p.send_to_out_server=" + send_to_out_server + ",";
|
||
if (sku_edit_json != null)
|
||
sql += " p.sku_edit_json='" + sku_edit_json + "',";
|
||
if (sku_secret_json != null)
|
||
sql += " p.sku_secret_json=@sku_secret_json,";
|
||
if (wx_img_map_json != null)
|
||
sql += " p.wx_img_map_json=@wx_img_map_json,";
|
||
if (!problem_prod_data.IsNullOrEmpty())
|
||
sql += " p.problem_prod_data=" + problem_prod_data + ",";
|
||
if (!is_relation.IsNullOrEmpty())
|
||
sql += " p.is_relation=" + is_relation + ",";
|
||
if (!string.IsNullOrWhiteSpace(view_uv))
|
||
sql += " p.view_uv=" + view_uv + ",";
|
||
sql += " p.mdy_time='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',";
|
||
sql = sql.TrimEnd(',');
|
||
sql += " where spu_id='" + spu_id + "';";
|
||
|
||
List<MySqlParameter> paramLst = new List<MySqlParameter>();
|
||
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "product_json", Value = product_json, });
|
||
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "size_json", Value = size_json, });
|
||
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "sku_secret_json", Value = sku_secret_json, });
|
||
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "wx_img_map_json", Value = wx_img_map_json, });
|
||
|
||
var rst = mySql.ExecuteNonQuery(sql, paramLst.ToArray());
|
||
mySql.Close();
|
||
if (rst)
|
||
{
|
||
return "{\"code\":200,\"msg\":\"success\"}";
|
||
}
|
||
else
|
||
{
|
||
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}";
|
||
}
|
||
}
|
||
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
||
}
|
||
|
||
/// <summary>
|
||
/// 违规商品
|
||
/// </summary>
|
||
/// <param name="inputData"></param>
|
||
/// <returns></returns>
|
||
public string MdyViolationProd(string inputData)
|
||
{
|
||
if (!string.IsNullOrEmpty(inputData))
|
||
{
|
||
var time = 0;
|
||
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "time"), out time);
|
||
string time1 = RegexUtils.GetStringQuery(ref inputData, "code");
|
||
if (time1 != EncrypUtil.Encryption(time))
|
||
return "{\"code\":50000,\"msg\":\"校验失败\"}";
|
||
|
||
string user_name = RegexUtils.GetStringQuery(ref inputData, "user_name")?.Replace("'", "\\'");
|
||
if (string.IsNullOrEmpty(user_name))
|
||
{
|
||
return "{\"code\":500,\"msg\":\"没有用户名\"}";
|
||
}
|
||
|
||
string product_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "product_name"))?.Replace("'", "\\'");
|
||
string secret_spu_id = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "secret_spu_id"))?.Replace("'", "\\'");
|
||
string spu_id = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "spu_id"))?.Replace("'", "\\'");
|
||
|
||
string group = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "group"))?.Replace("'", "\\'");
|
||
string notes = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "notes"))?.Replace("'", "\\'");
|
||
string wx_safe_status = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "wx_safe_status"))?.Replace("'", "\\'");
|
||
if (string.IsNullOrWhiteSpace(product_name) && string.IsNullOrWhiteSpace(secret_spu_id) && string.IsNullOrWhiteSpace(spu_id))
|
||
return "{\"code\":500,\"msg\":\"没有商品查询信息\"}";
|
||
|
||
string conn = "ConnKJD";
|
||
MysqlUtils mySql = new MysqlUtils(conn);
|
||
|
||
string tableName = GetProductTableName(inputData);
|
||
string sql = "";
|
||
|
||
if (!string.IsNullOrEmpty(product_name))
|
||
sql = "select id,spu_id from " + tableName + " p where p.product_name='" + product_name + "' and p.wx_safe_status in ('安全商品','未校验');";
|
||
else if (!string.IsNullOrEmpty(secret_spu_id))
|
||
sql = "select id,spu_id from " + tableName + " p where p.secret_spu_id='" + secret_spu_id + "' and p.wx_safe_status in ('安全商品','未校验');";
|
||
else
|
||
sql = "select id,spu_id from " + tableName + " p where p.spu_id='" + spu_id + "' and p.wx_safe_status in ('安全商品','未校验');";
|
||
|
||
|
||
var dt = mySql.ExecuteDataTable(sql);
|
||
if (!string.IsNullOrEmpty(mySql.Message))
|
||
{
|
||
mySql.Close();
|
||
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}";
|
||
}
|
||
var ids = "";
|
||
foreach(DataRow row in dt.Rows)
|
||
{
|
||
ids += row["spu_id"].ParseToString() + "','";
|
||
}
|
||
ids.Trim(',', '\'');
|
||
if (string.IsNullOrEmpty(ids))
|
||
{
|
||
return "{\"code\":200,\"msg\":\"success\",\"err_msg\":\"商品不存在\"}";
|
||
}
|
||
else
|
||
{
|
||
sql = "update " + tableName + " p set";
|
||
if (group != null)
|
||
sql += " p.group='" + group + "',";
|
||
if (notes != null)
|
||
sql += " p.notes='" + notes + "',";
|
||
if (wx_safe_status != null)
|
||
sql += " p.wx_safe_status='" + wx_safe_status + "',";
|
||
sql += " p.mdy_time='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',";
|
||
sql = sql.TrimEnd(',');
|
||
sql += " where p.spu_id in('" + ids + "')";
|
||
|
||
|
||
|
||
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\":\"输入为空\"}";
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 更新爆款数据商品
|
||
/// </summary>
|
||
/// <param name="inputData"></param>
|
||
/// <returns></returns>
|
||
public string MdyBestSaleProd(string inputData)
|
||
{
|
||
if (!string.IsNullOrEmpty(inputData))
|
||
{
|
||
var time = 0;
|
||
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "time"), out time);
|
||
string time1 = RegexUtils.GetStringQuery(ref inputData, "code");
|
||
if (time1 != EncrypUtil.Encryption(time))
|
||
return "{\"code\":50000,\"msg\":\"校验失败\"}";
|
||
|
||
string user_name = RegexUtils.GetStringQuery(ref inputData, "user_name")?.Replace("'", "\\'");
|
||
if (string.IsNullOrEmpty(user_name))
|
||
{
|
||
return "{\"code\":500,\"msg\":\"没有用户名\"}";
|
||
}
|
||
|
||
string spu_id = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "spu_id"))?.Replace("'", "\\'");
|
||
int? view_uv = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "view_uv"))?.ParseToNullableInt();
|
||
if (view_uv == null || string.IsNullOrWhiteSpace(spu_id))
|
||
return "{\"code\":500,\"msg\":\"缺少商品曝光率或编号信息\"}";
|
||
|
||
string conn = "ConnKJD";
|
||
MysqlUtils mySql = new MysqlUtils(conn);
|
||
|
||
string tableName = GetProductTableName(inputData);
|
||
string sql = "";
|
||
|
||
sql = "update " + tableName + " p set";
|
||
if (view_uv != null)
|
||
sql += " p.view_uv=" + view_uv + ",";
|
||
sql += " p.mdy_time='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',";
|
||
sql = sql.TrimEnd(',');
|
||
sql += " where p.spu_id='" + spu_id + "' and p.special_prod_type='爆款数据'";
|
||
|
||
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\":\"输入为空\"}";
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取商品SpuId(快速查询)
|
||
/// </summary>
|
||
/// <param name="inputData"></param>
|
||
/// <returns></returns>
|
||
public string GetProductSpuIdLst(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 version = RegexUtils.GetStringQuery(ref inputData, "version").ParseToInt();
|
||
if (version < (System.Configuration.ConfigurationManager.ConnectionStrings["LimitVersion"]?.ConnectionString).ParseToInt())
|
||
return "{\"code\":1,\"msg\":\"当前版本过于陈旧,请立即升级新版\"}";
|
||
|
||
var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name")?.Replace("'", "\\'");
|
||
var password = RegexUtils.GetStringQuery(ref inputData, "password")?.Replace("'", "\\'");
|
||
var search_secret_spu_ids = RegexUtils.GetStringQuery(ref inputData, "search_secret_spu_ids")?.Replace("'", "\\'");
|
||
var search_spu_ids = RegexUtils.GetStringQuery(ref inputData, "search_spu_ids")?.Replace("'", "\\'");
|
||
var wx_safe_status = RegexUtils.GetStringQuery(ref inputData, "wx_safe_status")?.Replace("'", "\\'");
|
||
|
||
int page = RegexUtils.GetStringQuery(ref inputData, "page").ParseToInt();
|
||
int page_size = RegexUtils.GetStringQuery(ref inputData, "page_size").ParseToInt(500);
|
||
|
||
string conn = "ConnKJD";
|
||
MysqlUtils mySql = new MysqlUtils(conn);
|
||
|
||
string tableName = GetProductTableName(inputData);
|
||
string sql = "";
|
||
|
||
sql = "select id,spu_id,secret_spu_id from " + tableName + " p where p.is_del=0";
|
||
if (search_secret_spu_ids != null)
|
||
{
|
||
sql += " and p.secret_spu_id in ('" + string.Join("','", search_secret_spu_ids.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries)) + "')";
|
||
}
|
||
if (search_spu_ids != null)
|
||
{
|
||
sql += " and p.spu_id in ('" + string.Join("','", search_spu_ids.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries)) + "')";
|
||
}
|
||
if (wx_safe_status != null)
|
||
{
|
||
sql += " and p.wx_safe_status in ('" + string.Join("','", wx_safe_status.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries)) + "')";
|
||
}
|
||
var dt = mySql.ExecuteDataTable(sql);
|
||
|
||
mySql.Close();
|
||
if (dt != null)
|
||
{
|
||
try
|
||
{
|
||
List<DBProductResultParamLite> productLst = new List<DBProductResultParamLite>();
|
||
foreach (DataRow row in dt.Rows)
|
||
{
|
||
DBProductResultParamLite prod = new DBProductResultParamLite
|
||
{
|
||
id = Convert.ToInt32(row["id"]),
|
||
spu_id = row["spu_id"].ToString(),
|
||
secret_spu_id = row["secret_spu_id"].IsNullOrEmpty() ? null : row["secret_spu_id"].ParseToString(),
|
||
};
|
||
productLst.Add(prod);
|
||
}
|
||
JsonSerializerSettings jsonSetting = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore };
|
||
var data = JsonUtils.SerializeObjectToString(productLst, jsonSetting);
|
||
var seconds = (DateTime.Now - timeCalc).TotalSeconds.ToString("0.000");
|
||
return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"count\":" + productLst.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\":\"输入为空\"}";
|
||
}
|
||
|
||
/// <summary>
|
||
/// 查询商品列表
|
||
/// </summary>
|
||
/// <param name="inputData"></param>
|
||
/// <param name="isDetail"></param>
|
||
/// <returns></returns>
|
||
public string GetProductList(string inputData, bool isDetail = false)
|
||
{
|
||
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 version = RegexUtils.GetStringQuery(ref inputData, "version").ParseToInt();
|
||
if (version < (System.Configuration.ConfigurationManager.ConnectionStrings["LimitVersion"]?.ConnectionString).ParseToInt())
|
||
return "{\"code\":1,\"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_cat1 = RegexUtils.GetStringQuery(ref inputData, "search_cat1")?.Replace("'", "\\'");
|
||
var search_cat = RegexUtils.GetStringQuery(ref inputData, "search_cat")?.Replace("'", "\\'");
|
||
var wx_cat_1 = RegexUtils.GetStringQuery(ref inputData, "wx_cat_1")?.Replace("'", "\\'");
|
||
var wx_cat_2 = RegexUtils.GetStringQuery(ref inputData, "wx_cat_2")?.Replace("'", "\\'");
|
||
var wx_cat_3 = RegexUtils.GetStringQuery(ref inputData, "wx_cat_3")?.Replace("'", "\\'");
|
||
var wx_cat_leaf = RegexUtils.GetStringQuery(ref inputData, "wx_cat_leaf")?.Replace("'", "\\'");
|
||
var search_ext_code = RegexUtils.GetStringQuery(ref inputData, "search_ext_code")?.Replace("'", "\\'");
|
||
var search_prod_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "search_prod_name"))?.Replace("'", "\\'");
|
||
var search_prod_name_in = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "search_prod_name_in"))?.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 search_secret_spu_ids = RegexUtils.GetStringQuery(ref inputData, "search_secret_spu_ids")?.Replace("'", "\\'");
|
||
var ext_code_in = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "ext_code_in"))?.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 from_shop_name = RegexUtils.GetStringQuery(ref inputData, "from_shop_name")?.Replace("'", "\\'");
|
||
var product_get_type = RegexUtils.GetStringQuery(ref inputData, "product_get_type")?.Replace("'", "\\'");
|
||
var sort_field = RegexUtils.GetStringQuery(ref inputData, "sort_field")?.Replace("'", "\\'");
|
||
var wx_safe_status = RegexUtils.GetStringQuery(ref inputData, "wx_safe_status")?.Replace("'", "\\'");
|
||
var special_prod_type = RegexUtils.GetStringQuery(ref inputData, "special_prod_type")?.Replace("'", "\\'");
|
||
if (special_prod_type.IsNullOrEmpty())
|
||
special_prod_type = "普通商品";
|
||
var is_supplier_prod_ok = RegexUtils.GetStringQuery(ref inputData, "is_supplier_prod_ok")?.Replace("'", "\\'");
|
||
var has_wx_cat = RegexUtils.GetStringQuery(ref inputData, "has_wx_cat")?.Replace("'", "\\'");
|
||
var send_to_out_server = RegexUtils.GetStringQuery(ref inputData, "send_to_out_server")?.Replace("'", "\\'");
|
||
var real_coid = RegexUtils.GetStringQuery(ref inputData, "real_coid")?.Replace("'", "\\'");
|
||
var has_wx_format = RegexUtils.GetStringQuery(ref inputData, "has_wx_format")?.Replace("'", "\\'");
|
||
var problem_prod_data = RegexUtils.GetStringQuery(ref inputData, "problem_prod_data")?.Replace("'", "\\'");
|
||
var is_relation = RegexUtils.GetStringQuery(ref inputData, "is_relation")?.Replace("'", "\\'");
|
||
var add_time_begin = RegexUtils.GetStringQuery(ref inputData, "add_time_begin")?.Replace("'", "\\'");
|
||
var add_time_end = RegexUtils.GetStringQuery(ref inputData, "add_time_end")?.Replace("'", "\\'");
|
||
var start_time = RegexUtils.GetStringQuery(ref inputData, "start_time")?.Replace("'", "\\'");
|
||
var end_time = RegexUtils.GetStringQuery(ref inputData, "end_time")?.Replace("'", "\\'");
|
||
var ban_wx = RegexUtils.GetStringQuery(ref inputData, "ban_wx")?.Replace("'", "\\'");
|
||
var ban_pdd = RegexUtils.GetStringQuery(ref inputData, "ban_pdd")?.Replace("'", "\\'");
|
||
var add_user_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "add_user_name"))?.Replace("'", "\\'");
|
||
var min_view_uv = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "min_view_uv"))?.ParseToNullableInt();
|
||
var is_not_count = RegexUtils.GetStringQuery(ref inputData, "is_not_count") == "true"; // 不计数
|
||
var no_fission_words = RegexUtils.GetStringQuery(ref inputData, "no_fission_words").ParseToBool(); // 未裂变标题
|
||
var fission_words = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "fission_words"))?.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 tableName = GetProductTableName(inputData);
|
||
string sql = "";
|
||
List<string> forceIndex = new List<string>() { };
|
||
if (!isDetail)
|
||
{
|
||
if (!search_prod_name.IsNullOrEmpty() || !search_prod_name_in.IsNullOrEmpty())
|
||
forceIndex.Add("index_product_name");
|
||
if (!search_spu.IsNullOrEmpty())
|
||
forceIndex.Add("index_spu_id");
|
||
if (!search_skc.IsNullOrEmpty())
|
||
forceIndex.Add("index_skc_id");
|
||
if (!search_secret_spu_ids.IsNullOrEmpty())
|
||
forceIndex.Add("index_secret_spu_id");
|
||
if (min_view_uv > 0)
|
||
forceIndex.Add("index_view_uv");
|
||
if (!search_group.IsNullOrEmpty())
|
||
forceIndex.Add("index_group");
|
||
if (!from_shop_id.IsNullOrEmpty())
|
||
forceIndex.Add("index_from_shop_id");
|
||
if (!from_shop_name.IsNullOrEmpty())
|
||
forceIndex.Add("index_from_shop_name");
|
||
if (!ext_code_in.IsNullOrEmpty() || !search_ext_code.IsNullOrEmpty())
|
||
forceIndex.Add("index_ext_code");
|
||
//if (!add_user_name.IsNullOrEmpty())
|
||
// forceIndex.Add("index_add_user_name");
|
||
if (!search_notes.IsNullOrEmpty())
|
||
forceIndex.Add("index_notes");
|
||
if (!start_time.IsNullOrEmpty())
|
||
forceIndex.Add("index_mdy_time");
|
||
|
||
if (!forceIndex.Contains("index_view_uv"))
|
||
forceIndex.Add("index_sort_add_time");
|
||
}
|
||
|
||
List<MySqlParameter> paramLst = new List<MySqlParameter>();
|
||
|
||
sql = " select count(*) from " + tableName + " p ";
|
||
//sql += " LEFT JOIN bxx.jst_supplier_ban_platform b ON (p.skc_id=b.coid or p.real_coid=b.coid)" +
|
||
if (forceIndex.Count > 0)
|
||
sql += " FORCE INDEX(" + string.Join(",", forceIndex) + ")";
|
||
sql += " WHERE p.is_del=0";
|
||
|
||
string where = "";
|
||
if (!string.IsNullOrEmpty(from_shop_id))
|
||
where += " and p.from_shop_id='" + from_shop_id + "'";
|
||
if (!string.IsNullOrEmpty(from_shop_name))
|
||
where += " and p.from_shop_name='" + from_shop_name + "'";
|
||
if (!string.IsNullOrEmpty(search_db_ids))
|
||
where += " and p.id in (" + search_db_ids + ")";
|
||
if (!string.IsNullOrEmpty(search_secret_spu_ids))
|
||
where += " and p.secret_spu_id in ('" + string.Join("','", search_secret_spu_ids.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries)) + "')";
|
||
if (!string.IsNullOrWhiteSpace(ext_code_in))
|
||
where += " and p.ext_code in ('" + string.Join("','", ext_code_in.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries)) + "')";
|
||
if (!string.IsNullOrEmpty(product_get_type))
|
||
where += " and p.product_get_type in ('" + product_get_type.Replace(",", "','") + "')";
|
||
else
|
||
where += " and p.product_get_type in ('厂商直采','1688厂家','1688外部数据','微信小店','微信店采','母店采集','机会商品','以图搜品','多多外部数据')";
|
||
if (!string.IsNullOrEmpty(wx_safe_status))
|
||
where += " and p.wx_safe_status in ('" + wx_safe_status.Replace(",", "','") + "')";
|
||
if (!string.IsNullOrEmpty(special_prod_type)/* && special_prod_type != "普通商品,爆款数据"*/)
|
||
where += " and p.special_prod_type in ('" + special_prod_type.Replace(",", "','") + "')";
|
||
|
||
if (!string.IsNullOrWhiteSpace(search_spu))
|
||
{
|
||
if (search_spu.Contains(",") || search_spu.Contains(",") || search_spu.Contains(";") || search_spu.Contains(";"))
|
||
where += " and p.spu_id in ('" + string.Join("','", search_spu.Split(new string[] { ",", ",", ";", ";" }, StringSplitOptions.RemoveEmptyEntries)) + "')";
|
||
else
|
||
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_cat1))
|
||
where += " and p.main_cat_name like '" + search_cat1 + "%'";
|
||
if (!string.IsNullOrWhiteSpace(search_ext_code))
|
||
where += " and p.ext_code like '" + search_ext_code + "%'";
|
||
if (!string.IsNullOrWhiteSpace(search_prod_name))
|
||
{
|
||
var searchProdNameWords = search_prod_name.Split(new string[] { ",", ",", ";", ";", "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries);
|
||
var multi_search_prod_name = "";
|
||
var index = 0;
|
||
foreach (var word in searchProdNameWords)
|
||
{
|
||
index++;
|
||
string parameName = "@prodNameWords" + index;
|
||
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = parameName, Value = word/*.Replace("&", "&").Replace("'", "\\'")*/, });
|
||
//multi_search_prod_name += " or p.product_name like '%" + parameName + "%'";
|
||
//multi_search_prod_name += " or p.product_name like CONCAT('%'," + parameName + ",'%')";
|
||
multi_search_prod_name += " or p.product_name like CONCAT(" + parameName + ",'%')";
|
||
|
||
}
|
||
where += " and (" + multi_search_prod_name.Substring(4) + ")";
|
||
|
||
//where += " and p.product_name like '" + search_prod_name + "'";
|
||
}
|
||
if (!string.IsNullOrWhiteSpace(search_prod_name_in))
|
||
{
|
||
where += " and p.product_name in ('" + search_prod_name_in.Replace(",", "','") + "')";
|
||
}
|
||
if (!string.IsNullOrWhiteSpace(search_group))
|
||
{
|
||
if (search_group == "无分组")
|
||
where += " and (p.group is null or p.group = '')";
|
||
else
|
||
where += " and p.group like '" + search_group + "%'";
|
||
}
|
||
if (!string.IsNullOrWhiteSpace(search_notes))
|
||
where += " and p.notes like '" + search_notes + "%'";
|
||
|
||
if (!string.IsNullOrWhiteSpace(wx_cat_1))
|
||
where += " and p.wx_cat_1 in (" + wx_cat_1 + ")";
|
||
if (!string.IsNullOrWhiteSpace(wx_cat_2))
|
||
where += " and p.wx_cat_2 in (" + wx_cat_2 + ")";
|
||
if (!string.IsNullOrWhiteSpace(wx_cat_3))
|
||
where += " and p.wx_cat_3 in (" + wx_cat_3 + ")";
|
||
if (!string.IsNullOrWhiteSpace(wx_cat_leaf))
|
||
where += " and p.wx_cat_leaf in (" + wx_cat_leaf + ")";
|
||
|
||
if (!string.IsNullOrEmpty(has_wx_cat))
|
||
{
|
||
if (has_wx_cat.ToLower() == "true")
|
||
where += " and p.wx_cat_3 >= 0";
|
||
else
|
||
where += " and p.wx_cat_3 IS NULL";
|
||
}
|
||
if (!string.IsNullOrEmpty(send_to_out_server))
|
||
where += " and p.send_to_out_server in (" + send_to_out_server + ")";
|
||
// 供应商货源是否已完成初始设置
|
||
if (!string.IsNullOrEmpty(is_supplier_prod_ok))
|
||
{
|
||
//if (is_supplier_prod_ok == "1" || is_supplier_prod_ok == "已设置")
|
||
// where += " and wx_cat_leaf IS NOT NULL and send_to_out_server=1 and delivery_fee_set=1 and after_sale_set=1 and distribution_set=1";
|
||
//else
|
||
// where += " and (wx_cat_leaf IS NULL or send_to_out_server=0 or delivery_fee_set=0 or after_sale_set=0 or distribution_set=0)";
|
||
if (is_supplier_prod_ok == "1" || is_supplier_prod_ok == "是" || is_supplier_prod_ok == "已设置")
|
||
where += " and p.wx_cat_3 IS NOT NULL and p.send_to_out_server IN (1,127) and p.distribution_set IN (1,127)";
|
||
else
|
||
where += " and (p.wx_cat_3 IS NULL or p.send_to_out_server NOT IN (1,127) or p.distribution_set NOT IN (1,127))";
|
||
}
|
||
if (!where.Contains("send_to_out_server"))
|
||
{
|
||
where += " and p.send_to_out_server IN (0,1,2,127)";
|
||
}
|
||
if (!where.Contains("distribution_set"))
|
||
{
|
||
where += " and p.distribution_set IN (0,1,2,127)";
|
||
}
|
||
|
||
if (!string.IsNullOrEmpty(real_coid))
|
||
{
|
||
where += " and p.real_coid='" + real_coid + "'";
|
||
}
|
||
if (!string.IsNullOrEmpty(has_wx_format))
|
||
{
|
||
where += " and p.has_wx_format='" + has_wx_format + "'";
|
||
}
|
||
if (!string.IsNullOrEmpty(problem_prod_data))
|
||
{
|
||
if (problem_prod_data.ToLower().Contains("is null"))
|
||
where += " and p.problem_prod_data " + problem_prod_data;
|
||
else
|
||
where += " and p.problem_prod_data='" + problem_prod_data + "'";
|
||
}
|
||
if (!string.IsNullOrEmpty(is_relation))
|
||
{
|
||
where += " and p.is_relation=" + is_relation;
|
||
}
|
||
if (add_time_begin != null && add_time_end != null)
|
||
{
|
||
where += " and p.add_time between '" + add_time_begin + "' and '" + add_time_end + "'";
|
||
}
|
||
if (start_time != null && end_time != null)
|
||
{
|
||
where += " and p.mdy_time between '" + start_time + "' and '" + end_time + "'";
|
||
}
|
||
if (ban_wx != null)
|
||
{
|
||
where += " and p.ban_wx=" + ban_wx;
|
||
}
|
||
else
|
||
{
|
||
where += " and p.ban_wx in (0,1)";
|
||
}
|
||
if (ban_pdd != null)
|
||
{
|
||
where += " and p.ban_pdd=" + ban_pdd;
|
||
}
|
||
else
|
||
{
|
||
where += " and p.ban_pdd in (0,1)";
|
||
}
|
||
if (min_view_uv != null)
|
||
{
|
||
where += " and p.view_uv>=" + min_view_uv;
|
||
}
|
||
if (!string.IsNullOrEmpty(add_user_name))
|
||
{
|
||
add_user_name = "'" + string.Join("','", add_user_name.Split(new string[] { ",", ",", " " }, StringSplitOptions.RemoveEmptyEntries)) + "'";
|
||
where += " and p.add_user_name in (" + add_user_name + ")";
|
||
}
|
||
else
|
||
{
|
||
// 目前客户端即使是自有库查详情的时候也有没传 todo 每次查询都传参,或者就不管,详情会命中其他索引
|
||
//where += " and p.add_user_name='admin'";
|
||
}
|
||
if (no_fission_words)
|
||
{
|
||
where += " and (fission_words='' or fission_words IS NULL)";
|
||
}
|
||
if (!string.IsNullOrEmpty(fission_words))
|
||
{
|
||
where += " and fission_words LIKE '" + fission_words + "%'";
|
||
}
|
||
sql += where;
|
||
|
||
var count = 0;
|
||
if (isDetail || is_not_count)
|
||
count = 1;
|
||
else
|
||
{
|
||
count = mySql.ExecuteRowCount(sql, paramLst.ToArray());
|
||
}
|
||
|
||
DataTable dt;
|
||
if (count == 0)
|
||
{
|
||
dt = new DataTable();
|
||
}
|
||
else
|
||
{
|
||
sql = " SELECT p.id " +
|
||
" FROM " + tableName + " p";
|
||
if (forceIndex.Count > 0)
|
||
sql += " FORCE INDEX(" + string.Join(",", forceIndex) + ")";
|
||
sql += " WHERE p.is_del=0";
|
||
|
||
//where子句
|
||
sql += where;
|
||
|
||
if (sort_field == "view_uv")
|
||
sql += " order by p.view_uv desc, p.add_time desc";
|
||
else
|
||
sql += " order by p.add_time desc";
|
||
sql += " limit " + Math.Max(page - 1, 0) * page_size + "," + page_size;
|
||
dt = mySql.ExecuteDataTable(sql, paramLst.ToArray());
|
||
|
||
if (!string.IsNullOrEmpty(mySql.Message) || dt == null)
|
||
{
|
||
mySql.Close();
|
||
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\",\"data\":[],\"count\":" + 0 + "}";
|
||
}
|
||
var db_ids = string.Join(",", dt.Rows.Cast<DataRow>().Select(r => r["id"].ParseToInt()));
|
||
if (string.IsNullOrEmpty(db_ids))
|
||
{
|
||
mySql.Close();
|
||
return "{\"code\":200,\"data\":[],\"count\":" + 0 + "}";
|
||
}
|
||
|
||
|
||
if (isDetail)
|
||
sql = " SELECT p.*" +
|
||
" from " + tableName + " p" +
|
||
" 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.fission_words,p.head_words,p.end_words,p.group," +
|
||
" p.product_get_type,p.wx_safe_status,p.sale_count,p.sale_count_text,p.special_prod_type,p.from_shop_name,p.wx_cat_1,p.wx_cat_2,p.wx_cat_3," +
|
||
" p.wx_cat_leaf,p.send_to_out_server,p.secret_spu_id,p.real_coid,p.real_spu_id,p.is_relation,p.view_uv,p.add_user_name" +
|
||
" FROM " + tableName + " p" +
|
||
" WHERE p.is_del=0";
|
||
|
||
sql += " and id in (" + db_ids + ")";
|
||
dt = mySql.ExecuteDataTable(sql, paramLst.ToArray());
|
||
}
|
||
|
||
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(),
|
||
from_shop_name = row["from_shop_name"].ToString(),
|
||
//offline_supplier_id = row["offline_supplier_id"].ToString(),
|
||
//offline_supplier_name = row["offline_supplier_name"].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(),
|
||
wx_cat_1 = row["wx_cat_1"].ToString(),
|
||
wx_cat_2 = row["wx_cat_2"].ToString(),
|
||
wx_cat_3 = row["wx_cat_3"].ToString(),
|
||
wx_cat_leaf = row["wx_cat_leaf"].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(),
|
||
product_get_type_text = row["product_get_type"].ToString(),
|
||
view_uv = row["view_uv"].ParseToNullableInt(),
|
||
sale_count = row["sale_count"].ParseToInt(),
|
||
sale_count_text = row["sale_count_text"].ToString(),
|
||
wx_safe_status = row["wx_safe_status"].ToString(),
|
||
special_prod_type = row["special_prod_type"].ToString(),
|
||
main_cat_id = row["main_cat_id"].ToString(),
|
||
main_cat_name = row["main_cat_name"].ToString(),
|
||
send_to_out_server = row["send_to_out_server"].ParseToInt(),
|
||
secret_spu_id = row["secret_spu_id"].IsNullOrEmpty() ? null : row["secret_spu_id"].ParseToString(),
|
||
real_coid = row["real_coid"].IsNullOrEmpty() ? null : row["real_coid"].ParseToString(),
|
||
real_spu_id = row["real_spu_id"].IsNullOrEmpty() ? null : row["real_spu_id"].ParseToString(),
|
||
is_relation = row["is_relation"].ParseToInt(),
|
||
add_user_name = row["add_user_name"].ParseToString(),
|
||
};
|
||
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_secret_json = row["sku_secret_json"].ToString();
|
||
prod.fission_imgs = row["fission_imgs"].ToString();
|
||
prod.has_wx_format = row["has_wx_format"].ParseToNullableString(); // 微信回采
|
||
prod.wx_img_map_json = row["wx_img_map_json"].ToString();
|
||
problem_prod_data = row["problem_prod_data"].IsNullOrEmpty() ? null : row["problem_prod_data"].ParseToString();
|
||
|
||
if (!prod.sku_secret_json.IsNullOrEmpty() && prod.secret_spu_id.IsNullOrEmpty())
|
||
{
|
||
var secret_json = prod.sku_secret_json;
|
||
var goodsId = RegexUtils.GetStringJson(ref secret_json, "goodsId");
|
||
prod.secret_spu_id = goodsId;
|
||
if (!string.IsNullOrWhiteSpace(goodsId))
|
||
{
|
||
mySql = new MysqlUtils(conn);
|
||
try
|
||
{
|
||
sql = "update " + tableName + " set secret_spu_id='" + goodsId + "' where spu_id='" + prod.spu_id + "'";
|
||
mySql.ExecuteNonQuery(sql);
|
||
}
|
||
catch { }
|
||
mySql.Close();
|
||
}
|
||
}
|
||
if (prod.product_json.Contains("\"source_json\"") && !prod.product_json.Contains("\"source_json\":null"))
|
||
{
|
||
mySql = new MysqlUtils(conn);
|
||
try
|
||
{
|
||
JObject jObj = JsonUtils.JObjectParse(prod.product_json);
|
||
jObj["source_json"] = null;
|
||
var newProdJson = JsonUtils.SerializeObject(jObj);
|
||
sql = "update " + tableName + " set product_json=@product_json where spu_id='" + prod.spu_id + "'";
|
||
paramLst = new List<MySqlParameter>();
|
||
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "product_json", Value = newProdJson, });
|
||
mySql.ExecuteNonQuery(sql, paramLst.ToArray());
|
||
prod.product_json = newProdJson;
|
||
}
|
||
catch
|
||
{
|
||
}
|
||
mySql.Close();
|
||
}
|
||
if (prod.product_json.Contains(":null"))
|
||
{
|
||
mySql = new MysqlUtils(conn);
|
||
try
|
||
{
|
||
JObject jObj = JsonUtils.JObjectParse(prod.product_json);
|
||
|
||
RemoveNullProperties(jObj);
|
||
|
||
JsonSerializerSettings jsonIgnoreNullSetting = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore };
|
||
var newProdJson = JsonUtils.SerializeObjectToString(jObj, jsonIgnoreNullSetting);
|
||
|
||
sql = "update " + tableName + " set product_json=@product_json where spu_id='" + prod.spu_id + "'";
|
||
paramLst = new List<MySqlParameter>();
|
||
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "product_json", Value = newProdJson, });
|
||
mySql.ExecuteNonQuery(sql, paramLst.ToArray());
|
||
prod.product_json = newProdJson;
|
||
|
||
//sql = "DELETE FROM " + tableName + " where is_del = 1 AND add_time < '" + DateTime.Now.AddDays(-10) + "' ORDER BY add_time DESC limit 1;";
|
||
}
|
||
catch
|
||
{
|
||
}
|
||
mySql.Close();
|
||
}
|
||
}
|
||
if (!string.IsNullOrEmpty(get_select_count))
|
||
{
|
||
prod.select_count = row["select_count"].ParseToInt();
|
||
}
|
||
productLst.Add(prod);
|
||
}
|
||
JsonSerializerSettings jsonSetting = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore };
|
||
var data = JsonUtils.SerializeObjectToString(productLst, jsonSetting);
|
||
var seconds = (DateTime.Now - timeCalc).TotalSeconds.ToString("0.000");
|
||
if (is_not_count)
|
||
count = productLst.Count;
|
||
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\":\"输入为空\"}";
|
||
}
|
||
|
||
/// <summary>
|
||
/// 递归剔除JObject中值为null的字段 (修改为null才删除,empty不删除)
|
||
/// </summary>
|
||
public static void RemoveNullProperties(JToken token)
|
||
{
|
||
if (token.Type == JTokenType.Object)
|
||
{
|
||
var jObj = (JObject)token;
|
||
var propertiesToRemove = jObj.Properties()
|
||
//.Where(p =>
|
||
// p.Value == null ||
|
||
// p.Value.Type == JTokenType.Null ||
|
||
// (p.Value.Type == JTokenType.String && string.IsNullOrEmpty((string)p.Value)) ||
|
||
// (p.Value.Type == JTokenType.String && string.IsNullOrWhiteSpace((string)p.Value)) ||
|
||
// (p.Value.Type == JTokenType.Array && !p.Value.HasValues))
|
||
.Where(p =>
|
||
p.Value == null ||
|
||
p.Value.Type == JTokenType.Null)
|
||
.ToList();
|
||
|
||
foreach (var prop in propertiesToRemove)
|
||
prop.Remove();
|
||
|
||
foreach (var child in jObj.Children())
|
||
{
|
||
if (child.Children().Count() > 0)
|
||
{
|
||
RemoveNullProperties(child);
|
||
}
|
||
}
|
||
}
|
||
else if (token.Type == JTokenType.Property)
|
||
{
|
||
if (token.Children().Count() > 0)
|
||
{
|
||
var childs = token.Children()
|
||
//.Where(p =>
|
||
// p == null ||
|
||
// p.Type == JTokenType.Null ||
|
||
// (p.Type == JTokenType.String && string.IsNullOrEmpty((string)p)) ||
|
||
// (p.Type == JTokenType.String && string.IsNullOrWhiteSpace((string)p)) ||
|
||
// (p.Type == JTokenType.Array && !p.HasValues))
|
||
.Where(p =>
|
||
p == null ||
|
||
p.Type == JTokenType.Null)
|
||
.ToList();
|
||
|
||
foreach (var prop in childs)
|
||
prop.Remove();
|
||
foreach (var child in token.Children())
|
||
{
|
||
if (child.Children().Count() > 0)
|
||
{
|
||
RemoveNullProperties(child);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
else if (token.Type == JTokenType.Array)
|
||
{
|
||
var jArray = (JArray)token;
|
||
|
||
// 清理数组内部的 null / ""
|
||
for (int i = jArray.Count - 1; i >= 0; i--)
|
||
{
|
||
var item = jArray[i];
|
||
//if (item.Type == JTokenType.Null ||
|
||
// (item.Type == JTokenType.String && string.IsNullOrWhiteSpace((string)item)))
|
||
if (item.Type == JTokenType.Null)
|
||
{
|
||
jArray.RemoveAt(i);
|
||
}
|
||
}
|
||
|
||
// 递归数组内对象/子数组
|
||
foreach (var child in jArray)
|
||
RemoveNullProperties(child);
|
||
|
||
//// 如果数组最后变空,也删除
|
||
//if (!jArray.HasValues)
|
||
//{
|
||
// if (jArray.Parent is JProperty prop)
|
||
// prop.Remove();
|
||
//}
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 回采微信小店属性等商品数据入库
|
||
/// </summary>
|
||
/// <param name="inputData"></param>
|
||
/// <returns></returns>
|
||
public string AddProdWXComplate(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("'", "\\'");
|
||
var password = RegexUtils.GetStringQuery(ref inputData, "password")?.Replace("'", "\\'");
|
||
if (user_name.IsNullOrEmpty())
|
||
{
|
||
return "{\"code\":500,\"msg\":\"用户信息不能为空\"}";
|
||
}
|
||
|
||
var spu_id = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "spu_id")).ParseToString().Replace("'", "\\'");
|
||
var coid = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "coid")).ParseToString().Replace("'", "\\'");
|
||
var secret_spu_id = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "secret_spu_id")).ParseToString().Replace("'", "\\'");
|
||
var wx_edit_prod_json = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "wx_edit_prod_json")).ParseToString().Replace("'", "\\'");
|
||
if (secret_spu_id.IsNullOrEmpty() || wx_edit_prod_json.IsNullOrEmpty())
|
||
{
|
||
return "{\"code\":500,\"msg\":\"商品回采数据不能为空\"}";
|
||
}
|
||
|
||
string conn = "ConnKJD";
|
||
MysqlUtils mySql = new MysqlUtils(conn);
|
||
|
||
string tableName = GetProductTableName(inputData);
|
||
tableName = "bxx.product"; // 回采只支持主库,后续可能删除回采功能
|
||
string sql = "";
|
||
|
||
sql = "INSERT INTO bxx.product_wx_complate (spu_id,coid,secret_spu_id,wx_edit_prod_json) VALUES " +
|
||
" ('" + spu_id + "','" + coid + "','" + secret_spu_id + "','" + wx_edit_prod_json + "')" +
|
||
" ON DUPLICATE KEY UPDATE spu_id=VALUES(spu_id),coid=VALUES(coid),wx_edit_prod_json=VALUES(wx_edit_prod_json);";
|
||
|
||
var rst = mySql.ExecuteNonQuery(sql);
|
||
if (!rst || !string.IsNullOrEmpty(mySql.Message))
|
||
{
|
||
mySql.Close();
|
||
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}";
|
||
}
|
||
|
||
sql = "UPDATE " + tableName + " set has_wx_format='1' where secret_spu_id='" + secret_spu_id + "'";
|
||
rst = mySql.ExecuteNonQuery(sql);
|
||
mySql.Close();
|
||
if (!rst || !string.IsNullOrEmpty(mySql.Message))
|
||
{
|
||
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}";
|
||
}
|
||
else
|
||
{
|
||
var seconds = (DateTime.Now - timeCalc).TotalSeconds.ToString("0.000");
|
||
return "{\"code\":200,\"msg\":\"success\",\"seconds\":" + seconds + "}";
|
||
}
|
||
}
|
||
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
||
}
|
||
|
||
/// <summary>
|
||
/// 查询回采微信小店属性等商品数据
|
||
/// </summary>
|
||
/// <param name="inputData"></param>
|
||
/// <returns></returns>
|
||
public string GetProdWXComplateList(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("'", "\\'");
|
||
var password = RegexUtils.GetStringQuery(ref inputData, "password")?.Replace("'", "\\'");
|
||
if (user_name.IsNullOrEmpty())
|
||
{
|
||
return "{\"code\":500,\"msg\":\"用户信息不能为空\"}";
|
||
}
|
||
|
||
var spu_id = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "spu_id")).ParseToString().Replace("'", "\\'");
|
||
var coid = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "coid")).ParseToString().Replace("'", "\\'");
|
||
var search_secret_spu_ids = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "search_secret_spu_ids")).ParseToString().Replace("'", "\\'");
|
||
if (search_secret_spu_ids.IsNullOrEmpty())
|
||
{
|
||
return "{\"code\":500,\"msg\":\"商品回采数据编号不能为空\"}";
|
||
}
|
||
|
||
int page = RegexUtils.GetStringQuery(ref inputData, "page").ParseToInt();
|
||
int page_size = RegexUtils.GetStringQuery(ref inputData, "page_size").ParseToInt(1000);
|
||
|
||
string conn = "ConnKJD";
|
||
MysqlUtils mySql = new MysqlUtils(conn);
|
||
|
||
string sql = "select id,spu_id,coid,secret_spu_id,wx_edit_prod_json,add_time" +
|
||
" from bxx.product_wx_complate p where 1=1";
|
||
if (search_secret_spu_ids != null)
|
||
{
|
||
sql += " and p.secret_spu_id in ('" + string.Join("','", search_secret_spu_ids.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries)) + "')";
|
||
}
|
||
sql += " limit " + Math.Max(page - 1, 0) * page_size + "," + page_size;
|
||
var dt = mySql.ExecuteDataTable(sql);
|
||
|
||
mySql.Close();
|
||
if (dt != null)
|
||
{
|
||
try
|
||
{
|
||
JArray wxProdComplateArr = new JArray();
|
||
foreach (DataRow row in dt.Rows)
|
||
{
|
||
JObject wxProdComplateObj = new JObject();
|
||
wxProdComplateObj["id"] = Convert.ToInt32(row["id"]);
|
||
wxProdComplateObj["spu_id"] = row["spu_id"].ToString();
|
||
wxProdComplateObj["coid"] = row["coid"].ToString();
|
||
wxProdComplateObj["secret_spu_id"] = row["secret_spu_id"].ToString();
|
||
wxProdComplateObj["wx_edit_prod_json"] = row["wx_edit_prod_json"].ToString();
|
||
wxProdComplateObj["add_time"] = Convert.ToDateTime(row["add_time"]);
|
||
wxProdComplateArr.Add(wxProdComplateObj);
|
||
}
|
||
JsonSerializerSettings jsonSetting = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore };
|
||
var data = JsonUtils.SerializeObjectToString(wxProdComplateArr, jsonSetting);
|
||
var seconds = (DateTime.Now - timeCalc).TotalSeconds.ToString("0.000");
|
||
return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"count\":" + wxProdComplateArr.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\":\"输入为空\"}";
|
||
}
|
||
|
||
/// <summary>
|
||
/// 新增下架sku
|
||
/// </summary>
|
||
/// <param name="inputData"></param>
|
||
/// <returns></returns>
|
||
public string AddProdDownSku(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("'", "\\'");
|
||
var password = RegexUtils.GetStringQuery(ref inputData, "password")?.Replace("'", "\\'");
|
||
|
||
var itemMainImage = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "itemMainImage")).ParseToString().Replace("'", "\\'");
|
||
var itemName = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "itemName")).ParseToString().Replace("'", "\\'");
|
||
var styleCode = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "styleCode")).ParseToString().Replace("'", "\\'");
|
||
var itemCode = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "itemCode")).ParseToString().Replace("'", "\\'");
|
||
var colourSpec = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "colourSpec")).ParseToString().Replace("'", "\\'");
|
||
var supplyPrice = RegexUtils.GetStringQuery(ref inputData, "supplyPrice").ParseToString().Replace("'", "\\'");
|
||
var supplierName = RegexUtils.GetStringQuery(ref inputData, "supplierName").ParseToString().Replace("'", "\\'");
|
||
var shelvesTime = RegexUtils.GetStringQuery(ref inputData, "shelvesTime").ParseToString().Replace("'", "\\'");
|
||
var supplierCoId = RegexUtils.GetStringQuery(ref inputData, "supplierCoId").ParseToString().Replace("'", "\\'");
|
||
var coId = RegexUtils.GetStringQuery(ref inputData, "coId").ParseToString().Replace("'", "\\'");
|
||
var spuId = RegexUtils.GetStringQuery(ref inputData, "spuId").ParseToString().Replace("'", "\\'");
|
||
var partnerSkuId = RegexUtils.GetStringQuery(ref inputData, "partnerSkuId").ParseToString().Replace("'", "\\'");
|
||
var partnerSpuId = RegexUtils.GetStringQuery(ref inputData, "partnerSpuId").ParseToString().Replace("'", "\\'");
|
||
var supplierId = RegexUtils.GetStringQuery(ref inputData, "supplierId").ParseToString().Replace("'", "\\'");
|
||
var drpItemStatus = RegexUtils.GetStringQuery(ref inputData, "drpItemStatus").ParseToString().Replace("'", "\\'");
|
||
var lastOperator = RegexUtils.GetStringQuery(ref inputData, "lastOperator").ParseToString().Replace("'", "\\'");
|
||
var itemSpuIdMd5 = RegexUtils.GetStringQuery(ref inputData, "itemSpuIdMd5").ParseToString().Replace("'", "\\'");
|
||
var secret_spu_id = RegexUtils.GetStringQuery(ref inputData, "secret_spu_id").ParseToString().Replace("'", "\\'");
|
||
var secret_sku_id = RegexUtils.GetStringQuery(ref inputData, "secret_sku_id").ParseToString().Replace("'", "\\'");
|
||
var is_in_product_db = RegexUtils.GetStringQuery(ref inputData, "is_in_product_db").ParseToInt();
|
||
|
||
string conn = "ConnKJD";
|
||
MysqlUtils mySql = new MysqlUtils(conn);
|
||
|
||
string sql = "";
|
||
sql = "select styleCode,itemCode,colourSpec from bxx.product_jst_update where styleCode='" + styleCode +
|
||
"' and itemCode='" + itemCode + "' and colourSpec='" + colourSpec + "'";
|
||
var dt = mySql.ExecuteDataTable(sql);
|
||
if (!string.IsNullOrEmpty(mySql.Message))
|
||
{
|
||
mySql.Close();
|
||
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}";
|
||
}
|
||
if (dt.Rows.Count > 0)
|
||
{
|
||
mySql.Close();
|
||
return "{\"code\":500,\"msg\":\"数据已存在\"}";
|
||
}
|
||
|
||
sql = "insert into bxx.product_jst_update " +
|
||
" (itemMainImage,itemName,styleCode,itemCode,colourSpec,supplyPrice,supplierName,shelvesTime,supplierCoId,coId,spuId," +
|
||
" partnerSkuId,partnerSpuId,supplierId,drpItemStatus,lastOperator,itemSpuIdMd5,secret_spu_id,secret_sku_id,is_in_product_db)" +
|
||
" values('" + itemMainImage + "','" + itemName + "','" + styleCode + "','" + itemCode + "','" + colourSpec + "','" + supplyPrice + "','" +
|
||
supplierName + "','" + shelvesTime + "','" + supplierCoId + "','" + coId + "','" + spuId + "','" + partnerSkuId + "','" +
|
||
partnerSpuId + "','" + supplierId + "','" + drpItemStatus + "','" + lastOperator + "','" + itemSpuIdMd5 + "','" + secret_spu_id + "','"
|
||
+ secret_sku_id + "'," + is_in_product_db + ")";
|
||
|
||
//var rst = mySql.ExecuteNonQuery(sql, paramLst.ToArray());
|
||
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\":\"输入为空\"}";
|
||
}
|
||
|
||
/// <summary>
|
||
/// 查询下架sku
|
||
/// </summary>
|
||
/// <param name="inputData"></param>
|
||
/// <returns></returns>
|
||
public string GetProdDownSkuLstBySkuCodes(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 version = RegexUtils.GetStringQuery(ref inputData, "version").ParseToInt();
|
||
//if (version < (System.Configuration.ConfigurationManager.ConnectionStrings["LimitVersion"]?.ConnectionString).ParseToInt())
|
||
// return "{\"code\":1,\"msg\":\"当前版本过于陈旧,请立即升级新版\"}";
|
||
|
||
var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name")?.Replace("'", "\\'");
|
||
var password = RegexUtils.GetStringQuery(ref inputData, "password")?.Replace("'", "\\'");
|
||
var search_spu_ids = RegexUtils.GetStringQuery(ref inputData, "search_spu_ids")?.Replace("'", "\\'");
|
||
var search_sku_codes = RegexUtils.GetStringQuery(ref inputData, "search_sku_codes")?.Replace("'", "\\'");
|
||
var search_secret_spu_ids = RegexUtils.GetStringQuery(ref inputData, "search_secret_spu_ids")?.Replace("'", "\\'");
|
||
if (search_spu_ids.IsNullOrEmpty() && search_sku_codes.IsNullOrEmpty() && search_secret_spu_ids.IsNullOrEmpty())
|
||
return "{\"code\":500,\"msg\":\"查询条件不能全部为空\",\"data\":[],\"count\":" + 0 + "}";
|
||
|
||
int page = RegexUtils.GetStringQuery(ref inputData, "page").ParseToInt();
|
||
int page_size = RegexUtils.GetStringQuery(ref inputData, "page_size").ParseToInt(1000);
|
||
|
||
string conn = "ConnKJD";
|
||
MysqlUtils mySql = new MysqlUtils(conn);
|
||
|
||
string sql = "select id,spuId,itemName,styleCode,itemCode,colourSpec,supplierCoId,supplierName,is_in_product_db,secret_spu_id,secret_sku_id,add_time" +
|
||
" from bxx.product_jst_update p where 1=1";
|
||
if (search_secret_spu_ids != null)
|
||
{
|
||
sql += " and p.secret_spu_id in ('" + string.Join("','", search_secret_spu_ids.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries)) + "')";
|
||
}
|
||
if (search_spu_ids != null)
|
||
{
|
||
sql += " and p.spuId in ('" + string.Join("','", search_spu_ids.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries)) + "')";
|
||
}
|
||
if (search_sku_codes != null)
|
||
{
|
||
sql += " and p.itemCode in ('" + string.Join("','", search_sku_codes.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries)) + "')";
|
||
}
|
||
sql += " limit " + Math.Max(page - 1, 0) * page_size + "," + page_size;
|
||
var dt = mySql.ExecuteDataTable(sql);
|
||
|
||
mySql.Close();
|
||
if (dt != null)
|
||
{
|
||
try
|
||
{
|
||
List<JSTDownProdSkuInfo> productLst = new List<JSTDownProdSkuInfo>();
|
||
foreach (DataRow row in dt.Rows)
|
||
{
|
||
JSTDownProdSkuInfo prod = new JSTDownProdSkuInfo
|
||
{
|
||
id = Convert.ToInt32(row["id"]),
|
||
spuId = row["spuId"].ToString(),
|
||
itemName = row["itemName"].ToString(),
|
||
styleCode = row["styleCode"].ToString(),
|
||
itemCode = row["itemCode"].ToString(),
|
||
colourSpec = row["colourSpec"].ToString(),
|
||
supplierCoId = row["supplierCoId"].ToString(),
|
||
supplierName = row["supplierName"].ToString(),
|
||
add_time = Convert.ToDateTime(row["add_time"]),
|
||
is_in_product_db = row["is_in_product_db"].ParseToInt(),
|
||
secret_spu_id = row["secret_spu_id"].ParseToString(),
|
||
secret_sku_id = row["secret_sku_id"].ParseToString(),
|
||
};
|
||
productLst.Add(prod);
|
||
}
|
||
JsonSerializerSettings jsonSetting = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore };
|
||
var data = JsonUtils.SerializeObjectToString(productLst, jsonSetting);
|
||
var seconds = (DateTime.Now - timeCalc).TotalSeconds.ToString("0.000");
|
||
return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"count\":" + productLst.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 GetProductGroups(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(200);
|
||
var add_user_name = RegexUtils.GetStringQuery(ref inputData, "add_user_name")?.Replace("'", "\\'");
|
||
var is_get_detail = RegexUtils.GetStringQuery(ref inputData, "is_get_detail") == "true";
|
||
|
||
string conn = "ConnKJD";
|
||
MysqlUtils mySql = new MysqlUtils(conn);
|
||
|
||
string sql = "SELECT p.* FROM `bxx`.`product_group` p where 1=1 ";
|
||
string where = "";
|
||
if (!string.IsNullOrEmpty(add_user_name))
|
||
{
|
||
add_user_name = "'" + string.Join("','", add_user_name.Split(new string[] { ",", ",", " " }, StringSplitOptions.RemoveEmptyEntries)) + "'";
|
||
where += " and p.add_user_name in (" + add_user_name + ")";
|
||
}
|
||
else
|
||
{
|
||
where += " and p.add_user_name='admin'";
|
||
}
|
||
sql += where;
|
||
sql += " ORDER BY id DESC";
|
||
|
||
var dt = mySql.ExecuteDataTable(sql);
|
||
mySql.Close();
|
||
|
||
if (dt != null)
|
||
{
|
||
try
|
||
{
|
||
JArray groupArr = new JArray();
|
||
string group_data = "";
|
||
foreach (DataRow row in dt.Rows)
|
||
{
|
||
group_data += row["group_name"].ToString() + ",";
|
||
|
||
if (is_get_detail)
|
||
{
|
||
JObject groupObj = new JObject();
|
||
groupObj["id"] = row["id"].ParseToLong();
|
||
groupObj["group_name"] = row["group_name"].ParseToString();
|
||
groupObj["add_user_name"] = row["add_user_name"].ParseToString();
|
||
groupArr.Add(groupObj);
|
||
}
|
||
}
|
||
var data = group_data.Trim(',');
|
||
return "{\"code\":200,\"msg\":\"success\",\"data\":\"" + data + "\",\"groups\":" + JsonUtils.SerializeObject(groupArr) + "}";
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
return "{\"code\":50002,\"msg\":\"" + ex.Message + "\",\"data\":\"\"}";
|
||
}
|
||
}
|
||
else
|
||
{
|
||
return "{\"code\":50003,\"msg\":\"" + mySql.Message + "\",\"data\":\"\"}";
|
||
}
|
||
}
|
||
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
||
}
|
||
|
||
public string AddProductGroup(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\":\"没有用户名\"}";
|
||
}
|
||
|
||
var add_user_name = RegexUtils.GetStringQuery(ref inputData, "add_user_name")?.Replace("'", "\\'");
|
||
if (string.IsNullOrEmpty(add_user_name))
|
||
{
|
||
add_user_name = "admin";
|
||
}
|
||
var group_name = RegexUtils.GetStringQuery(ref inputData, "group_name")?.Replace("'", "\\'");
|
||
if (string.IsNullOrEmpty(group_name))
|
||
{
|
||
return "{\"code\":500,\"msg\":\"未指定要新增的组\"}";
|
||
}
|
||
|
||
string conn = "ConnKJD";
|
||
MysqlUtils mySql = new MysqlUtils(conn);
|
||
|
||
string sql = "INSERT IGNORE INTO `bxx`.`product_group` (group_name,add_user_name) VALUES ('" + group_name + "','" + add_user_name + "')";
|
||
|
||
var add_rows = mySql.ExecuteAffectedRows(sql);
|
||
mySql.Close();
|
||
|
||
if (string.IsNullOrEmpty(mySql.Message))
|
||
{
|
||
return "{\"code\":200,\"msg\":\"success\", \"add_rows\":" + add_rows + "}";
|
||
}
|
||
else
|
||
{
|
||
return "{\"code\":50003,\"msg\":\"" + mySql.Message + "\",\"data\":\"\"}";
|
||
}
|
||
}
|
||
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
||
}
|
||
|
||
public string DelProductGroup(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\":\"没有用户名\"}";
|
||
}
|
||
|
||
var add_user_name = RegexUtils.GetStringQuery(ref inputData, "add_user_name")?.Replace("'", "\\'");
|
||
if (string.IsNullOrEmpty(add_user_name))
|
||
{
|
||
add_user_name = "admin";
|
||
}
|
||
var id = RegexUtils.GetStringQuery(ref inputData, "group_id")?.Replace("'", "\\'");
|
||
var group_name = RegexUtils.GetStringQuery(ref inputData, "group_name")?.Replace("'", "\\'");
|
||
if (string.IsNullOrEmpty(id) && string.IsNullOrEmpty(group_name))
|
||
{
|
||
return "{\"code\":500,\"msg\":\"未指定要删除的组\"}";
|
||
}
|
||
|
||
string conn = "ConnKJD";
|
||
MysqlUtils mySql = new MysqlUtils(conn);
|
||
|
||
string sql = "DELETE FROM `bxx`.`product_group` p where 1=1";
|
||
|
||
string where = "";
|
||
if (!string.IsNullOrEmpty(id))
|
||
{
|
||
id = "" + string.Join(",", id.Split(new string[] { ",", ",", " " }, StringSplitOptions.RemoveEmptyEntries)) + "";
|
||
where += " and p.id in (" + id + ")";
|
||
}
|
||
if (!string.IsNullOrEmpty(group_name))
|
||
{
|
||
group_name = "'" + string.Join("','", group_name.Split(new string[] { ",", ",", " " }, StringSplitOptions.RemoveEmptyEntries)) + "'";
|
||
where += " and p.group_name in (" + group_name + ")";
|
||
}
|
||
if (!string.IsNullOrEmpty(add_user_name))
|
||
{
|
||
add_user_name = "'" + string.Join("','", add_user_name.Split(new string[] { ",", ",", " " }, StringSplitOptions.RemoveEmptyEntries)) + "'";
|
||
where += " and p.add_user_name in (" + add_user_name + ")";
|
||
}
|
||
sql += where;
|
||
|
||
var del_rows = mySql.ExecuteAffectedRows(sql);
|
||
mySql.Close();
|
||
|
||
if (string.IsNullOrEmpty(mySql.Message))
|
||
{
|
||
return "{\"code\":200,\"msg\":\"success\", \"del_rows\":" + del_rows + "}";
|
||
}
|
||
else
|
||
{
|
||
return "{\"code\":50003,\"msg\":\"" + mySql.Message + "\",\"data\":\"\"}";
|
||
}
|
||
}
|
||
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
||
}
|
||
|
||
public string GetProductNotes(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(200);
|
||
var add_user_name = RegexUtils.GetStringQuery(ref inputData, "add_user_name")?.Replace("'", "\\'");
|
||
var is_get_detail = RegexUtils.GetStringQuery(ref inputData, "is_get_detail") == "true";
|
||
|
||
string conn = "ConnKJD";
|
||
MysqlUtils mySql = new MysqlUtils(conn);
|
||
|
||
string sql = "SELECT p.* FROM `bxx`.`product_notes` p where 1=1 ";
|
||
string where = "";
|
||
if (!string.IsNullOrEmpty(add_user_name))
|
||
{
|
||
add_user_name = "'" + string.Join("','", add_user_name.Split(new string[] { ",", ",", " " }, StringSplitOptions.RemoveEmptyEntries)) + "'";
|
||
where += " and p.add_user_name in (" + add_user_name + ")";
|
||
}
|
||
else
|
||
{
|
||
where += " and p.add_user_name='admin'";
|
||
}
|
||
sql += where;
|
||
sql += " ORDER BY id DESC";
|
||
|
||
var dt = mySql.ExecuteDataTable(sql);
|
||
mySql.Close();
|
||
|
||
if (dt != null)
|
||
{
|
||
try
|
||
{
|
||
JArray notesArr = new JArray();
|
||
string notes_data = "";
|
||
foreach (DataRow row in dt.Rows)
|
||
{
|
||
notes_data += row["notes"].ToString() + ",";
|
||
|
||
if (is_get_detail)
|
||
{
|
||
JObject notesObj = new JObject();
|
||
notesObj["id"] = row["id"].ParseToLong();
|
||
notesObj["notes"] = row["notes"].ParseToString();
|
||
notesObj["add_user_name"] = row["add_user_name"].ParseToString();
|
||
notesArr.Add(notesObj);
|
||
}
|
||
}
|
||
var data = notes_data.Trim(',');
|
||
return "{\"code\":200,\"msg\":\"success\",\"data\":\"" + data + "\",\"notes\":" + JsonUtils.SerializeObject(notesArr) + "}";
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
return "{\"code\":50002,\"msg\":\"" + ex.Message + "\",\"data\":\"\"}";
|
||
}
|
||
}
|
||
else
|
||
{
|
||
return "{\"code\":50003,\"msg\":\"" + mySql.Message + "\",\"data\":\"\"}";
|
||
}
|
||
}
|
||
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
||
}
|
||
|
||
public string AddProductNotes(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\":\"没有用户名\"}";
|
||
}
|
||
|
||
var add_user_name = RegexUtils.GetStringQuery(ref inputData, "add_user_name")?.Replace("'", "\\'");
|
||
if (string.IsNullOrEmpty(add_user_name))
|
||
{
|
||
add_user_name = "admin";
|
||
}
|
||
var notes = RegexUtils.GetStringQuery(ref inputData, "notes")?.Replace("'", "\\'");
|
||
if (string.IsNullOrEmpty(notes))
|
||
{
|
||
return "{\"code\":500,\"msg\":\"未指定要新增的组\"}";
|
||
}
|
||
|
||
string conn = "ConnKJD";
|
||
MysqlUtils mySql = new MysqlUtils(conn);
|
||
|
||
string sql = "INSERT IGNORE INTO `bxx`.`product_notes` (notes,add_user_name) VALUES ('" + notes + "','" + add_user_name + "')";
|
||
|
||
var add_rows = mySql.ExecuteAffectedRows(sql);
|
||
mySql.Close();
|
||
|
||
if (string.IsNullOrEmpty(mySql.Message))
|
||
{
|
||
return "{\"code\":200,\"msg\":\"success\", \"add_rows\":" + add_rows + "}";
|
||
}
|
||
else
|
||
{
|
||
return "{\"code\":50003,\"msg\":\"" + mySql.Message + "\",\"data\":\"\"}";
|
||
}
|
||
}
|
||
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
||
}
|
||
|
||
public string DelProductNotes(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\":\"没有用户名\"}";
|
||
}
|
||
|
||
var add_user_name = RegexUtils.GetStringQuery(ref inputData, "add_user_name")?.Replace("'", "\\'");
|
||
if (string.IsNullOrEmpty(add_user_name))
|
||
{
|
||
add_user_name = "admin";
|
||
}
|
||
var id = RegexUtils.GetStringQuery(ref inputData, "notes_id")?.Replace("'", "\\'");
|
||
var notes = RegexUtils.GetStringQuery(ref inputData, "notes")?.Replace("'", "\\'");
|
||
if (string.IsNullOrEmpty(id) && string.IsNullOrEmpty(notes))
|
||
{
|
||
return "{\"code\":500,\"msg\":\"未指定要删除的组\"}";
|
||
}
|
||
|
||
string conn = "ConnKJD";
|
||
MysqlUtils mySql = new MysqlUtils(conn);
|
||
|
||
string sql = "DELETE FROM `bxx`.`product_notes` p where 1=1";
|
||
|
||
string where = "";
|
||
if (!string.IsNullOrEmpty(id))
|
||
{
|
||
id = "" + string.Join(",", id.Split(new string[] { ",", ",", " " }, StringSplitOptions.RemoveEmptyEntries)) + "";
|
||
where += " and p.id in (" + id + ")";
|
||
}
|
||
if (!string.IsNullOrEmpty(notes))
|
||
{
|
||
notes = "'" + string.Join("','", notes.Split(new string[] { ",", ",", " " }, StringSplitOptions.RemoveEmptyEntries)) + "'";
|
||
where += " and p.notes in (" + notes + ")";
|
||
}
|
||
if (!string.IsNullOrEmpty(add_user_name))
|
||
{
|
||
add_user_name = "'" + string.Join("','", add_user_name.Split(new string[] { ",", ",", " " }, StringSplitOptions.RemoveEmptyEntries)) + "'";
|
||
where += " and p.add_user_name in (" + add_user_name + ")";
|
||
}
|
||
sql += where;
|
||
|
||
var del_rows = mySql.ExecuteAffectedRows(sql);
|
||
mySql.Close();
|
||
|
||
if (string.IsNullOrEmpty(mySql.Message))
|
||
{
|
||
return "{\"code\":200,\"msg\":\"success\", \"del_rows\":" + del_rows + "}";
|
||
}
|
||
else
|
||
{
|
||
return "{\"code\":50003,\"msg\":\"" + mySql.Message + "\",\"data\":\"\"}";
|
||
}
|
||
}
|
||
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
||
}
|
||
|
||
|
||
public string GetProductCates(string inputData)
|
||
{
|
||
return "{\"code\":19999,\"msg\":\"接口废弃\"}";
|
||
}
|
||
|
||
public string GetProductMainCates(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);
|
||
|
||
// 直接返回全部拼多多一级类目名称及ID
|
||
var pddCats1Str = "男装,办公设备/耗材/相关服务,文具电教/文化用品/商务用品,3C数码配件,古董文玩/邮币/字画/收藏,影音电器,手机,二手数码,笔记本电脑,数码相机/单反相机/摄像机,智能设备,厨房电器,大家电,生活电器,个人护理保健,网络设备,零食/坚果/特产,咖啡/麦片/冲饮,茶,粮油米面/南北干货/调味品,酒类,保健食品/膳食营养补充食品,传统滋补品,电子元器件市场,摩托车/装备/配件,汽车/用品/配件/改装,水产肉类/新鲜蔬果/熟食,女装/女士精品,新车/二手车,流行男鞋,女鞋,箱包皮具/女包/男包,内衣裤袜,腕表眼镜,服饰配件,本地化生活服务,电影/演出/体育赛事,个性定制/设计服务,购物卡/礼品卡/代金券,婚庆/摄影/摄像服务,教育培训,景点门票/周边游,旅游路线/商品/服务,生活缴费,数字生活娱乐,特价酒店/客栈/公寓旅馆,网络服务/软件,网上营业厅,休闲娱乐,游戏服务/直播,床上用品,电子/电工,基础建材,家居饰品,灯饰光源照明,家装主材,居家布艺,全屋定制,商业/办公家具,特色手工艺,五金工具,住宅家具,电动车/配件/交通工具,户外/登山/旅行野营用品,运动/瑜伽/健身/球类,运动包/户外包/配件,运动服/休闲服,运动鞋,自行车/骑行装备/零配件,OTC药品,精制中药材,隐形眼镜/护理液,奶粉/辅食/营养品/零食,婴童用品,童鞋/婴儿鞋/亲子鞋,童装/婴儿装/亲子装,玩具/童车/益智/积木/模型,孕产妇用品/孕妇装/营养,书籍/杂志/报纸,农机/农具/农膜,畜牧/养殖物资,农用物资,成人用品,宠物/宠物食品及用品,餐饮具,厨房/烹饪用具,收纳整理,家庭/个人清洁工具,居家日用,节庆用品/礼品,烟品/打火机/瑞士军刀,洗护清洁剂/卫生巾/纸/香薰,饰品/流行首饰/摆件/保养鉴定,珠宝/钻石/翡翠/黄金,鲜花园艺/绿植仿真/园林设备,乐器/吉他/钢琴/配件,装修设计/施工/监理,医疗健康服务,处方药,彩妆/香水/美妆工具,美容美体仪器,美发护发/假发,美容护肤/美体/精油,医疗器械,婴童尿裤,汽车服务,交通出行,房地产,模玩/动漫/周边/cos/桌游,音乐/影视/明星/音像,搬运/仓储/物流设备,标准件/零部件/工业耗材,机械设备,清洗/食品/商业设备,橡塑材料及制品,平板电脑/MID,品牌台机/品牌一体机/服务器,DIY电脑,闪存卡/U盘/存储/移动硬盘,电脑硬件/显示器/电脑周边,电玩/配件/游戏/攻略,包装用品,保健用品,特色农产品(非食用),239,2603,2629,2933,5217,5752,5834,5839,5851,5906,5921,5955,6076,6128,6209,6290,6398,6536,6586,6630,6758,6785,6883,7323,7629,7639,8172,8439,8502,8508,8509,8538,8583,8634,8669,8721,8722,8723,8724,8725,8726,8727,8728,8729,8730,8731,8732,8733,8734,8736,9313,9314,9315,9316,9317,9318,9319,9320,9321,9322,9323,9324,11683,11684,11685,11686,11687,11688,11689,13176,13177,13178,14697,14740,14933,14966,15083,15356,15543,16155,16192,16209,16237,16288,16548,16676,16794,16901,16989,17134,17249,17285,17412,17455,17671,17803,18088,18270,18349,18482,18574,18601,18637,18814,19298,20078,20118,20340,20645,21417,22856,22881,22931,22964,22986,24383,24386,24402,24407,24426,24520,24636,24699,27063";
|
||
var data = pddCats1Str;
|
||
return "{\"code\":200,\"msg\":\"success\",\"data\":\"" + data + "\"}";
|
||
}
|
||
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
||
}
|
||
|
||
/// <summary>
|
||
/// 查询商品替换sku
|
||
/// </summary>
|
||
/// <param name="inputData"></param>
|
||
/// <param name="isDetail"></param>
|
||
/// <returns></returns>
|
||
public string GetSkuImgReplaceList(string inputData, bool isDetail = false)
|
||
{
|
||
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 sku_img_replace_ids = RegexUtils.GetStringQuery(ref inputData, "sku_img_replace_ids")?.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(*) from bxx.sku_img_replace s where 1=1";
|
||
|
||
string where = "";
|
||
if (!string.IsNullOrWhiteSpace(sku_img_replace_ids))
|
||
where += " and s.id in (" + sku_img_replace_ids + ")";
|
||
sql += where;
|
||
|
||
var count = mySql.ExecuteRowCount(sql);
|
||
|
||
DataTable dt;
|
||
if (count == 0)
|
||
{
|
||
dt = new DataTable();
|
||
}
|
||
else
|
||
{
|
||
sql = "select * from bxx.sku_img_replace s where 1=1";
|
||
|
||
//where子句
|
||
sql += where;
|
||
|
||
sql += " order by s.img_type asc, s.id desc";
|
||
sql += " limit " + Math.Max(page - 1, 0) * page_size + "," + page_size;
|
||
dt = mySql.ExecuteDataTable(sql);
|
||
}
|
||
|
||
mySql.Close();
|
||
if (dt != null)
|
||
{
|
||
try
|
||
{
|
||
List<sku_img_replace> skuImgReplaceLst = new List<sku_img_replace>();
|
||
foreach (DataRow row in dt.Rows)
|
||
{
|
||
sku_img_replace skuImgReplace = new sku_img_replace
|
||
{
|
||
id = Convert.ToInt32(row["id"]),
|
||
//img_base64 = row["img_base64"].ToString(),
|
||
img_md5 = row["img_md5"].ToString(),
|
||
img_url = row["img_url"].ToString(),
|
||
add_time = Convert.ToDateTime(row["add_time"]),
|
||
mdy_time = Convert.ToDateTime(row["mdy_time"]),
|
||
img_type = row["img_type"].ToString(),
|
||
img_group = row["img_group"].ToString(),
|
||
};
|
||
if (isDetail)
|
||
{
|
||
skuImgReplace.img_base64 = row["img_base64"].ToString();
|
||
}
|
||
skuImgReplaceLst.Add(skuImgReplace);
|
||
}
|
||
var data = JsonUtils.SerializeObjectToString(skuImgReplaceLst);
|
||
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\":\"输入为空\"}";
|
||
}
|
||
|
||
/// <summary>
|
||
/// 随机获取商品(无详情) 随机添加到上传列表所以不需要获取详情
|
||
/// </summary>
|
||
/// <param name="inputData"></param>
|
||
/// <returns></returns>
|
||
public string GetProductListRandom(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("'", "\\'");
|
||
var password = RegexUtils.GetStringQuery(ref inputData, "password")?.Replace("'", "\\'");
|
||
var in_ext_codes = RegexUtils.GetStringQuery(ref inputData, "in_ext_codes")?.Replace("'", "\\'");
|
||
var in_spu_ids = RegexUtils.GetStringQuery(ref inputData, "in_spu_ids")?.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_notes = RegexUtils.GetStringQuery(ref inputData, "in_notes")?.Replace("'", "\\'");
|
||
var product_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "product_name"))?.Replace("'", "\\'");
|
||
var in_cates = RegexUtils.GetStringQuery(ref inputData, "in_cates")?.Replace("'", "\\'");
|
||
var wx_cat_1 = RegexUtils.GetStringQuery(ref inputData, "wx_cat_1")?.Replace("'", "\\'");
|
||
var wx_cat_2 = RegexUtils.GetStringQuery(ref inputData, "wx_cat_2")?.Replace("'", "\\'");
|
||
var wx_cat_3 = RegexUtils.GetStringQuery(ref inputData, "wx_cat_3")?.Replace("'", "\\'");
|
||
var wx_safe_status = RegexUtils.GetStringQuery(ref inputData, "wx_safe_status")?.Replace("'", "\\'");
|
||
var special_prod_type = RegexUtils.GetStringQuery(ref inputData, "special_prod_type")?.Replace("'", "\\'");
|
||
if (special_prod_type.IsNullOrEmpty())
|
||
special_prod_type = "普通商品";
|
||
var product_get_type = RegexUtils.GetStringQuery(ref inputData, "product_get_type")?.Replace("'", "\\'");
|
||
var is学员数据 = false;
|
||
if (product_get_type == "学员数据")
|
||
{
|
||
is学员数据 = true;
|
||
product_get_type = "多多外部数据,微信小店,微信店采";
|
||
special_prod_type = "普通商品,爆款数据";
|
||
}
|
||
var is_supplier_prod_ok = RegexUtils.GetStringQuery(ref inputData, "is_supplier_prod_ok")?.Replace("'", "\\'");
|
||
var is_not_count = RegexUtils.GetStringQuery(ref inputData, "is_not_count") == "true"; // 不计数
|
||
var prod_count = RegexUtils.GetStringQuery(ref inputData, "prod_count").ParseToInt();
|
||
var add_days_less = RegexUtils.GetStringQuery(ref inputData, "add_days_less").ParseToNullableInt();
|
||
var has_wx_format = RegexUtils.GetStringQuery(ref inputData, "has_wx_format")?.Replace("'", "\\'");
|
||
var is_relation = RegexUtils.GetStringQuery(ref inputData, "is_relation").ParseToNullableInt();
|
||
var ban_wx = RegexUtils.GetStringQuery(ref inputData, "ban_wx")?.Replace("'", "\\'");
|
||
var ban_pdd = RegexUtils.GetStringQuery(ref inputData, "ban_pdd")?.Replace("'", "\\'");
|
||
var add_user_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "add_user_name"))?.Replace("'", "\\'");
|
||
if (is学员数据)
|
||
add_user_name = "admin";
|
||
var no_fission_words = RegexUtils.GetStringQuery(ref inputData, "no_fission_words").ParseToBool(); // 未裂变标题
|
||
var fission_words = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "fission_words"))?.Replace("'", "\\'");
|
||
var min_view_uv = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "min_view_uv"))?.ParseToNullableInt();
|
||
if (min_view_uv > 0 && min_view_uv < 100)
|
||
min_view_uv = 100;
|
||
if (is学员数据)
|
||
min_view_uv = null;
|
||
|
||
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 tableName = GetProductTableName(inputData);
|
||
string sql = "";
|
||
|
||
sql = " SELECT count(*)" + " FROM " + tableName + " p";
|
||
//if (!string.IsNullOrEmpty(wx_safe_status))
|
||
// sql += " FORCE INDEX (index_wx_safe_status)";
|
||
//sql += " LEFT JOIN bxx.jst_supplier_ban_platform b ON (p.skc_id=b.coid or p.real_coid=b.coid)"
|
||
sql += " WHERE p.is_del=0";
|
||
|
||
string where = "";
|
||
//where += " AND (b.ban_wx IS NULL OR b.ban_wx=0)";
|
||
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_spu_ids))
|
||
{
|
||
in_spu_ids = "'" + string.Join("','", in_spu_ids.Split(new string[] { ",", ",", " " }, StringSplitOptions.RemoveEmptyEntries)) + "'";
|
||
where += " and p.spu_id in (" + in_spu_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_notes))
|
||
{
|
||
in_notes = "'" + string.Join("','", in_notes.Split(new string[] { ",", ",", " " }, StringSplitOptions.RemoveEmptyEntries)) + "'";
|
||
where += " and p.notes in (" + in_notes + ")";
|
||
}
|
||
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 + "))";
|
||
}
|
||
if (!string.IsNullOrEmpty(product_name))
|
||
{
|
||
where += " and p.product_name='" + product_name + "'";
|
||
}
|
||
if (!string.IsNullOrEmpty(wx_cat_1))
|
||
{
|
||
where += " and p.wx_cat_1 in (" + wx_cat_1 + ")";
|
||
}
|
||
if (!string.IsNullOrEmpty(wx_cat_2))
|
||
{
|
||
where += " and p.wx_cat_2 in (" + wx_cat_2 + ")";
|
||
}
|
||
if (!string.IsNullOrEmpty(wx_cat_3))
|
||
{
|
||
where += " and p.wx_cat_3 in (" + wx_cat_3 + ")";
|
||
}
|
||
string where1 = "";
|
||
string where2 = "";
|
||
if (!string.IsNullOrEmpty(product_get_type))
|
||
{
|
||
where1 = " and p.product_get_type in ('" + product_get_type.Replace(",", "','") + "')";
|
||
//where1 = " and ((product_get_type = '多多外部数据') OR (product_get_type = '微信小店') OR (product_get_type = '微信店采' AND wx_safe_status = '安全商品')) ";
|
||
if (is学员数据)
|
||
{
|
||
// 多多外部数据20% 微信小店数据30% 微信店采50%
|
||
//where2 = " and (RAND() < 0.066 AND product_get_type = '多多外部数据' OR RAND() < 0.3 AND product_get_type = '微信小店' OR RAND() <= 1 AND product_get_type = '微信店采') ";
|
||
where2 = " and ((RAND() < 0.055 AND product_get_type = '多多外部数据') OR (RAND() < 0.39 AND product_get_type = '微信小店') OR (RAND() <= 1 AND product_get_type = '微信店采' AND wx_safe_status = '安全商品')) ";
|
||
}
|
||
where += where1;
|
||
}
|
||
if (!string.IsNullOrEmpty(wx_safe_status))
|
||
where += " and p.wx_safe_status in ('" + wx_safe_status.Replace(",", "','") + "')";
|
||
//if (!string.IsNullOrEmpty(special_prod_type)) // 普通商品 爆款数据
|
||
// where += " and p.special_prod_type ='" + special_prod_type + "'";
|
||
if (!string.IsNullOrEmpty(special_prod_type)/* && special_prod_type != "普通商品,爆款数据"*/)
|
||
where += " and p.special_prod_type in ('" + special_prod_type.Replace(",", "','") + "')";
|
||
// 供应商货源是否已完成初始设置
|
||
if (!string.IsNullOrEmpty(is_supplier_prod_ok))
|
||
{
|
||
if (is_supplier_prod_ok == "1" || is_supplier_prod_ok == "是" || is_supplier_prod_ok == "已设置")
|
||
where += " AND wx_cat_leaf > 0 AND send_to_out_server IN (1,127) and distribution_set IN (1,127)";
|
||
else
|
||
where += " AND (wx_cat_leaf IS NULL OR send_to_out_server NOT IN (1,127) OR distribution_set NOT IN (1,127))";
|
||
}
|
||
else
|
||
{
|
||
where += " AND send_to_out_server IN (0,1,127) and distribution_set IN (0,1,2,127)";
|
||
}
|
||
if (!add_days_less.IsNullOrZero())
|
||
{
|
||
where += " and add_time > '" + DateTime.Now.AddDays(-add_days_less.ParseToInt()).ToString("yyyy-MM-dd") + "'";
|
||
}
|
||
if (!has_wx_format.IsNullOrEmpty())
|
||
{
|
||
where += " and has_wx_format = '" + has_wx_format + "'";
|
||
}
|
||
if (is_relation != null)
|
||
{
|
||
where += " and is_relation = " + is_relation;
|
||
}
|
||
if (ban_wx != null)
|
||
{
|
||
where += " and p.ban_wx=" + ban_wx;
|
||
}
|
||
else
|
||
{
|
||
where += " and p.ban_wx in (0,1) ";
|
||
}
|
||
if (ban_pdd != null)
|
||
{
|
||
where += " and p.ban_pdd=" + ban_pdd;
|
||
}
|
||
else
|
||
{
|
||
where += " and p.ban_pdd in (0,1) ";
|
||
}
|
||
if (!string.IsNullOrEmpty(add_user_name))
|
||
{
|
||
add_user_name = "'" + string.Join("','", add_user_name.Split(new string[] { ",", ",", " " }, StringSplitOptions.RemoveEmptyEntries)) + "'";
|
||
where += " and p.add_user_name in (" + add_user_name + ")";
|
||
}
|
||
if (no_fission_words)
|
||
{
|
||
where += " and (fission_words='' or fission_words IS NULL)";
|
||
}
|
||
if (!string.IsNullOrEmpty(fission_words))
|
||
{
|
||
where += " and fission_words LIKE '" + fission_words + "%'";
|
||
}
|
||
if (min_view_uv > 0)
|
||
{
|
||
where += " and view_uv >= " + min_view_uv + "";
|
||
}
|
||
sql += where;
|
||
|
||
int count = prod_count;
|
||
if (product_get_type == "厂商直采" && count > 1000)
|
||
count = (count / 2.0).ParseToInt();
|
||
if (is学员数据 && count >= 450)
|
||
count = (count / 3.0).ParseToInt();
|
||
if (!is_not_count)
|
||
{
|
||
count = mySql.ExecuteRowCount(sql);
|
||
Thread.Sleep(1500);
|
||
}
|
||
|
||
DataTable dt;
|
||
if (count == 0 && !is_not_count)
|
||
{
|
||
dt = new DataTable();
|
||
}
|
||
else
|
||
{
|
||
if (is学员数据)
|
||
{
|
||
where = where.Replace(where1, where2);
|
||
}
|
||
|
||
sql = " SELECT p.id" +
|
||
" FROM " + tableName + " p" +
|
||
//" LEFT JOIN bxx.jst_supplier_ban_platform b ON (p.skc_id=b.coid OR p.real_coid=b.coid)" +
|
||
" WHERE p.is_del=0";
|
||
//where子句
|
||
sql += where;
|
||
|
||
sql += " ORDER BY RAND()";
|
||
sql += " limit " + Math.Max(page - 1, 0) * page_size + "," + page_size;
|
||
|
||
//var limit = RandomUtils.GetId(Math.Max(0, count - page_size));
|
||
//sql += " limit " + limit + "," + 5000;
|
||
|
||
dt = mySql.ExecuteDataTable(sql);
|
||
Thread.Sleep(100);
|
||
if (!string.IsNullOrEmpty(mySql.Message) || dt == null)
|
||
{
|
||
mySql.Close();
|
||
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\",\"data\":[],\"count\":" + 0 + "}";
|
||
}
|
||
|
||
var db_ids = string.Join(",", dt.Rows.Cast<DataRow>().Select(r => r["id"].ParseToInt()).OrderBy(x => RandomUtils.GetId(10000000)).Take(page_size));
|
||
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.product_get_type,fission_words," +
|
||
" p.wx_safe_status,p.special_prod_type,p.wx_cat_1,p.wx_cat_2,p.wx_cat_3,p.send_to_out_server," +
|
||
" p.wx_cat_leaf,p.is_relation" +
|
||
" from " + tableName + " p where p.is_del=0";
|
||
//where子句
|
||
//sql += where;
|
||
sql += " and id in (" + db_ids + ")";
|
||
|
||
//sql += " ORDER BY RAND()";
|
||
//sql += " limit " + Math.Max(page - 1, 0) * page_size + "," + page_size;
|
||
dt = mySql.ExecuteDataTable(sql);
|
||
}
|
||
|
||
mySql.Close();
|
||
Thread.Sleep(500);
|
||
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(),
|
||
spu_id = row["spu_id"].ToString(),
|
||
skc_id = row["skc_id"].ToString(),
|
||
main_cat_id = row["main_cat_id"].ToString(),
|
||
main_cat_name = row["main_cat_name"].ToString(),
|
||
cat_id = row["cat_id"].ToString(),
|
||
cat_name = row["cat_name"].ToString(),
|
||
wx_cat_1 = row["wx_cat_1"].ToString(),
|
||
wx_cat_2 = row["wx_cat_2"].ToString(),
|
||
wx_cat_3 = row["wx_cat_3"].ToString(),
|
||
wx_cat_leaf = row["wx_cat_leaf"].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(),
|
||
add_time = Convert.ToDateTime(row["add_time"]),
|
||
mdy_time = Convert.ToDateTime(row["mdy_time"]),
|
||
group = row["group"].ToString(),
|
||
notes = row["notes"].ToString(),
|
||
product_get_type_text = row["product_get_type"].ParseToString(),
|
||
//sale_count = row["sale_count"].ParseToInt(),
|
||
//sale_count_text = row["sale_count_text"].ToString(),
|
||
wx_safe_status = row["wx_safe_status"].ToString(),
|
||
special_prod_type = row["special_prod_type"].ParseToString(),
|
||
send_to_out_server = row["send_to_out_server"].ParseToInt(),
|
||
is_relation = row["is_relation"].ParseToInt(),
|
||
fission_words = row["fission_words"].ParseToString(),
|
||
};
|
||
productLst.Add(prod);
|
||
}
|
||
JsonSerializerSettings jsonSetting = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore };
|
||
var data = JsonUtils.SerializeObjectToString(productLst, jsonSetting);
|
||
var seconds = (DateTime.Now - timeCalc).TotalSeconds.ToString("0.000");
|
||
if (product_get_type == "厂商直采" && count > 500)
|
||
count = (count * 2.0).ParseToInt();
|
||
if (is学员数据 && count >= 150)
|
||
count = (count * 3.0).ParseToInt();
|
||
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\":\"输入为空\"}";
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取拼多多商品随机sku替换图
|
||
/// </summary>
|
||
/// <param name="inputData"></param>
|
||
/// <returns></returns>
|
||
public string GetSkuReplaceImgListRandom(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("'", "\\'");
|
||
var password = RegexUtils.GetStringQuery(ref inputData, "password")?.Replace("'", "\\'");
|
||
var in_img_type = RegexUtils.GetStringQuery(ref inputData, "in_img_type")?.Replace("'", "\\'");
|
||
var in_img_group = RegexUtils.GetStringQuery(ref inputData, "in_img_group")?.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(*) from bxx.sku_img_replace s where 1=1";
|
||
|
||
string where = "";
|
||
if (!string.IsNullOrWhiteSpace(in_img_type) && !string.IsNullOrWhiteSpace(in_img_group))
|
||
{
|
||
in_img_type = "'" + string.Join("','", in_img_type.Split(new string[] { ",", ",", " " }, StringSplitOptions.RemoveEmptyEntries)) + "'";
|
||
in_img_group = "'" + string.Join("','", in_img_group.Split(new string[] { ",", ",", " " }, StringSplitOptions.RemoveEmptyEntries)) + "'";
|
||
where += " and (s.img_type in (" + in_img_type + ") or s.img_group in (" + in_img_group + ")";
|
||
}
|
||
else if (!string.IsNullOrWhiteSpace(in_img_type))
|
||
{
|
||
in_img_type = "'" + string.Join("','", in_img_type.Split(new string[] { ",", ",", " " }, StringSplitOptions.RemoveEmptyEntries)) + "'";
|
||
where += " and s.img_type in (" + in_img_type + ")";
|
||
}
|
||
else if (!string.IsNullOrWhiteSpace(in_img_group))
|
||
{
|
||
in_img_group = "'" + string.Join("','", in_img_group.Split(new string[] { ",", ",", " " }, StringSplitOptions.RemoveEmptyEntries)) + "'";
|
||
where += " and s.img_group in (" + in_img_group + ")";
|
||
}
|
||
|
||
sql += where;
|
||
|
||
var count = mySql.ExecuteRowCount(sql);
|
||
|
||
DataTable dt;
|
||
if (count == 0)
|
||
{
|
||
dt = new DataTable();
|
||
}
|
||
else
|
||
{
|
||
sql = "select s.img_url from bxx.sku_img_replace s where 1=1";
|
||
|
||
//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<string> imgs = new List<string>();
|
||
foreach (DataRow row in dt.Rows)
|
||
{
|
||
imgs.Add(row["img_url"].ToString());
|
||
}
|
||
var data = JsonUtils.SerializeObjectToString(imgs);
|
||
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 DelDbProd(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\":500,\"msg\":\"没有用户名\"}";
|
||
}
|
||
|
||
var id = RegexUtils.GetStringQuery(ref inputData, "db_id")?.Replace("'", "\\'");
|
||
if (string.IsNullOrEmpty(id))
|
||
{
|
||
return "{\"code\":500,\"msg\":\"删除失败:请指定要删除的数据!\"}";
|
||
}
|
||
|
||
string conn = "ConnKJD";
|
||
MysqlUtils mySql = new MysqlUtils(conn);
|
||
|
||
string tableName = GetProductTableName(inputData);
|
||
string sql = "";
|
||
|
||
if (tableName != "bxx.product")
|
||
sql = "delete from " + tableName + " where id='" + id + "'";
|
||
else
|
||
sql = "update " + tableName + " set is_del=1 where id='" + id + "'";
|
||
|
||
var rst = mySql.ExecuteNonQuery(sql);
|
||
mySql.Close();
|
||
if (rst)
|
||
{
|
||
return "{\"code\":200,\"msg\":\"success\"}";
|
||
}
|
||
else
|
||
return "{\"code\":500,\"msg\":\"删除失败:" + mySql.Message + "\"}";
|
||
}
|
||
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
||
}
|
||
|
||
/// <summary>
|
||
/// 编辑商品备注信息、货号、头尾词和分词
|
||
/// </summary>
|
||
/// <param name="inputData"></param>
|
||
/// <param name="isAdmin"></param>
|
||
/// <returns></returns>
|
||
public string MdyDBProduct(string inputData, bool isAdmin = false)
|
||
{
|
||
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\":\"校验失败\"}";
|
||
|
||
string user_name = RegexUtils.GetStringQuery(ref inputData, "user_name")?.Replace("'", "\\'");
|
||
string id = RegexUtils.GetStringQuery(ref inputData, "db_id")?.Replace("'", "\\'");
|
||
string in_db_ids = RegexUtils.GetStringQuery(ref inputData, "in_db_ids")?.Replace("'", "\\'");
|
||
string product_name = RegexUtils.GetStringQuery(ref inputData, "product_name")?.Replace("'", "\\'");
|
||
string group = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "group"))?.Replace("'", "\\'");
|
||
string notes = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "notes"))?.Replace("'", "\\'");
|
||
string ext_code = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "ext_code"))?.Replace("'", "\\'");
|
||
string fission_imgs = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "fission_imgs"))?.Replace("'", "\\'");
|
||
string fission_words = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "fission_words"))?.Replace("'", "\\'");
|
||
string head_words = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "head_words"))?.Replace("'", "\\'");
|
||
string end_words = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "end_words"))?.Replace("'", "\\'");
|
||
string sku_edit_json = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sku_edit_json"))?.Replace("'", "\\'");
|
||
string wx_safe_status = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "wx_safe_status"))?.Replace("'", "\\'");
|
||
string special_prod_type = RegexUtils.GetStringQuery(ref inputData, "special_prod_type")?.Replace("'", "\\'");
|
||
string wx_cat_1 = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "wx_cat_1"))?.Replace("'", "\\'");
|
||
string wx_cat_2 = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "wx_cat_2"))?.Replace("'", "\\'");
|
||
string wx_cat_3 = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "wx_cat_3"))?.Replace("'", "\\'");
|
||
string wx_cat_leaf = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "wx_cat_leaf"))?.Replace("'", "\\'");
|
||
string main_cat_id = RegexUtils.GetStringQuery(ref inputData, "main_cat_id")?.Replace("'", "\\'");
|
||
string main_cat_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "main_cat_name"))?.Replace("'", "\\'");
|
||
string cat_id = RegexUtils.GetStringQuery(ref inputData, "cat_id")?.Replace("'", "\\'");
|
||
string cat_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "cat_name"))?.Replace("'", "\\'");
|
||
if (!string.IsNullOrEmpty(special_prod_type) && special_prod_type != "爆款数据")
|
||
special_prod_type = "普通商品";
|
||
|
||
if (string.IsNullOrEmpty(user_name))
|
||
{
|
||
return "{\"code\":500,\"msg\":\"没有用户名\"}";
|
||
}
|
||
|
||
string conn = "ConnKJD";
|
||
MysqlUtils mySql = new MysqlUtils(conn);
|
||
|
||
string tableName = GetProductTableName(inputData);
|
||
string sql = "";
|
||
|
||
sql = "update " + tableName + " p set";
|
||
if (product_name != null)
|
||
sql += " p.product_name='" + product_name + "',";
|
||
if (group != null)
|
||
sql += " p.group='" + group + "',";
|
||
if (notes != null)
|
||
sql += " p.notes='" + notes + "',";
|
||
if (ext_code != null)
|
||
sql += " p.ext_code='" + ext_code + "',";
|
||
if (fission_imgs != null)
|
||
sql += " p.fission_imgs='" + fission_imgs + "',";
|
||
if (fission_words != null)
|
||
sql += " p.fission_words='" + fission_words + "',";
|
||
if (head_words != null)
|
||
sql += " p.head_words='" + head_words + "',";
|
||
if (end_words != null)
|
||
sql += " p.end_words='" + end_words + "',";
|
||
if (sku_edit_json != null)
|
||
sql += " p.sku_edit_json='" + sku_edit_json + "',";
|
||
if (wx_safe_status != null)
|
||
sql += " p.wx_safe_status='" + wx_safe_status + "',";
|
||
if (special_prod_type != null && special_prod_type != "")
|
||
sql += " p.special_prod_type='" + special_prod_type + "',";
|
||
if (!wx_cat_1.IsNullOrEmpty())
|
||
sql += " p.wx_cat_1=" + wx_cat_1 + ",";
|
||
if (!wx_cat_2.IsNullOrEmpty())
|
||
sql += " p.wx_cat_2=" + wx_cat_2 + ",";
|
||
if (!wx_cat_3.IsNullOrEmpty())
|
||
sql += " p.wx_cat_3=" + wx_cat_3 + ",";
|
||
if (!wx_cat_leaf.IsNullOrEmpty())
|
||
sql += " p.wx_cat_leaf=" + wx_cat_leaf + ",";
|
||
if (main_cat_id != null)
|
||
sql += " p.main_cat_id='" + main_cat_id + "',";
|
||
if (cat_id != null)
|
||
sql += " p.cat_id='" + cat_id + "',";
|
||
if (main_cat_name != null)
|
||
sql += " p.main_cat_name='" + main_cat_name + "',";
|
||
if (cat_name != null)
|
||
sql += " p.cat_name='" + cat_name + "',";
|
||
sql = sql.TrimEnd(',');
|
||
if (in_db_ids != null)
|
||
{
|
||
sql += " where id in (" + in_db_ids + ");";
|
||
}
|
||
else
|
||
{
|
||
sql += " where id=" + id + ";";
|
||
}
|
||
|
||
var rst = mySql.ExecuteNonQuery(sql);
|
||
mySql.Close();
|
||
if (rst)
|
||
{
|
||
return "{\"code\":200,\"msg\":\"success\"}";
|
||
}
|
||
else
|
||
{
|
||
return "{\"code\":500,\"msg\":\"更新失败:" + mySql.Message + "\"}";
|
||
}
|
||
}
|
||
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
||
}
|
||
|
||
public string AddSkuImgReplace(string inputData)
|
||
{
|
||
if (!string.IsNullOrEmpty(inputData))
|
||
{
|
||
var time = 0;
|
||
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "time"), out time);
|
||
string time1 = RegexUtils.GetStringQuery(ref inputData, "code");
|
||
if (time1 != EncrypUtil.Encryption(time))
|
||
return "{\"code\":50000,\"msg\":\"校验失败\"}";
|
||
|
||
string user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
|
||
string img_md5 = RegexUtils.GetStringQuery(ref inputData, "img_md5");
|
||
string img_base64 = RegexUtils.GetStringQuery(ref inputData, "img_base64");
|
||
string img_url = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "img_url"));
|
||
string img_type = RegexUtils.GetStringQuery(ref inputData, "img_type")?.Replace("'", "\\'");
|
||
string img_group = RegexUtils.GetStringQuery(ref inputData, "img_group")?.Replace("'", "\\'");
|
||
|
||
if (string.IsNullOrEmpty(user_name))
|
||
{
|
||
return "{\"code\":500,\"msg\":\"没有用户名\"}";
|
||
}
|
||
|
||
string conn = "ConnKJD";
|
||
MysqlUtils mySql = new MysqlUtils(conn);
|
||
string sql = "";
|
||
|
||
sql = "select id from bxx.sku_img_replace where img_md5='" + img_md5 + "';";
|
||
var bRst = false;
|
||
var rst = mySql.ExecuteFirstInt(sql).ParseToLong();
|
||
if (rst <= 0)
|
||
{
|
||
sql = "insert into bxx.sku_img_replace (img_md5,img_base64,img_url,img_type,img_group) " +
|
||
"values ('" + img_md5 + "','" + img_base64 + "','" + img_url + "','" + img_type + "','" + img_group + "');";
|
||
rst = mySql.ExecuteInsertId(sql);
|
||
}
|
||
if (rst > 0)
|
||
{
|
||
bRst = true;
|
||
}
|
||
mySql.Close();
|
||
if (rst > 0 && bRst)
|
||
{
|
||
return "{\"code\":200,\"msg\":\"success\",\"sku_img_replace_id\":" + rst + "}";
|
||
}
|
||
|
||
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}";
|
||
}
|
||
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
||
}
|
||
|
||
public string MdySkuImgReplace(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("'", "\\'");
|
||
var id = RegexUtils.GetStringQuery(ref inputData, "db_id")?.Replace("'", "\\'");
|
||
string img_md5 = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "img_md5"));
|
||
string img_base64 = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "img_base64"));
|
||
string img_url = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "img_url"));
|
||
string img_type = RegexUtils.GetStringQuery(ref inputData, "img_type")?.Replace("'", "\\'");
|
||
string img_group = RegexUtils.GetStringQuery(ref inputData, "img_group")?.Replace("'", "\\'");
|
||
|
||
if (string.IsNullOrEmpty(user_name))
|
||
{
|
||
return "{\"code\":500,\"msg\":\"没有用户名\"}";
|
||
}
|
||
|
||
string conn = "ConnKJD";
|
||
MysqlUtils mySql = new MysqlUtils(conn);
|
||
string sql = "update bxx.sku_img_replace set";
|
||
if (img_md5 != null)
|
||
sql += " img_md5='" + img_md5 + "',";
|
||
if (img_base64 != null)
|
||
sql += " img_base64='" + img_base64 + "',";
|
||
if (img_url != null)
|
||
sql += " img_url='" + img_url + "',";
|
||
if (img_type != null)
|
||
sql += " img_type='" + img_type + "',";
|
||
if (img_group != null)
|
||
sql += " img_group='" + img_group + "',";
|
||
sql = sql.TrimEnd(',');
|
||
sql += " where id=" + id + ";";
|
||
|
||
var rst = mySql.ExecuteNonQuery(sql);
|
||
mySql.Close();
|
||
if (rst)
|
||
{
|
||
return "{\"code\":200,\"msg\":\"success\"}";
|
||
}
|
||
else
|
||
{
|
||
return "{\"code\":500,\"msg\":\"更新失败:" + mySql.Message + "\"}";
|
||
}
|
||
}
|
||
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
||
}
|
||
|
||
public string AddSkuImg(string inputData)
|
||
{
|
||
if (!string.IsNullOrEmpty(inputData))
|
||
{
|
||
var time = 0;
|
||
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "time"), out time);
|
||
string time1 = RegexUtils.GetStringQuery(ref inputData, "code");
|
||
if (time1 != EncrypUtil.Encryption(time))
|
||
return "{\"code\":50000,\"msg\":\"校验失败\"}";
|
||
|
||
string user_name = RegexUtils.GetStringQuery(ref inputData, "user_name").Replace("'", "\\'");
|
||
string img_md5 = RegexUtils.GetStringQuery(ref inputData, "img_md5").Replace("'", "\\'");
|
||
string img_base64 = RegexUtils.GetStringQuery(ref inputData, "img_base64").Replace("'", "\\'");
|
||
string img_url = RegexUtils.GetStringQuery(ref inputData, "img_url").Replace("'", "\\'");
|
||
|
||
if (string.IsNullOrEmpty(user_name))
|
||
{
|
||
return "{\"code\":500,\"msg\":\"没有用户名\"}";
|
||
}
|
||
|
||
int sku_img_replace_id = 0;
|
||
string conn = "ConnKJD";
|
||
MysqlUtils mySql = new MysqlUtils(conn);
|
||
string sql = "";
|
||
|
||
sql = "select id from bxx.sku_img where img_md5='" + img_md5 + "';";
|
||
var bRst = false;
|
||
var rst = mySql.ExecuteFirstInt(sql).ParseToLong();
|
||
if (rst <= 0)
|
||
{
|
||
sql = "insert into bxx.sku_img (img_md5,img_base64,img_url) " +
|
||
"values ('" + img_md5 + "','" + img_base64 + "','" + img_url + "');";
|
||
rst = mySql.ExecuteInsertId(sql);
|
||
if (rst > 0)
|
||
{
|
||
mySql.Close();
|
||
return "{\"code\":200,\"msg\":\"success\",\"insert_id\":" + rst + "}";
|
||
}
|
||
}
|
||
else
|
||
{
|
||
sku_img_replace_id = (int)rst;
|
||
sql = "update bxx.sku_img set img_url='" + img_url + "' where img_md5='" + img_md5 + "';";
|
||
|
||
bRst = mySql.ExecuteNonQuery(sql);
|
||
if (bRst)
|
||
{
|
||
mySql.Close();
|
||
return "{\"code\":200,\"msg\":\"success\",\"update_id\":" + rst + "}";
|
||
}
|
||
}
|
||
mySql.Close();
|
||
|
||
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}";
|
||
}
|
||
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
||
}
|
||
|
||
public string WxApiGetWxAllCate(string inputData)
|
||
{
|
||
if (!string.IsNullOrEmpty(inputData))
|
||
{
|
||
if (!WXUserService.GetSign(inputData))
|
||
return "{\"code\":999,\"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\":\"校验失败\"}";
|
||
string token = RegexUtils.GetStringQuery(ref inputData, "token", true);
|
||
return HttpUtils.WxApiGetResponse("https://api.weixin.qq.com/shop/ec/category/all?access_token=" + token, "");
|
||
}
|
||
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
||
}
|
||
|
||
public string WxApiDropshipSearch(string inputData)
|
||
{
|
||
if (!string.IsNullOrEmpty(inputData))
|
||
{
|
||
if (!WXUserService.GetSign(inputData))
|
||
return "{\"code\":999,\"msg\":\"校验失败\"}";
|
||
|
||
string token = RegexUtils.GetStringQuery(ref inputData, "token", true)?.Replace("'", "\\'");
|
||
string order_id = RegexUtils.GetStringQuery(ref inputData, "order_id", true)?.Replace("'", "\\'");
|
||
string status = RegexUtils.GetStringQuery(ref inputData, "status", true)?.Replace("'", "\\'");
|
||
//string data = "{\"search_condition\":{\"order_id\":\"37000204335323251\" },\"page_info\":{\"offset\": 0,\"limit\":10}}";
|
||
string data = "{\"search_condition\":{\"order_id\":\"" + order_id + "\",\"status\":" + status + "}}";
|
||
return HttpUtils.WxApiPostResponse("https://api.weixin.qq.com/channels/ec/order/dropship/search?access_token=" + token, data, "");
|
||
}
|
||
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
||
}
|
||
|
||
/// <summary>
|
||
/// 微信小店分配订单代发
|
||
/// </summary>
|
||
/// <param name="inputData"></param>
|
||
/// <returns></returns>
|
||
public string WxApiDropshipAssign(string inputData)
|
||
{
|
||
if (!string.IsNullOrEmpty(inputData))
|
||
{
|
||
if (!WXUserService.GetSign(inputData))
|
||
return "{\"code\":999,\"msg\":\"校验失败\"}";
|
||
var token = RegexUtils.GetStringQuery(ref inputData, "token")?.Replace("'", "\\'");
|
||
var order_id = RegexUtils.GetStringQuery(ref inputData, "order_id")?.Replace("'", "\\'");
|
||
//var supplier_appid = RegexUtils.GetStringQuery(ref inputData, "supplier_appid")?.Replace("'", "\\'");
|
||
var dropship_product_list = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "dropship_product_list"))?.Replace("'", "\\'");
|
||
//{
|
||
// "order_id": "37012940902395351",
|
||
// "supplier_appid": "wxabc",
|
||
// "dropship_product_list": [
|
||
// {
|
||
// "spu_id": "1253129080",
|
||
// "sku_id": "2983950535",
|
||
// "product_cnt": 3
|
||
// }
|
||
// ]
|
||
//}
|
||
|
||
//{ "code":0,"data":{ "list":[{ "name":"29供货商","appid":"wxfc630d60a1af6c6f","status":1,"bindAuditStatus":1,"unbindAuditStatus":0,"bindTime":1782903213,"unbindTime":0,"updateTime":1782903213,"actionSource":0,"remark":"","headImg":""}],"totalCount":1} }
|
||
|
||
try
|
||
{
|
||
|
||
JObject obj = new JObject();
|
||
obj["order_id"] = order_id;
|
||
obj["supplier_appid"] = "wxfc630d60a1af6c6f";
|
||
JArray array = JArray.Parse(dropship_product_list);
|
||
obj["dropship_product_list"] = array;
|
||
|
||
return HttpUtils.WxApiPostResponse("https://api.weixin.qq.com/channels/ec/order/dropship/assign?access_token=" + token, JsonUtils.SerializeObject(obj), "");
|
||
}
|
||
catch
|
||
{
|
||
|
||
}
|
||
}
|
||
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
||
}
|
||
|
||
public string WxApiDropshipCancel(string inputData)
|
||
{
|
||
if (!string.IsNullOrEmpty(inputData))
|
||
{
|
||
if (!WXUserService.GetSign(inputData))
|
||
return "{\"code\":999,\"msg\":\"校验失败\"}";
|
||
var token = RegexUtils.GetStringQuery(ref inputData, "token")?.Replace("'", "\\'");
|
||
var order_id = RegexUtils.GetStringQuery(ref inputData, "order_id")?.Replace("'", "\\'");
|
||
var ds_order_id = RegexUtils.GetStringQuery(ref inputData, "ds_order_id")?.Replace("'", "\\'");
|
||
var dropship_product_list = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "dropship_product_list"))?.Replace("'", "\\'");
|
||
|
||
try
|
||
{
|
||
JObject obj = new JObject();
|
||
obj["order_id"] = order_id;
|
||
obj["ds_order_id"] = ds_order_id;
|
||
JArray array = JArray.Parse(dropship_product_list);
|
||
obj["dropship_product_list"] = array;
|
||
|
||
return HttpUtils.WxApiPostResponse("https://api.weixin.qq.com/channels/ec/order/dropship/cancel?access_token=" + token, JsonUtils.SerializeObject(obj), "");
|
||
}
|
||
catch
|
||
{
|
||
|
||
}
|
||
}
|
||
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
||
}
|
||
|
||
|
||
public string WxApiCategoryClassify(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\":\"校验失败\"}";
|
||
|
||
string post_data = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "post_data"));
|
||
string token = RegexUtils.GetStringQuery(ref inputData, "token");
|
||
|
||
return HttpUtils.WxApiPostResponse("https://api.weixin.qq.com/channels/ec/product/category/classify?access_token=" + token, post_data, "");
|
||
}
|
||
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
||
}
|
||
|
||
public string WxApiUploadImage(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\":\"校验失败\"}";
|
||
|
||
string img_base64 = RegexUtils.GetStringQuery(ref inputData, "img_base64")?.Replace("'", "\\'");
|
||
if (!string.IsNullOrEmpty(img_base64))
|
||
{
|
||
return WxApiUploadImageBase64(inputData, img_base64);
|
||
}
|
||
bool is_file = RegexUtils.GetStringQuery(ref inputData, "is_file")?.Replace("'", "\\'").ToLower() == "true";
|
||
if (is_file)
|
||
{
|
||
return WxApiUploadImageFile(inputData);
|
||
}
|
||
|
||
|
||
string post_data = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "post_data"));
|
||
string token = RegexUtils.GetStringQuery(ref inputData, "token");
|
||
|
||
//https://api.weixin.qq.com/shop/ec/basics/img/upload?access_token=ACCESS_TOKEN&upload_type=1&resp_type=1
|
||
return HttpUtils.WxApiPostResponse("https://api.weixin.qq.com/shop/ec/basics/img/upload?access_token=" + token +
|
||
"&upload_type=1&resp_type=1", post_data, "");
|
||
}
|
||
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
||
}
|
||
|
||
public string WxApiUploadImageFile(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\":\"校验失败\"}";
|
||
|
||
string token = RegexUtils.GetStringQuery(ref inputData, "token")?.Replace("'", "\\'");
|
||
string img_url = RegexUtils.GetStringQuery(ref inputData, "img_url")?.Replace("'", "\\'");
|
||
string random_code = RegexUtils.GetStringQuery(ref inputData, "random_code")?.Replace("'", "\\'");
|
||
int img_width = RegexUtils.GetStringQuery(ref inputData, "width").ParseToInt();
|
||
int img_height = RegexUtils.GetStringQuery(ref inputData, "height").ParseToInt();
|
||
bool is_keep_file = RegexUtils.GetStringQuery(ref inputData, "is_keep_file").ParseToBool();
|
||
|
||
string getImgError;
|
||
var image = HttpUtils.GetUrlImg(img_url.Replace("https://", "http://"), out getImgError);
|
||
if (!string.IsNullOrEmpty(getImgError) || image == null)
|
||
{
|
||
return "{\"code\":50001,\"msg\":\"获取图片失败:" + getImgError + "\"}";
|
||
}
|
||
try
|
||
{
|
||
if (img_width.IsNullOrZero() || img_height.IsNullOrZero())
|
||
{
|
||
img_width = image.Width;
|
||
img_height = image.Height;
|
||
}
|
||
var imageBg = new Bitmap(img_width, img_height);
|
||
using (Graphics g = Graphics.FromImage(imageBg))
|
||
{
|
||
g.DrawImage(image, new Rectangle(0, 0, imageBg.Width, imageBg.Height), 0, 0, image.Width, image.Height, GraphicsUnit.Pixel);
|
||
if (!string.IsNullOrEmpty(random_code) && random_code.ToLower() == "true")
|
||
{
|
||
g.FillRectangle(new SolidBrush(Color.FromArgb(RandomUtils.GetId(256), RandomUtils.GetId(256), RandomUtils.GetId(256))),
|
||
new Rectangle(RandomUtils.GetId(imageBg.Width - 30), RandomUtils.GetId(imageBg.Height - 30), 30, 30));
|
||
}
|
||
}
|
||
|
||
//string tempImgPath = Path.GetTempPath() + "\\" + RandomUtils.GetWordNumber(8).ToLower();
|
||
string tempImgPath = "C:\\tempImg\\" + RandomUtils.GetWordNumber(8).ToLower();
|
||
if (!Directory.Exists(tempImgPath))
|
||
Directory.CreateDirectory(tempImgPath);
|
||
string imgFullPath = tempImgPath + "\\" + EncrypUtil.GetMd5(img_url) + ".jpg";
|
||
imageBg.Save(imgFullPath, System.Drawing.Imaging.ImageFormat.Jpeg);
|
||
|
||
var apiUpImgFileRst = HttpUtils.WxApiUploadImgFile(imgFullPath, imageBg.Width, imageBg.Height, token);
|
||
if (string.IsNullOrEmpty(apiUpImgFileRst))
|
||
apiUpImgFileRst = "{\"code\":50002,\"msg\":\"图片传输超时\"}";
|
||
|
||
if (!is_keep_file)
|
||
{
|
||
try
|
||
{
|
||
// 删除文件夹及其所有内容
|
||
Directory.Delete(tempImgPath, true); // 第二个参数为true表示递归删除所有子文件夹和文件
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
}
|
||
}
|
||
return apiUpImgFileRst;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
return "{\"code\":50001,\"msg\":\"上传图片失败:" + ex.Message + "\"}";
|
||
}
|
||
|
||
}
|
||
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
||
}
|
||
|
||
public string WxApiUploadImageBase64(string inputData, string imgBase64)
|
||
{
|
||
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\":\"校验失败\"}";
|
||
|
||
string token = RegexUtils.GetStringQuery(ref inputData, "token")?.Replace("'", "\\'");
|
||
string img_url = RegexUtils.GetStringQuery(ref inputData, "img_url")?.Replace("'", "\\'");
|
||
bool is_keep_file = RegexUtils.GetStringQuery(ref inputData, "is_keep_file").ParseToBool();
|
||
|
||
is_keep_file = System.Configuration.ConfigurationManager.ConnectionStrings["IsKeepBase64UploadImgFile"]?.ConnectionString == "1";
|
||
|
||
try
|
||
{
|
||
byte[] imageBytes = Convert.FromBase64String(imgBase64);
|
||
using (MemoryStream ms = new MemoryStream(imageBytes, 0, imageBytes.Length))
|
||
{
|
||
// 创建Image对象
|
||
Image imageBg = Image.FromStream(ms, true);
|
||
|
||
string tempImgPath = "C:\\tempImg\\" + RandomUtils.GetWordNumber(16).ToLower();
|
||
if (!Directory.Exists(tempImgPath))
|
||
Directory.CreateDirectory(tempImgPath);
|
||
string imgFullPath = tempImgPath + "\\" + EncrypUtil.GetMd5(img_url) + ".jpg";
|
||
imageBg.Save(imgFullPath, System.Drawing.Imaging.ImageFormat.Jpeg);
|
||
|
||
var apiUpImgFileRst = HttpUtils.WxApiUploadImgFile(imgFullPath, imageBg.Width, imageBg.Height, token);
|
||
if (string.IsNullOrEmpty(apiUpImgFileRst))
|
||
apiUpImgFileRst = "{\"code\":50002,\"msg\":\"图片传输超时\"}";
|
||
|
||
if (!is_keep_file)
|
||
{
|
||
try
|
||
{
|
||
// 删除文件夹及其所有内容
|
||
Directory.Delete(tempImgPath, true); // 第二个参数为true表示递归删除所有子文件夹和文件
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
}
|
||
}
|
||
return apiUpImgFileRst;
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
return "{\"code\":50001,\"msg\":\"上传图片失败:" + ex.Message + "\"}";
|
||
}
|
||
|
||
}
|
||
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
||
}
|
||
|
||
|
||
|
||
public string AddJSTSku(string inputData)
|
||
{
|
||
if (!string.IsNullOrEmpty(inputData))
|
||
{
|
||
var time = 0;
|
||
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "time"), out time);
|
||
string time1 = RegexUtils.GetStringQuery(ref inputData, "code");
|
||
if (time1 != EncrypUtil.Encryption(time))
|
||
return "{\"code\":50000,\"msg\":\"校验失败\"}";
|
||
|
||
string user_name = RegexUtils.GetStringQuery(ref inputData, "user_name")?.Replace("'", "\\'");
|
||
if (string.IsNullOrEmpty(user_name))
|
||
return "{\"code\":50000,\"msg\":\"用户不存在\"}";
|
||
|
||
string coid = RegexUtils.GetStringQuery(ref inputData, "coid")?.Replace("'", "\\'");
|
||
string supplierId = RegexUtils.GetStringQuery(ref inputData, "supplierId")?.Replace("'", "\\'");
|
||
string supplierName = RegexUtils.GetStringQuery(ref inputData, "supplierName");
|
||
string skuId = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "skuId"))?.Replace("'", "\\'");
|
||
string itemSpuId = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "itemSpuId"))?.Replace("'", "\\'");
|
||
string pic = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "pic"))?.Replace("'", "\\'");
|
||
string itemName = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "itemName"));
|
||
string styleCode = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "styleCode"));
|
||
string itemCode = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "itemCode"))?.Replace("'", "\\'");
|
||
string color = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "color"))?.Replace("'", "\\'");
|
||
string spec = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "spec"))?.Replace("'", "\\'");
|
||
string salePrice = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "salePrice"))?.Replace("'", "\\'");
|
||
string supplyPrice = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "supplyPrice"))?.Replace("'", "\\'");
|
||
string stock = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "stock"))?.Replace("'", "\\'");
|
||
string stockTime = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "stockTime"))?.Replace("'", "\\'");
|
||
string weight = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "weight"))?.Replace("'", "\\'");
|
||
string status = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "status"))?.Replace("'", "\\'");
|
||
if (string.IsNullOrEmpty(user_name))
|
||
{
|
||
return "{\"code\":500,\"msg\":\"没有用户名\"}";
|
||
}
|
||
|
||
string conn = "ConnKJD";
|
||
MysqlUtils mySql = new MysqlUtils(conn);
|
||
string sql = "";
|
||
sql = "insert into ";
|
||
sql += "bxx.product_sku_restore ";
|
||
sql += "(coid,supplierId,supplierName,skuId,itemSpuId,pic,itemName,styleCode,itemCode,color,spec,stockTime," +
|
||
"salePrice,supplyPrice,stock,weight) " +
|
||
"values ('" + coid + "','" + supplierId + "','" + supplierName + "','" + skuId + "','" + itemSpuId + "','" +
|
||
pic + "','" + itemName + "','" + styleCode + "','" + itemCode + "','" + color + "','" + spec + "','" + stockTime + "'," +
|
||
(salePrice.IsNullOrEmpty() ? "null" : salePrice) + "," + supplyPrice + "," + stock + "," + weight + ");";
|
||
|
||
List<MySqlParameter> paramLst = new List<MySqlParameter>();
|
||
//paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "product_json", Value = product_json, });
|
||
//paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "size_json", Value = size_json, });
|
||
var rst = mySql.ExecuteNonQuery(sql, paramLst.ToArray());
|
||
mySql.Close();
|
||
if (rst)
|
||
{
|
||
return "{\"code\":200,\"msg\":\"success\"}";
|
||
}
|
||
else
|
||
{
|
||
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}";
|
||
}
|
||
}
|
||
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
||
}
|
||
|
||
public string MdyJSTSku(string inputData)
|
||
{
|
||
if (!string.IsNullOrEmpty(inputData))
|
||
{
|
||
var time = 0;
|
||
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "time"), out time);
|
||
string time1 = RegexUtils.GetStringQuery(ref inputData, "code");
|
||
if (time1 != EncrypUtil.Encryption(time))
|
||
return "{\"code\":50000,\"msg\":\"校验失败\"}";
|
||
|
||
string user_name = RegexUtils.GetStringQuery(ref inputData, "user_name")?.Replace("'", "\\'");
|
||
if (string.IsNullOrEmpty(user_name))
|
||
return "{\"code\":50000,\"msg\":\"用户不存在\"}";
|
||
|
||
string coid = RegexUtils.GetStringQuery(ref inputData, "coid")?.Replace("'", "\\'");
|
||
string supplierId = RegexUtils.GetStringQuery(ref inputData, "supplierId")?.Replace("'", "\\'");
|
||
string supplierName = RegexUtils.GetStringQuery(ref inputData, "supplierName");
|
||
string skuId = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "skuId"))?.Replace("'", "\\'");
|
||
string itemSpuId = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "itemSpuId"))?.Replace("'", "\\'");
|
||
string pic = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "pic"))?.Replace("'", "\\'");
|
||
string itemName = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "itemName"));
|
||
string styleCode = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "styleCode"));
|
||
string itemCode = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "itemCode"))?.Replace("'", "\\'");
|
||
string color = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "color"))?.Replace("'", "\\'");
|
||
string spec = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "spec"))?.Replace("'", "\\'");
|
||
string salePrice = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "salePrice"))?.Replace("'", "\\'");
|
||
string supplyPrice = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "supplyPrice"))?.Replace("'", "\\'");
|
||
string stock = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "stock"))?.Replace("'", "\\'");
|
||
string stockTime = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "stockTime"))?.Replace("'", "\\'");
|
||
string weight = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "weight"))?.Replace("'", "\\'");
|
||
string status = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "status"))?.Replace("'", "\\'");
|
||
if (string.IsNullOrEmpty(user_name))
|
||
{
|
||
return "{\"code\":500,\"msg\":\"没有用户名\"}";
|
||
}
|
||
|
||
string conn = "ConnKJD";
|
||
MysqlUtils mySql = new MysqlUtils(conn);
|
||
string sql = "";
|
||
sql = "update ";
|
||
sql += "bxx.product_sku_restore p set ";
|
||
if (coid != null)
|
||
sql += " p.coid='" + coid + "',";
|
||
if (supplierId != null)
|
||
sql += " p.supplierId='" + supplierId + "',";
|
||
if (supplierName != null)
|
||
sql += " p.supplierName='" + supplierName + "',";
|
||
if (pic != null)
|
||
sql += " p.pic='" + pic + "',";
|
||
if (itemName != null)
|
||
sql += " p.itemName='" + itemName + "',";
|
||
if (styleCode != null)
|
||
sql += " p.styleCode='" + styleCode + "',";
|
||
if (itemCode != null)
|
||
sql += " p.itemCode='" + itemCode + "',";
|
||
if (color != null)
|
||
sql += " p.color='" + color + "',";
|
||
if (spec != null)
|
||
sql += " p.spec='" + spec + "',";
|
||
if (salePrice != null)
|
||
sql += " p.salePrice=" + salePrice + ",";
|
||
if (supplyPrice != null)
|
||
sql += " p.supplyPrice=" + supplyPrice + ",";
|
||
if (stock != null)
|
||
sql += " p.stock=" + stock + ",";
|
||
if (stockTime != null)
|
||
sql += " p.stockTime='" + stockTime + "',";
|
||
if (salePrice != null)
|
||
sql += " p.salePrice=" + salePrice + ",";
|
||
if (weight != null)
|
||
sql += " p.weight='" + weight + "',";
|
||
sql = sql.TrimEnd(',');
|
||
sql += " where skuId='" + skuId + "' and itemSpuId='" + itemSpuId + "';";
|
||
|
||
List<MySqlParameter> paramLst = new List<MySqlParameter>();
|
||
//paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "product_json", Value = product_json, });
|
||
//paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "size_json", Value = size_json, });
|
||
var rst = mySql.ExecuteNonQuery(sql, paramLst.ToArray());
|
||
mySql.Close();
|
||
if (rst)
|
||
{
|
||
return "{\"code\":200,\"msg\":\"success\"}";
|
||
}
|
||
else
|
||
{
|
||
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}";
|
||
}
|
||
}
|
||
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
||
}
|
||
|
||
public string GetJSTSkuList(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 version = RegexUtils.GetStringQuery(ref inputData, "version").ParseToInt();
|
||
if (version < (System.Configuration.ConfigurationManager.ConnectionStrings["LimitVersion"]?.ConnectionString).ParseToInt())
|
||
return "{\"code\":1,\"msg\":\"当前版本过于陈旧,请立即升级新版\"}";
|
||
|
||
var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name")?.Replace("'", "\\'");
|
||
if (string.IsNullOrEmpty(user_name))
|
||
return "{\"code\":50000,\"msg\":\"用户不存在\"}";
|
||
|
||
var search_coid = RegexUtils.GetStringQuery(ref inputData, "search_coid")?.Replace("'", "\\'");
|
||
var search_supplierId = RegexUtils.GetStringQuery(ref inputData, "search_supplierId")?.Replace("'", "\\'");
|
||
var search_supplierName = RegexUtils.GetStringQuery(ref inputData, "search_supplierName")?.Replace("'", "\\'");
|
||
var search_skuId = RegexUtils.GetStringQuery(ref inputData, "search_skuId")?.Replace("'", "\\'");
|
||
var search_itemSpuId = RegexUtils.GetStringQuery(ref inputData, "search_itemSpuId")?.Replace("'", "\\'");
|
||
var search_itemName = RegexUtils.GetStringQuery(ref inputData, "search_itemName")?.Replace("'", "\\'");
|
||
var search_styleCode = RegexUtils.GetStringQuery(ref inputData, "search_styleCode")?.Replace("'", "\\'");
|
||
var search_itemCode = RegexUtils.GetStringQuery(ref inputData, "search_itemCode")?.Replace("'", "\\'");
|
||
var search_color = RegexUtils.GetStringQuery(ref inputData, "search_color")?.Replace("'", "\\'");
|
||
var search_spec = RegexUtils.GetStringQuery(ref inputData, "search_spec")?.Replace("'", "\\'");
|
||
var search_status = RegexUtils.GetStringQuery(ref inputData, "search_status")?.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(*) from bxx.product_sku_restore p where 1=1";
|
||
|
||
string where = "";
|
||
if (!string.IsNullOrEmpty(search_coid))
|
||
where += " and p.coid ='" + search_coid + "'";
|
||
if (!string.IsNullOrEmpty(search_supplierId))
|
||
where += " and p.supplierId ='" + search_supplierId + "'";
|
||
if (!string.IsNullOrEmpty(search_supplierName))
|
||
where += " and p.supplierName ='" + search_supplierName + "'";
|
||
if (!string.IsNullOrEmpty(search_skuId))
|
||
where += " and p.skuId ='" + search_skuId + "'";
|
||
if (!string.IsNullOrEmpty(search_itemSpuId))
|
||
where += " and p.itemSpuId ='" + search_itemSpuId + "'";
|
||
if (!string.IsNullOrEmpty(search_itemName))
|
||
where += " and p.itemName like '%" + search_itemName + "%'";
|
||
if (!string.IsNullOrEmpty(search_styleCode))
|
||
where += " and p.styleCode ='" + search_styleCode + "'";
|
||
if (!string.IsNullOrEmpty(search_itemCode))
|
||
where += " and p.itemCode ='" + search_itemCode + "'";
|
||
if (!string.IsNullOrEmpty(search_color))
|
||
where += " and p.color ='" + search_color + "'";
|
||
if (!string.IsNullOrEmpty(search_spec))
|
||
where += " and p.spec ='" + search_spec + "'";
|
||
if (!string.IsNullOrEmpty(search_status))
|
||
where += " and p.status ='" + search_status + "'";
|
||
|
||
sql += where;
|
||
|
||
var count = 0;
|
||
count = mySql.ExecuteRowCount(sql);
|
||
|
||
DataTable dt;
|
||
if (count == 0)
|
||
{
|
||
dt = new DataTable();
|
||
}
|
||
else
|
||
{
|
||
sql = "select p.* from bxx.product_sku_restore p" +
|
||
" where 1=1";
|
||
|
||
//where子句
|
||
sql += where;
|
||
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<JSTListProductSkuInfo> productLst = new List<JSTListProductSkuInfo>();
|
||
foreach (DataRow row in dt.Rows)
|
||
{
|
||
JSTListProductSkuInfo prod = new JSTListProductSkuInfo
|
||
{
|
||
id = Convert.ToInt32(row["id"]),
|
||
coid = row["coid"].ToString(),
|
||
color = row["color"].ToString(),
|
||
itemCode = row["itemCode"].ToString(),
|
||
itemName = row["itemName"].ToString(),
|
||
itemSpuId = row["itemSpuId"].ToString(),
|
||
pic = row["pic"].ToString(),
|
||
salePrice = row["salePrice"].ParseToDecimal(),
|
||
skuId = row["skuId"].ToString(),
|
||
spec = row["spec"].ToString(),
|
||
status = row["status"].ToString(),
|
||
stock = row["stock"].ParseToInt(),
|
||
styleCode = row["styleCode"].ParseToString(),
|
||
supplierId = row["supplierId"].ToString(),
|
||
supplierName = row["supplierName"].ToString(),
|
||
supplyPrice = row["supplyPrice"].ParseToDecimal(),
|
||
add_time = Convert.ToDateTime(row["add_time"]),
|
||
mdy_time = Convert.ToDateTime(row["mdy_time"]),
|
||
stockTime = row["stockTime"].ParseToString().ParseToDateTime(),
|
||
weight = row["weight"].ParseToDecimal(),
|
||
};
|
||
productLst.Add(prod);
|
||
}
|
||
JsonSerializerSettings jsonSetting = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore };
|
||
var data = JsonUtils.SerializeObjectToString(productLst, 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 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 bxx.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\":\"输入为空\"}";
|
||
}
|
||
|
||
/// <summary>
|
||
/// 随机工厂商品
|
||
/// </summary>
|
||
/// <param name="inputData"></param>
|
||
/// <returns></returns>
|
||
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 bxx.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 AddRelation(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_spu_id = RegexUtils.GetStringQuery(ref inputData, "up_spu_id")?.Replace("'", "\\'");
|
||
if (string.IsNullOrEmpty(up_spu_id))
|
||
{
|
||
return "{\"code\":500,\"msg\":\"缺少上家编号\"}";
|
||
}
|
||
var index = RegexUtils.GetStringQuery(ref inputData, "index").ParseToNullableLong();
|
||
if (index == null)
|
||
index = Math.Abs(up_spu_id.GetHashCode()) % 128;
|
||
var up_goods_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "up_goods_name"));
|
||
if (string.IsNullOrEmpty(up_goods_name))
|
||
{
|
||
return "{\"code\":500,\"msg\":\"缺少上家商品名称\"}";
|
||
}
|
||
var from_site = RegexUtils.GetStringQuery(ref inputData, "from_site")?.Replace("'", "\\'");
|
||
if (string.IsNullOrEmpty(from_site))
|
||
{
|
||
return "{\"code\":500,\"msg\":\"缺少关联商品平台\"}";
|
||
}
|
||
var goods_id = RegexUtils.GetStringQuery(ref inputData, "goods_id")?.Replace("'", "\\'");
|
||
if (string.IsNullOrEmpty(goods_id))
|
||
{
|
||
return "{\"code\":500,\"msg\":\"缺少关联商品编号\"}";
|
||
}
|
||
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 bxx_relation.out_prod_relation_" + index.ParseToString().PadLeft(4, '0') +
|
||
" (up_spu_id,up_goods_name,from_site,goods_id,shop_id,price_min,price_max) " +
|
||
" values ('" + up_spu_id + "',@up_goods_name,'" + from_site + "','" +
|
||
goods_id + "'," + shop_id + "," + price_min + "," + price_max + ");";
|
||
List<MySqlParameter> paramLst = new List<MySqlParameter>();
|
||
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@up_goods_name", Value = up_goods_name, });
|
||
mySql.ExecuteNonQuery(sql, paramLst.ToArray());
|
||
mySql.Close();
|
||
if (mySql.Message.IsNullOrEmpty())
|
||
{
|
||
return "{\"code\":200,\"msg\":\"成功\"}";
|
||
}
|
||
else
|
||
{
|
||
return "{\"code\":500,\"msg\":\"失败:" + mySql.Message + "\"}";
|
||
}
|
||
}
|
||
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
||
}
|
||
|
||
public string GetRelation(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_spu_id = RegexUtils.GetStringQuery(ref inputData, "up_spu_id")?.Replace("'", "\\'");
|
||
if (string.IsNullOrEmpty(up_spu_id))
|
||
{
|
||
return "{\"code\":500,\"msg\":\"缺少来源商品编号\"}";
|
||
}
|
||
var index = RegexUtils.GetStringQuery(ref inputData, "index").ParseToNullableLong();
|
||
if (index == null)
|
||
index = Math.Abs(up_spu_id.GetHashCode()) % 128;
|
||
|
||
string conn = "ConnKJD";
|
||
MysqlUtils mySql = new MysqlUtils(conn);
|
||
|
||
string sql = "select * from bxx_relation.out_prod_relation_" + index.ParseToString().PadLeft(4, '0') +
|
||
" where up_spu_id='" + up_spu_id + "' limit 20;";
|
||
var dt = mySql.ExecuteDataTable(sql);
|
||
mySql.Close();
|
||
if (mySql.Message.IsNullOrEmpty())
|
||
{
|
||
JArray jArr = new JArray();
|
||
foreach (DataRow row in dt.Rows)
|
||
{
|
||
JObject jObj = new JObject();
|
||
jObj["id"] = row["id"].ParseToInt();
|
||
jObj["up_spu_id"] = row["up_spu_id"].ToString();
|
||
jObj["up_goods_name"] = row["up_goods_name"].ToString();
|
||
jObj["from_site"] = row["from_site"].ToString();
|
||
jObj["goods_id"] = row["goods_id"].ToString();
|
||
jObj["shop_id"] = row["shop_id"].ToString();
|
||
jObj["price_min"] = row["price_min"].ParseToInt();
|
||
jObj["price_max"] = row["price_max"].ParseToInt();
|
||
jObj["add_time"] = row["add_time"].ParseToString().ParseToDateTime();
|
||
jArr.Add(jObj);
|
||
}
|
||
JsonSerializerSettings jsonSetting = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore };
|
||
var data = JsonUtils.SerializeObjectToString(jArr, jsonSetting);
|
||
return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"count\":" + jArr.Count + "}";
|
||
}
|
||
else
|
||
{
|
||
return "{\"code\":500,\"msg\":\"失败:" + mySql.Message + "\"}";
|
||
}
|
||
}
|
||
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
||
}
|
||
|
||
public string AddMdyJstProductBan(string inputData)
|
||
{
|
||
if (!string.IsNullOrEmpty(inputData))
|
||
{
|
||
if (!WXUserService.GetSign(inputData))
|
||
return "{\"code\":999,\"msg\":\"校验失败\"}";
|
||
|
||
// 软件用户名
|
||
string coid = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "coid"))?.Replace("'", "\\'");
|
||
int? ban_wx = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "ban_wx"))?.ParseToNullableInt();
|
||
int? ban_pdd = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "ban_pdd"))?.ParseToNullableInt();
|
||
// 收件人
|
||
string user_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "receiver"))?.Replace("'", "\\'");
|
||
if (string.IsNullOrEmpty(coid))
|
||
return "{\"code\":500,\"msg\":\"缺少供应商编号\"}";
|
||
if (ban_wx == null)
|
||
return "{\"code\":500,\"msg\":\"缺少设置值\"}";
|
||
if (ban_pdd == null)
|
||
return "{\"code\":500,\"msg\":\"缺少设置值\"}";
|
||
|
||
string conn = "ConnKJD";
|
||
MysqlUtils mySql = new MysqlUtils(conn, true);
|
||
|
||
string sql = "SELECT 1 FROM `bxx`.`jst_supplier_ban_platform` where coid='" + coid + "'";
|
||
string where = "";
|
||
sql += where;
|
||
var exist = mySql.ExecuteFirstInt(sql);
|
||
if (!mySql.Message.IsNullOrEmpty())
|
||
{
|
||
mySql.RollBack();
|
||
mySql.Close();
|
||
return "{\"code\":501,\"msg\":\"" + mySql.Message + "\"}";
|
||
}
|
||
|
||
if (exist == 0)
|
||
{
|
||
sql = " INSERT INTO `bxx`.`jst_supplier_ban_platform` (coid,ban_wx,ban_pdd)" +
|
||
" VALUES (@coid,@ban_wx,@ban_pdd);";
|
||
}
|
||
else
|
||
{
|
||
sql = "UPDATE `bxx`.`jst_supplier_ban_platform` SET ";
|
||
if (ban_wx != null)
|
||
sql += " ban_wx=@ban_wx,";
|
||
if (ban_pdd != null)
|
||
sql += " ban_pdd=@ban_pdd,";
|
||
sql = sql.TrimEnd(',');
|
||
sql += " 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.Int16, ParameterName = "ban_wx", Value = ban_wx, });
|
||
paramLst.Add(new MySqlParameter() { DbType = DbType.Int16, ParameterName = "ban_pdd", Value = ban_pdd, });
|
||
var rowCnt = mySql.ExecuteAffectedRows(sql, paramLst.ToArray());
|
||
if (!string.IsNullOrEmpty(mySql.Message))
|
||
{
|
||
mySql.RollBack();
|
||
mySql.Close();
|
||
return "{\"code\":50003,\"msg\":\"" + mySql.Message + "\",\"data\":\"\"}";
|
||
}
|
||
|
||
sql = "UPDATE `bxx`.`product` SET ";
|
||
if (ban_wx != null)
|
||
sql += " ban_wx=@ban_wx,";
|
||
if (ban_pdd != null)
|
||
sql += " ban_pdd=@ban_pdd,";
|
||
sql = sql.TrimEnd(',');
|
||
sql += " WHERE (real_coid=@coid or skc_id=@coid) AND product_get_type='厂商直采';";
|
||
rowCnt = mySql.ExecuteAffectedRows(sql, paramLst.ToArray());
|
||
if (!string.IsNullOrEmpty(mySql.Message))
|
||
{
|
||
mySql.RollBack();
|
||
mySql.Close();
|
||
return "{\"code\":50003,\"msg\":\"" + mySql.Message + "\",\"data\":\"\"}";
|
||
}
|
||
|
||
mySql.Commit();
|
||
mySql.Close();
|
||
return "{\"code\":200,\"msg\":\"success\",\"data\":\"\"}";
|
||
}
|
||
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
||
}
|
||
|
||
public string GetJstProductCoidList(string inputData)
|
||
{
|
||
if (!string.IsNullOrEmpty(inputData))
|
||
{
|
||
var timeCalc = DateTime.Now;
|
||
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(200);
|
||
string coids = RegexUtils.GetStringQuery(ref inputData, "coids")?.Replace("'", "\\'");
|
||
string not_count = RegexUtils.GetStringQuery(ref inputData, "not_count")?.Replace("'", "\\'");
|
||
|
||
string conn = "ConnKJD";
|
||
MysqlUtils mySql = new MysqlUtils(conn);
|
||
|
||
string tableName = GetProductTableName(inputData);
|
||
string sql = "";
|
||
var count = -1;
|
||
|
||
//sql = " SELECT COUNT(*) FROM" +
|
||
// " (SELECT skc_id as coid FROM " + tableName + " WHERE product_get_type='厂商直采' UNION SELECT real_coid as coid FROM " + tableName + " WHERE product_get_type='厂商直采') as coids" +
|
||
// " WHERE 1=1 AND coids.coid != ''";
|
||
sql = "select count(*) FROM (SELECT DISTINCT coids.*,a.after_sale_json,p.from_shop_name,b.ban_wx,b.ban_pdd" +
|
||
" FROM (SELECT skc_id as coid FROM " + tableName + " WHERE product_get_type='厂商直采' UNION SELECT real_coid as coid FROM " + tableName + " WHERE product_get_type='厂商直采') as coids" +
|
||
" LEFT JOIN wxxd.after_sale as a ON coids.coid=a.coid AND a.is_del = 0" +
|
||
" LEFT JOIN " + tableName + " p ON coids.coid=p.skc_id AND p.product_get_type='厂商直采'" +
|
||
" LEFT JOIN bxx.jst_supplier_ban_platform b ON coids.coid=b.coid" +
|
||
" WHERE 1=1 AND coids.coid != ''";
|
||
string where = "";
|
||
if (coids != null)
|
||
where += " AND coids.coid IN ('" + coids.Replace(",", "','") + "')";
|
||
sql += where;
|
||
sql += ") as cnt";
|
||
sql += ";";
|
||
|
||
if (not_count != "true")
|
||
count = mySql.ExecuteRowCount(sql);
|
||
|
||
DataTable dt;
|
||
if (count == 0)
|
||
{
|
||
dt = new DataTable();
|
||
}
|
||
else
|
||
{
|
||
sql = " SELECT DISTINCT coids.*,a.after_sale_json,p.from_shop_name,b.ban_wx,b.ban_pdd" +
|
||
" FROM (SELECT skc_id as coid FROM " + tableName + " WHERE product_get_type='厂商直采' UNION SELECT real_coid as coid FROM " + tableName + " WHERE product_get_type='厂商直采') as coids" +
|
||
" LEFT JOIN wxxd.after_sale as a ON coids.coid=a.coid AND a.is_del = 0" +
|
||
" LEFT JOIN " + tableName + " p ON coids.coid=p.skc_id AND p.product_get_type='厂商直采'" +
|
||
" LEFT JOIN bxx.jst_supplier_ban_platform b ON coids.coid=b.coid" +
|
||
" WHERE 1=1 AND coids.coid != ''";
|
||
sql += where;
|
||
//sql += " ORDER BY coid DESC";
|
||
//sql += " ORDER BY coid ASC";
|
||
sql += " LIMIT " + Math.Max(0, page - 1) * page_size + "," + page_size + ";";
|
||
dt = mySql.ExecuteDataTable(sql);
|
||
if (!string.IsNullOrEmpty(mySql.Message))
|
||
{
|
||
mySql.Close();
|
||
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\",\"data\":[],\"count\":" + 0 + "}";
|
||
}
|
||
}
|
||
mySql.Close();
|
||
|
||
if (dt != null)
|
||
{
|
||
try
|
||
{
|
||
List<JObject> coidLst = new List<JObject>();
|
||
foreach (DataRow row in dt.Rows)
|
||
{
|
||
var jObj = new JObject();
|
||
var afterSaleJson = row["after_sale_json"].ParseToString();
|
||
var supplier_name = row["from_shop_name"].ParseToString();
|
||
if (string.IsNullOrEmpty(supplier_name))
|
||
supplier_name = RegexUtils.GetStringJson(ref afterSaleJson, "name");
|
||
coidLst.Add(jObj);
|
||
jObj["coid"] = row["coid"].ParseToString();
|
||
jObj["supplier_name"] = supplier_name;
|
||
jObj["ban_wx"] = row["ban_wx"].ParseToInt();
|
||
jObj["ban_pdd"] = row["ban_pdd"].ParseToInt();
|
||
}
|
||
JsonSerializerSettings jsonSetting = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore };
|
||
var data = JsonUtils.SerializeObjectToString(coidLst, 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 GetJstProductBanPlatformList(string inputData)
|
||
{
|
||
if (!string.IsNullOrEmpty(inputData))
|
||
{
|
||
var timeCalc = DateTime.Now;
|
||
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(200);
|
||
string coids = RegexUtils.GetStringQuery(ref inputData, "coid")?.Replace("'", "\\'");
|
||
string not_count = RegexUtils.GetStringQuery(ref inputData, "not_count")?.Replace("'", "\\'");
|
||
|
||
string conn = "ConnKJD";
|
||
MysqlUtils mySql = new MysqlUtils(conn);
|
||
|
||
string sql = "";
|
||
var count = -1;
|
||
|
||
sql = "SELECT count(*) FROM `bxx`.`jst_supplier_ban_platform` where 1=1";
|
||
string where = "";
|
||
if (coids != null)
|
||
where += " AND coid IN ('" + coids.Replace(",", "','") + "')";
|
||
sql += where;
|
||
sql += ";";
|
||
|
||
if (not_count != "true")
|
||
count = mySql.ExecuteRowCount(sql);
|
||
|
||
DataTable dt;
|
||
if (count == 0)
|
||
{
|
||
dt = new DataTable();
|
||
}
|
||
else
|
||
{
|
||
sql = "SELECT * FROM `bxx`.`jst_supplier_ban_platform` 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<JObject> supplierBanPlatformLst = new List<JObject>();
|
||
foreach (DataRow row in dt.Rows)
|
||
{
|
||
var jObj = new JObject();
|
||
supplierBanPlatformLst.Add(jObj);
|
||
jObj["id"] = row["id"].ParseToInt();
|
||
jObj["coid"] = row["coid"].ParseToString();
|
||
jObj["ban_wx"] = row["ban_wx"].ParseToInt();
|
||
jObj["ban_pdd"] = row["ban_pdd"].ParseToInt();
|
||
}
|
||
JsonSerializerSettings jsonSetting = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore };
|
||
var data = JsonUtils.SerializeObjectToString(supplierBanPlatformLst, 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 XJGetAiImage(string inputData)
|
||
//{
|
||
// if (string.IsNullOrEmpty(inputData))
|
||
// return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
||
|
||
// if (!WXUserService.GetSign(inputData))
|
||
// return "{\"code\":999,\"msg\":\"校验失败\"}";
|
||
|
||
// string image_url = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "image_url"))?.ParseToString();
|
||
// string word = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "word"))?.ParseToString();
|
||
// if (image_url == null)
|
||
// return "{\"code\":500,\"msg\":\"缺少图片地址\"}";
|
||
// if (word == null)
|
||
// return "{\"code\":500,\"msg\":\"缺少图片文字\"}";
|
||
|
||
// string secret = "sadhjufhe15c4fbvFBvcvds+5sdfds@#%$xsc";
|
||
// string time = TimeUtils.DateTimeToTimestampSeconds(DateTime.Now).ToString();
|
||
// string code = EncrypUtil.GetMd5(secret + time);
|
||
|
||
// try
|
||
// {
|
||
// string url = "http://ai-bs.jiaotian.vip:" + RandomUtils.GetId(20010, 20021) + "/index.php?obj=public/image";
|
||
// string data = "time=" + time + "&code=" + code + "&image_url=" + image_url + "&word=" + word;
|
||
// string html = HttpUtils.e57GetResponse(url, "");
|
||
// return html;
|
||
// }
|
||
// catch (Exception ex)
|
||
// {
|
||
// return "{\"code\":50001,\"msg\":\"" + ex.Message + "\"}";
|
||
// }
|
||
//}
|
||
|
||
public string IsGetWXRecommendHotProd(string inputData)
|
||
{
|
||
if (!string.IsNullOrEmpty(inputData))
|
||
{
|
||
if (!WXUserService.GetSign(inputData))
|
||
return "{\"code\":999,\"msg\":\"校验失败\"}";
|
||
|
||
var isGetReturn = System.Configuration.ConfigurationManager.ConnectionStrings["GetWXRecommendHotProd"]?.ConnectionString;
|
||
var isGetOnce = System.Configuration.ConfigurationManager.ConnectionStrings["GetWXRecommendHotProd"]?.ConnectionString;
|
||
var minViewUv = (System.Configuration.ConfigurationManager.ConnectionStrings["GetWXRecommendHotProdMinViewUv"]?.ConnectionString).ParseToInt(500);
|
||
var getInterval = (System.Configuration.ConfigurationManager.ConnectionStrings["GetWXRecommendHotProdInterval"]?.ConnectionString).ParseToInt(3);
|
||
return "{\"code\":200,\"is_get\":\"" + isGetReturn + "\",\"isGetOnce\":\"" + isGetOnce + "\"," +
|
||
"\"minViewUv\":" + minViewUv + ",\"getViewUvInterval\":" + getInterval + "}";
|
||
}
|
||
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
/*
|
||
List<MySqlParameter> paramLst = new List<MySqlParameter>();
|
||
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "spu_id", Value = spu_id, });
|
||
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "skc_id", Value = skc_id, });
|
||
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "cat_id", Value = cat_id, });
|
||
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "cat_name", Value = cat_name, });
|
||
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "product_name", Value = product_name, });
|
||
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "ext_code", Value = ext_code, });
|
||
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "main_img", Value = main_img, });
|
||
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "product_json", Value = product_json, });
|
||
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "size_json", Value = size_json, });
|
||
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "notes", Value = notes.ParseToString(), });
|
||
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "product_md5", Value = product_md5, });
|
||
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "add_time", Value = add_time, });
|
||
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "mdy_time", Value = mdy_time, });
|
||
rst = mySql.ExecuteInsertId(sql, paramLst.ToArray());*/
|
||
|
||
|
||
|
||
|
||
|