拼多多映射修复相关代码
This commit is contained in:
1 parent
bbb7d19dc1
commit
28a90b135c
2 files changed
+83
-8
No files matched your search
@@ -1,6 +1,7 @@
|
||||
using KJD_Web.BLL.WXXD;
|
||||
using KJD_Web.Model;
|
||||
using KJD_Web.Model.ShopModel;
|
||||
using KJD_Web.Upload.Prod;
|
||||
using KJD_Web.Utils;
|
||||
using MySql.Data.MySqlClient;
|
||||
using NaiBa.Util.Extension;
|
||||
@@ -3913,8 +3914,9 @@ namespace KJD_Web.BLL.BXX
|
||||
return "{\"code\":500,\"msg\":\"缺少上家编号\"}";
|
||||
}
|
||||
var index = RegexUtils.GetStringQuery(ref inputData, "index").ParseToNullableLong();
|
||||
if (index == null)
|
||||
index = Math.Abs(up_spu_id.GetHashCode()) % 128;
|
||||
index = Convert.ToInt32(EncrypUtil.GetMd5(up_spu_id).Substring(EncrypUtil.GetMd5(up_spu_id).Length - 4), 16) % 128;
|
||||
//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))
|
||||
{
|
||||
@@ -3949,7 +3951,7 @@ namespace KJD_Web.BLL.BXX
|
||||
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
||||
MysqlUtils mySql = new MysqlUtils(conn);
|
||||
|
||||
string sql = "insert into bxx_relation.out_prod_relation_" + index.ParseToString().PadLeft(4, '0') +
|
||||
string sql = "insert into bxx_relation.out_prod_relation_t" + 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 + ");";
|
||||
@@ -3984,16 +3986,89 @@ namespace KJD_Web.BLL.BXX
|
||||
return "{\"code\":500,\"msg\":\"缺少来源商品编号\"}";
|
||||
}
|
||||
var index = RegexUtils.GetStringQuery(ref inputData, "index").ParseToNullableLong();
|
||||
if (index == null)
|
||||
index = Math.Abs(up_spu_id.GetHashCode()) % 128;
|
||||
index = Convert.ToInt32(EncrypUtil.GetMd5(up_spu_id).Substring(EncrypUtil.GetMd5(up_spu_id).Length - 4), 16) % 128;
|
||||
//if (index == null)
|
||||
// index = Math.Abs(up_spu_id.GetHashCode()) % 128;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
||||
MysqlUtils mySql = new MysqlUtils(conn);
|
||||
|
||||
string sql = "select * from bxx_relation.out_prod_relation_" + index.ParseToString().PadLeft(4, '0') +
|
||||
string sql = "select * from bxx_relation.out_prod_relation_t" + index.ParseToString().PadLeft(4, '0') +
|
||||
" where up_spu_id='" + up_spu_id + "' limit 20;";
|
||||
var dt = mySql.ExecuteDataTable(sql);
|
||||
|
||||
mySql.Close();
|
||||
|
||||
//int uniqCount = 0; //95 个重复的(可能中间少记录一个)
|
||||
//var totalCount = 0; //30224 //30320
|
||||
//for (int i = 0; i < 128; i++)
|
||||
//{
|
||||
// sql = "";
|
||||
// mySql = new MysqlUtils(conn);
|
||||
|
||||
// //sql = @"drop table if exists bxx_relation.out_prod_relation_t" + i.ParseToString().PadLeft(4, '0') + ";\r\n";
|
||||
// //sql += @"CREATE TABLE bxx_relation.out_prod_relation_t" + i.ParseToString().PadLeft(4, '0') + @" (
|
||||
// // `id` int NOT NULL AUTO_INCREMENT,
|
||||
// // `up_spu_id` varchar(50) NOT NULL COMMENT '源商品id信息,此字段为分表依据',
|
||||
// // `up_goods_name` varchar(255) NOT NULL COMMENT '源商品标题',
|
||||
// // `from_site` varchar(10) NOT NULL COMMENT '商品来源平台如pdd,tb,1688,vd(微店)等',
|
||||
// // `goods_id` varchar(50) NOT NULL COMMENT '映射商品id信息',
|
||||
// // `shop_id` varchar(50) NOT NULL COMMENT '上传到的店铺id',
|
||||
// // `price_min` int NOT NULL COMMENT '最低价,单位分',
|
||||
// // `price_max` int NOT NULL COMMENT '最高价,单位分',
|
||||
// // `add_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
// // PRIMARY KEY(`id`),
|
||||
// // UNIQUE KEY `index_up_spu_id` (`up_spu_id`) USING BTREE,
|
||||
// // KEY `index_add_time` (`add_time`) USING BTREE,
|
||||
// // KEY `index_shop_id` (`shop_id`) USING BTREE,
|
||||
// // KEY `index_price_min` (`price_min`) USING BTREE,
|
||||
// // KEY `index_price_max` (`price_max`) USING BTREE
|
||||
// // ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '记录拼多多关联数据信息'";
|
||||
// //var rst = mySql.ExecuteNonQuery(sql);
|
||||
|
||||
// sql = "select * from bxx_relation.out_prod_relation_" + i.ParseToString().PadLeft(4, '0');
|
||||
// dt = mySql.ExecuteDataTable(sql);
|
||||
// totalCount += dt.Rows.Count;
|
||||
|
||||
// //sql = "select count(*) from bxx_relation.out_prod_relation_" + i.ParseToString().PadLeft(4, '0');
|
||||
// //totalCount += mySql.ExecuteFirstInt(sql);
|
||||
// foreach (DataRow row in dt.Rows)
|
||||
// {
|
||||
// var indexCount = dt.Rows.IndexOf(row);
|
||||
// JObject jObj = new JObject();
|
||||
// //jObj["id"] = row["id"].ParseToInt();
|
||||
// var up_spu_id1 = row["up_spu_id"].ToString();
|
||||
// var up_goods_name = row["up_goods_name"].ToString();
|
||||
// var from_site = row["from_site"].ToString();
|
||||
// var goods_id = row["goods_id"].ToString();
|
||||
// var shop_id = row["shop_id"].ToString();
|
||||
// var price_min = row["price_min"].ParseToInt();
|
||||
// var price_max = row["price_max"].ParseToInt();
|
||||
// var add_time = row["add_time"].ParseToString().ParseToDateTime();
|
||||
|
||||
|
||||
// index = Convert.ToInt32(EncrypUtil.GetMd5(up_spu_id1).Substring(EncrypUtil.GetMd5(up_spu_id1).Length - 4), 16) % 128;
|
||||
|
||||
// sql = "insert into bxx_relation.out_prod_relation_t" + index.ParseToString().PadLeft(4, '0') +
|
||||
// " (up_spu_id,up_goods_name,from_site,goods_id,shop_id,price_min,price_max,add_time) " +
|
||||
// " values ('" + up_spu_id1 + "',@up_goods_name,'" + from_site + "','" +
|
||||
// goods_id + "'," + shop_id + "," + price_min + "," + price_max + ",'" + add_time.ToString("yyyy-MM-dd HH:mm:ss") + "');";
|
||||
// List<MySqlParameter> paramLst = new List<MySqlParameter>();
|
||||
// paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@up_goods_name", Value = up_goods_name, });
|
||||
// var rs = mySql.ExecuteAffectedRows(sql, paramLst.ToArray());
|
||||
// if (rs != 1)
|
||||
// {
|
||||
// uniqCount++;
|
||||
// }
|
||||
// }
|
||||
|
||||
// mySql.Close();
|
||||
//}
|
||||
|
||||
if (mySql.Message.IsNullOrEmpty())
|
||||
{
|
||||
JArray jArr = new JArray();
|
||||
|
||||
@@ -38,8 +38,8 @@ namespace KJD_Web.BLL
|
||||
//string sql = "";
|
||||
//for (int i = 0; i < 128; i++)
|
||||
//{
|
||||
// sql = @"drop table if exists bxx_relation.out_prod_relation_" + i.ParseToString().PadLeft(4, '0') + ";\r\n";
|
||||
// sql += @"CREATE TABLE bxx_relation.out_prod_relation_" + i.ParseToString().PadLeft(4, '0') + @" (
|
||||
// sql = @"drop table if exists bxx_relation.out_prod_relation_" + i.ParseToString().PadLeft(6, '0') + ";\r\n";
|
||||
// sql += @"CREATE TABLE bxx_relation.out_prod_relation_" + i.ParseToString().PadLeft(6, '0') + @" (
|
||||
// `id` int NOT NULL AUTO_INCREMENT,
|
||||
// `up_spu_id` varchar(50) NOT NULL COMMENT '源商品id信息,此字段为分表依据',
|
||||
// `up_goods_name` varchar(255) NOT NULL COMMENT '源商品标题',
|
||||
|
||||
Reference in new issue
Block a user