增加老版本 KJDWebService

This commit is contained in:
chfei committed 2026-08-21 16:46:36 +08:00
1 parent 58abbb5b4f
commit f84c4c1949
115 files changed
+36598 -18

No files matched your search

@@ -0,0 +1,858 @@
using StoreHub.KJDWebService.Models;
using StoreHub.Framework.Repositorys;
using Microsoft.Extensions.Configuration;
using StoreHub.KJDWebService.Commons;
using MySql.Data.MySqlClient;
using NaiBa.Util.Extension;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
namespace StoreHub.KJDWebService.Services
{
public class BXXPriceService : ServiceBase
{
public BXXPriceService(SqlRepository sqlRepository, IConfiguration configuration) : base(sqlRepository, configuration)
{
}
public string AddPrice(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 user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
string ext_code = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "ext_code")).ParseToString();
int original_price = RegexUtils.GetStringQuery(ref inputData, "original_price").ParseToInt();
int markup_times = RegexUtils.GetStringQuery(ref inputData, "markup_times").ParseToInt();
int extra_price = RegexUtils.GetStringQuery(ref inputData, "extra_price").ParseToInt();
string notes = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "notes")).ParseToString();
if (string.IsNullOrEmpty(user_name))
{
return "{\"code\":500,\"msg\":\"没有用户名\"}";
}
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sqlExist = "select count(ext_code) from bxx.price_markup where ext_code=@ext_code";
string sql = "insert into bxx.price_markup " +
"(ext_code,original_price,markup_times,extra_price,notes) " +
"values (@ext_code,@original_price,@markup_times,@extra_price,@notes);";
List<MySqlParameter> paramLst = new List<MySqlParameter>();
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@ext_code", Value = ext_code, });
paramLst.Add(new MySqlParameter() { DbType = DbType.Int32, ParameterName = "@original_price", Value = original_price, });
paramLst.Add(new MySqlParameter() { DbType = DbType.Int32, ParameterName = "@markup_times", Value = markup_times, });
paramLst.Add(new MySqlParameter() { DbType = DbType.Int32, ParameterName = "@extra_price", Value = extra_price, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@notes", Value = notes, });
var has = mySql.ExecuteFirst(sqlExist, paramLst.ToArray());
if (has != "0")
{
mySql.Close();
return "{\"code\":501,\"msg\":\"货号 " + ext_code + " 价格数据已存在\"}";
}
var rst = mySql.ExecuteNonQuery(sql, paramLst.ToArray());
mySql.Close();
if (rst)
{
return "{\"code\":200,\"msg\":\"success\"}";
}
else
{
return "{\"code\":502,\"msg\":\"" + mySql.Message + "\"}";
}
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string GetPriceList(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");
var password = RegexUtils.GetStringQuery(ref inputData, "password");
string start_original_price = RegexUtils.GetStringQuery(ref inputData, "start_original_price");
string end_original_price = RegexUtils.GetStringQuery(ref inputData, "end_original_price");
string start_markup_times = RegexUtils.GetStringQuery(ref inputData, "start_markup_times");
string end_markup_times = RegexUtils.GetStringQuery(ref inputData, "end_markup_times");
string start_extra_price = RegexUtils.GetStringQuery(ref inputData, "start_extra_price");
string end_extra_price = RegexUtils.GetStringQuery(ref inputData, "end_extra_price");
var search_ext_code = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "search_ext_code"));
var search_notes = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "search_notes"));
var in_ext_code = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "in_ext_code"));
int page = RegexUtils.GetStringQuery(ref inputData, "page").ParseToInt();
int page_size = RegexUtils.GetStringQuery(ref inputData, "page_size").ParseToInt(50);
if (string.IsNullOrEmpty(user_name))
{
return "{\"code\":500,\"msg\":\"没有用户名\"}";
}
List<MySqlParameter> paramLst = new List<MySqlParameter>();
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@search_ext_code", Value = "%" + search_ext_code + "%", });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@search_notes", Value = "%" + search_notes + "%", });
paramLst.Add(new MySqlParameter() { DbType = DbType.Int32, ParameterName = "@start_original_price", Value = start_original_price.ParseToInt(), });
paramLst.Add(new MySqlParameter() { DbType = DbType.Int32, ParameterName = "@end_original_price", Value = end_original_price.ParseToInt(), });
paramLst.Add(new MySqlParameter() { DbType = DbType.Int32, ParameterName = "@start_markup_times", Value = start_markup_times.ParseToInt(), });
paramLst.Add(new MySqlParameter() { DbType = DbType.Int32, ParameterName = "@end_markup_times", Value = end_markup_times.ParseToInt(), });
paramLst.Add(new MySqlParameter() { DbType = DbType.Int32, ParameterName = "@start_extra_price", Value = start_extra_price.ParseToInt(), });
paramLst.Add(new MySqlParameter() { DbType = DbType.Int32, ParameterName = "@end_extra_price", Value = end_extra_price.ParseToInt(), });
//paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@in_ext_code", Value = "'" + in_ext_code?.Replace(",", "','") + "'", });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@in_ext_code", Value = in_ext_code.ParseToString() });
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "select count(id) from bxx.price_markup p where 1=1";
string where = "";
if (!string.IsNullOrWhiteSpace(search_ext_code))
where += " and p.ext_code like @search_ext_code";
if (!string.IsNullOrWhiteSpace(search_notes))
where += " and p.notes like @search_notes";
if (!string.IsNullOrWhiteSpace(start_original_price))
where += " and p.original_price >= @start_original_price";
if (!string.IsNullOrWhiteSpace(end_original_price))
where += " and p.original_price <= @end_original_price";
if (!string.IsNullOrWhiteSpace(start_markup_times))
where += " and p.markup_times >= @start_markup_times";
if (!string.IsNullOrWhiteSpace(end_markup_times))
where += " and p.markup_times <= @end_markup_times";
if (!string.IsNullOrWhiteSpace(start_extra_price))
where += " and p.extra_price >= @start_extra_price";
if (!string.IsNullOrWhiteSpace(end_extra_price))
where += " and p.extra_price <= @end_extra_price";
if (!string.IsNullOrEmpty(in_ext_code))
where += " and p.ext_code in ('" + in_ext_code?.Replace(",", "','") + "')";
sql += where;
var count = mySql.ExecuteRowCount(sql, paramLst.ToArray());
DataTable dt;
if (count == 0)
{
dt = new DataTable();
}
else
{
sql = "select * from bxx.price_markup 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, paramLst.ToArray());
}
mySql.Close();
if (dt != null)
{
try
{
List<DBPriceResultParam> priceList = new List<DBPriceResultParam>();
foreach (DataRow row in dt.Rows)
{
DBPriceResultParam price = new DBPriceResultParam
{
id = row["id"].ParseToInt(),
extra_price = row["extra_price"].ParseToInt(),
markup_times = row["markup_times"].ParseToInt(),
original_price = row["original_price"].ParseToInt(),
notes = row["notes"].ParseToString(),
ext_code = row["ext_code"].ParseToString(),
add_time = Convert.ToDateTime(row["add_time"]),
mdy_time = Convert.ToDateTime(row["mdy_time"]),
};
priceList.Add(price);
}
var data = JsonUtils.SerializeObjectToString(priceList);
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 DelDbPrice(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("'", "\\'");
if (string.IsNullOrEmpty(user_name))
{
return "{\"code\":500,\"msg\":\"没有用户名\"}";
}
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "delete from bxx.price_markup 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 MdyDBPrice(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\":\"校验失败\"}";
var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
var db_id = RegexUtils.GetStringQuery(ref inputData, "db_id");
string notes = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "notes"));
string ext_code = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "ext_code"));
string original_price = RegexUtils.GetStringQuery(ref inputData, "original_price");
string markup_times = RegexUtils.GetStringQuery(ref inputData, "markup_times");
string extra_price = RegexUtils.GetStringQuery(ref inputData, "extra_price");
if (string.IsNullOrEmpty(user_name))
{
return "{\"code\":500,\"msg\":\"没有用户名\"}";
}
List<MySqlParameter> paramLst = new List<MySqlParameter>();
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@ext_code", Value = ext_code, });
paramLst.Add(new MySqlParameter() { DbType = DbType.Int32, ParameterName = "@original_price", Value = original_price.ParseToInt(), });
paramLst.Add(new MySqlParameter() { DbType = DbType.Int32, ParameterName = "@markup_times", Value = markup_times.ParseToInt(), });
paramLst.Add(new MySqlParameter() { DbType = DbType.Int32, ParameterName = "@extra_price", Value = extra_price.ParseToInt(), });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@notes", Value = notes, });
paramLst.Add(new MySqlParameter() { DbType = DbType.Int32, ParameterName = "@db_id", Value = db_id, });
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sqlExist = "select count(ext_code) from bxx.price_markup where ext_code=@ext_code and id!=@db_id";
var has = mySql.ExecuteFirst(sqlExist, paramLst.ToArray());
if (has != "0")
{
mySql.Close();
return "{\"code\":501,\"msg\":\"货号 " + ext_code + " 价格数据已存在\"}";
}
string sql = "update bxx.price_markup set";
if (notes != null)
sql += " notes=@notes,";
if (ext_code != null)
sql += " ext_code=@ext_code,";
if (original_price != null)
sql += " original_price=@original_price,";
if (markup_times != null)
sql += " markup_times=@markup_times,";
if (extra_price != null)
sql += " extra_price=@extra_price,";
sql = sql.TrimEnd(',');
sql += " where id=@db_id;";
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 AddPurchasePrice(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 user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
if (string.IsNullOrEmpty(user_name))
{
return "{\"code\":500,\"msg\":\"没有用户名\"}";
}
string shop_id = RegexUtils.GetStringQuery(ref inputData, "shop_id");
string shop_name = RegexUtils.GetStringQuery(ref inputData, "shop_name");
string spu_id = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "spu_id")).ParseToString();
string skc_id = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "skc_id")).ParseToString();
string cat_id = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "cat_id")).ParseToString();
string cat_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "cat_name")).ParseToString();
string ext_code = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "ext_code")).ParseToString();
string product_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "product_name")).ParseToString();
string main_img = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "main_img")).ParseToString();
string discount = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "discount")).ParseToString();
string price_text = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "price_text")).ParseToString();
string sku_purchase_price_json = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sku_purchase_price_json")).ParseToString();
string notes = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "notes")).ParseToString();
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sqlExist = "select count(spu_id) from bxx.product_purchase_price where spu_id=@spu_id";
string sql = "insert into bxx.product_purchase_price " +
"(shop_id,shop_name,spu_id,skc_id,cat_id,cat_name,ext_code,product_name,main_img,discount,price_text,sku_purchase_price_json,notes) " +
"values (@shop_id,@shop_name,@spu_id,@skc_id,@cat_id,@cat_name,@ext_code,@product_name,@main_img,@discount,@price_text,@sku_purchase_price_json,@notes);";
List<MySqlParameter> paramLst = new List<MySqlParameter>();
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@shop_id", Value = shop_id, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@shop_name", Value = shop_name, });
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 = "@ext_code", Value = ext_code, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@product_name", Value = product_name, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@main_img", Value = main_img, });
paramLst.Add(new MySqlParameter() { DbType = DbType.Int32, ParameterName = "@discount", Value = discount.ParseToInt(), });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@price_text", Value = price_text, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@sku_purchase_price_json", Value = sku_purchase_price_json, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@notes", Value = notes, });
var has = mySql.ExecuteFirst(sqlExist, paramLst.ToArray());
if (has != "0")
{
mySql.Close();
return "{\"code\":501,\"msg\":\"货号 " + ext_code + " 价格数据已存在\"}";
}
var rst = mySql.ExecuteNonQuery(sql, paramLst.ToArray());
mySql.Close();
if (rst)
{
return "{\"code\":200,\"msg\":\"success\"}";
}
else
{
return "{\"code\":502,\"msg\":\"" + mySql.Message + "\"}";
}
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string MdyPurchasePrice(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\":\"校验失败\"}";
var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
if (string.IsNullOrEmpty(user_name))
{
return "{\"code\":500,\"msg\":\"没有用户名\"}";
}
var db_id = RegexUtils.GetStringQuery(ref inputData, "db_id");
string shop_id = RegexUtils.GetStringQuery(ref inputData, "shop_id");
string shop_name = RegexUtils.GetStringQuery(ref inputData, "shop_name");
string cat_id = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "cat_id")).ParseToString();
string cat_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "cat_name")).ParseToString();
string ext_code = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "ext_code")).ParseToString();
string product_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "product_name")).ParseToString();
string main_img = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "main_img")).ParseToString();
string discount = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "discount")).ParseToString();
string price_text = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "price_text")).ParseToString();
string sku_purchase_price_json = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sku_purchase_price_json")).ParseToString();
string notes = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "notes")).ParseToString();
List<MySqlParameter> paramLst = new List<MySqlParameter>();
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@db_id", Value = db_id, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@shop_id", Value = shop_id, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@shop_name", Value = shop_name, });
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 = "@ext_code", Value = ext_code, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@product_name", Value = product_name, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@main_img", Value = main_img, });
paramLst.Add(new MySqlParameter() { DbType = DbType.Int32, ParameterName = "@discount", Value = discount.ParseToInt(), });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@price_text", Value = price_text, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@sku_purchase_price_json", Value = sku_purchase_price_json, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@notes", Value = notes, });
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "update bxx.product_purchase_price set";
if (shop_id != null)
sql += " shop_id=@shop_id,";
if (shop_name != null)
sql += " shop_name=@shop_name,";
if (cat_id != null)
sql += " cat_id=@cat_id,";
if (cat_name != null)
sql += " cat_name=@cat_name,";
if (ext_code != null)
sql += " ext_code=@ext_code,";
if (product_name != null)
sql += " product_name=@product_name,";
if (main_img != null)
sql += " main_img=@main_img,";
if (discount != null)
sql += " discount=@discount,";
if (price_text != null)
sql += " price_text=@price_text,";
if (sku_purchase_price_json != null)
sql += " sku_purchase_price_json=@sku_purchase_price_json,";
if (notes != null)
sql += " notes=@notes,";
sql = sql.TrimEnd(',');
sql += " where id=@db_id;";
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 GetPurchasePriceList(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");
var password = RegexUtils.GetStringQuery(ref inputData, "password");
var search_spu_id = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "search_spu_id"));
var search_skc_id = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "search_skc_id"));
var search_ext_code = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "search_ext_code"));
var search_notes = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "search_notes"));
var in_spu_id = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "in_spu_id"));
int page = RegexUtils.GetStringQuery(ref inputData, "page").ParseToInt();
int page_size = RegexUtils.GetStringQuery(ref inputData, "page_size").ParseToInt(50);
if (string.IsNullOrEmpty(user_name))
{
return "{\"code\":500,\"msg\":\"没有用户名\"}";
}
List<MySqlParameter> paramLst = new List<MySqlParameter>();
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@search_spu_id", Value = "%" + search_spu_id + "%", });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@search_skc_id", Value = "%" + search_skc_id + "%", });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@search_ext_code", Value = "%" + search_ext_code + "%", });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@search_notes", Value = "%" + search_notes + "%", });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@in_spu_id", Value = in_spu_id.ParseToString() });
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "select count(id) from bxx.product_purchase_price p where 1=1";
string where = "";
if (!string.IsNullOrWhiteSpace(search_spu_id))
where += " and p.spu_id like @search_spu_id";
if (!string.IsNullOrWhiteSpace(search_skc_id))
where += " and p.skc_id like @search_skc_id";
if (!string.IsNullOrWhiteSpace(search_ext_code))
where += " and p.ext_code like @search_ext_code";
if (!string.IsNullOrWhiteSpace(search_notes))
where += " and p.notes like @search_notes";
if (!string.IsNullOrEmpty(in_spu_id))
where += " and p.spu_id in ('" + in_spu_id?.Replace(",", "','") + "')";
sql += where;
var count = mySql.ExecuteRowCount(sql, paramLst.ToArray());
DataTable dt;
if (count == 0)
{
dt = new DataTable();
}
else
{
sql = "select * from bxx.product_purchase_price 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, paramLst.ToArray());
}
mySql.Close();
if (dt != null)
{
try
{
List<ProductPurchasePriceResultParam> purchasePriceList = new List<ProductPurchasePriceResultParam>();
foreach (DataRow row in dt.Rows)
{
ProductPurchasePriceResultParam price = new ProductPurchasePriceResultParam
{
id = row["id"].ParseToInt(),
shop_id = row["shop_id"].ParseToString(),
shop_name = row["shop_name"].ParseToString(),
cat_id = row["cat_id"].ParseToString(),
cat_name = row["cat_name"].ParseToString(),
main_img = row["main_img"].ParseToString(),
discount = row["discount"].ParseToInt(),
price_text = row["price_text"].ParseToString(),
product_name = row["product_name"].ParseToString(),
skc_id = row["skc_id"].ParseToString(),
sku_purchase_price_json = row["sku_purchase_price_json"].ParseToString(),
spu_id = row["spu_id"].ParseToString(),
notes = row["notes"].ParseToString(),
ext_code = row["ext_code"].ParseToString(),
add_time = Convert.ToDateTime(row["add_time"]),
mdy_time = Convert.ToDateTime(row["mdy_time"]),
};
purchasePriceList.Add(price);
}
var data = JsonUtils.SerializeObjectToString(purchasePriceList);
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 DelPurchasePrice(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("'", "\\'");
if (string.IsNullOrEmpty(user_name))
{
return "{\"code\":500,\"msg\":\"没有用户名\"}";
}
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "delete from bxx.product_purchase_price 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 AddExtCodePrice(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 user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
string ext_code = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "ext_code")).ParseToString();
var ext_code_price = RegexUtils.GetStringQuery(ref inputData, "ext_code_price")?.ParseToInt();
if (string.IsNullOrEmpty(user_name))
{
return "{\"code\":500,\"msg\":\"没有用户名\"}";
}
if (string.IsNullOrEmpty(ext_code))
{
return "{\"code\":500,\"msg\":\"没有货号\"}";
}
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
List<MySqlParameter> paramLst = new List<MySqlParameter>();
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@ext_code", Value = ext_code, });
paramLst.Add(new MySqlParameter() { DbType = DbType.Int32, ParameterName = "@ext_code_price", Value = ext_code_price, });
string sql= "select count(ext_code) from bxx.ext_code_price where ext_code=@ext_code";
var count = mySql.ExecuteRowCount(sql, paramLst.ToArray());
if (count.ParseToInt() > 0)
{
sql = "update bxx.ext_code_price set ext_code_price=@ext_code_price where ext_code=@ext_code";
}
else
{
sql = "insert into bxx.ext_code_price (ext_code,ext_code_price) values (@ext_code,@ext_code_price);";
}
var rst = mySql.ExecuteNonQuery(sql, paramLst.ToArray());
mySql.Close();
if (rst)
{
return "{\"code\":200,\"msg\":\"success\"}";
}
else
{
return "{\"code\":502,\"msg\":\"" + mySql.Message + "\"}";
}
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string GetExtCodePriceList(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");
var password = RegexUtils.GetStringQuery(ref inputData, "password");
string start_ext_price = RegexUtils.GetStringQuery(ref inputData, "start_ext_price");
string end_ext_price = RegexUtils.GetStringQuery(ref inputData, "end_ext_price");
var search_ext_code = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "search_ext_code"));
var in_ext_code = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "in_ext_code"));
int page = RegexUtils.GetStringQuery(ref inputData, "page").ParseToInt();
int page_size = RegexUtils.GetStringQuery(ref inputData, "page_size").ParseToInt(50);
if (string.IsNullOrEmpty(user_name))
{
return "{\"code\":500,\"msg\":\"没有用户名\"}";
}
List<MySqlParameter> paramLst = new List<MySqlParameter>();
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@search_ext_code", Value = "%" + search_ext_code + "%", });
paramLst.Add(new MySqlParameter() { DbType = DbType.Int32, ParameterName = "@start_ext_price", Value = start_ext_price.ParseToInt(), });
paramLst.Add(new MySqlParameter() { DbType = DbType.Int32, ParameterName = "@end_ext_price", Value = end_ext_price.ParseToInt(), });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@in_ext_code", Value = in_ext_code.ParseToString() });
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "select count(id) from bxx.ext_code_price p where 1=1";
string where = "";
if (!string.IsNullOrWhiteSpace(search_ext_code))
where += " and p.ext_code like @search_ext_code";
if (!string.IsNullOrWhiteSpace(start_ext_price))
where += " and p.ext_code_price >= @start_ext_price";
if (!string.IsNullOrWhiteSpace(end_ext_price))
where += " and p.ext_code_price <= @end_ext_price";
if (!string.IsNullOrEmpty(in_ext_code))
where += " and p.ext_code in ('" + in_ext_code?.Replace(",", "','") + "')";
sql += where;
var count = mySql.ExecuteRowCount(sql, paramLst.ToArray());
DataTable dt;
if (count == 0)
{
dt = new DataTable();
}
else
{
sql = "select * from bxx.ext_code_price 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, paramLst.ToArray());
}
mySql.Close();
if (dt != null)
{
try
{
List<DBExtCodePriceResult> priceList = new List<DBExtCodePriceResult>();
foreach (DataRow row in dt.Rows)
{
DBExtCodePriceResult price = new DBExtCodePriceResult
{
id = row["id"].ParseToInt(),
ext_code_price = row["ext_code_price"].ParseToInt(),
ext_code = row["ext_code"].ParseToString(),
add_time = Convert.ToDateTime(row["add_time"]),
mdy_time = Convert.ToDateTime(row["mdy_time"]),
};
priceList.Add(price);
}
var data = JsonUtils.SerializeObjectToString(priceList);
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 DelDbExtCodePrice(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("'", "\\'");
if (string.IsNullOrEmpty(user_name))
{
return "{\"code\":500,\"msg\":\"没有用户名\"}";
}
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "delete from bxx.ext_code_price 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 MdyDBExtCodePrice(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\":\"校验失败\"}";
var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
var db_id = RegexUtils.GetStringQuery(ref inputData, "db_id");
string ext_code = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "ext_code"));
string ext_code_price = RegexUtils.GetStringQuery(ref inputData, "original_price");
if (string.IsNullOrEmpty(user_name))
{
return "{\"code\":500,\"msg\":\"没有用户名\"}";
}
List<MySqlParameter> paramLst = new List<MySqlParameter>();
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@ext_code", Value = ext_code, });
paramLst.Add(new MySqlParameter() { DbType = DbType.Int32, ParameterName = "@ext_code_price", Value = ext_code_price.ParseToInt(), });
paramLst.Add(new MySqlParameter() { DbType = DbType.Int32, ParameterName = "@db_id", Value = db_id, });
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
//string sqlExist = "select count(ext_code) from bxx.ext_code_price where ext_code=@ext_code and id!=@db_id";
//var has = mySql.ExecuteFirst(sqlExist, paramLst.ToArray());
//if (has != "0")
//{
// mySql.Close();
// return "{\"code\":501,\"msg\":\"货号 " + ext_code + " 价格数据已存在\"}";
//}
string sql = "update bxx.ext_code_price set";
if (ext_code != null)
sql += " ext_code=@ext_code,";
if (ext_code_price != null)
sql += " ext_code_price=@ext_code_price,";
sql = sql.TrimEnd(',');
sql += " where id=@db_id;";
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\":\"输入为空\"}";
}
}
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,751 @@
using StoreHub.KJDWebService.Models;
using StoreHub.Framework.Repositorys;
using Microsoft.Extensions.Configuration;
using StoreHub.KJDWebService.Commons;
using MySql.Data.MySqlClient;
using NaiBa.Util.Extension;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text.RegularExpressions;
namespace StoreHub.KJDWebService.Services
{
public class BXXProductThirdService : ServiceBase
{
public BXXProductThirdService(SqlRepository sqlRepository, IConfiguration configuration) : base(sqlRepository, configuration)
{
}
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");
string from_shop_id = RegexUtils.GetStringQuery(ref inputData, "from_shop_id");
string spu_id = RegexUtils.GetStringQuery(ref inputData, "spu_id");
string skc_id = RegexUtils.GetStringQuery(ref inputData, "skc_id");
string cat_id = RegexUtils.GetStringQuery(ref inputData, "cat_id");
string cat_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "cat_name"));
string ext_code = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "ext_code"));
string product_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "product_name"));
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"));
string notes = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "notes"));
if (string.IsNullOrEmpty(user_name))
{
return "{\"code\":500,\"msg\":\"没有用户名\"}";
}
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "";
var json_ids = RegexUtils.GetMatchRegex(ref product_json, "(\"id\":\\d{8,14})"); // 取商品json数据里不同签名的部分
var product_json_replace = product_json;
foreach (Match json_id in json_ids)
{
product_json_replace = product_json_replace.Replace(json_id.Value, "\"id\":0");
}
var product_md5 = EncrypUtil.GetMd5(product_json_replace + size_json);
sql = "select id from bxx.third_product where product_md5='" + product_md5 + "';";
var rst = mySql.ExecuteFirstInt(sql).ParseToLong();
if (rst <= 0)
{
//sql = "insert into bxx.third_product (from_shop_id,spu_id,skc_id,cat_id,cat_name,product_name,ext_code,main_img,product_json,size_json,notes,product_md5,add_time,mdy_time) " +
// "values ('" + from_shop_id + "','" + spu_id + "','" + skc_id + "','" + cat_id + "','" + cat_name + "','" + product_name + "','" +
// ext_code + "','" + main_img + "','" + product_json + "','" + size_json + "','" + notes + "','" + product_md5 + "','" +
// DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','" +
// DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "');";
//rst = mySql.ExecuteInsertId(sql);
sql = "insert into bxx.third_product (from_shop_id,spu_id,skc_id,cat_id,cat_name,product_name," +
"ext_code,main_img,product_json,size_json,notes,product_md5,add_time,mdy_time) " +
"values (@from_shop_id,@spu_id,@skc_id,@cat_id,@cat_name,@product_name," +
"@ext_code,@main_img,@product_json,@size_json,@notes,@product_md5," +
"@add_time,@mdy_time);";
string add_time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
string mdy_time = add_time;
List<MySqlParameter> paramLst = new List<MySqlParameter>();
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@from_shop_id", Value = from_shop_id, });
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());
mySql.Close();
}
if (rst > 0)
{
return "{\"code\":200,\"msg\":\"success\",\"id\":" + rst + "}";
}
else
{
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}";
}
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string GetProductList(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 from_shop_id = RegexUtils.GetStringQuery(ref inputData, "from_shop_id")?.Replace("'", "\\'");
var search_spu = RegexUtils.GetStringQuery(ref inputData, "search_spu")?.Replace("'", "\\'");
var search_skc = RegexUtils.GetStringQuery(ref inputData, "search_skc")?.Replace("'", "\\'");
var search_cat = RegexUtils.GetStringQuery(ref inputData, "search_cat")?.Replace("'", "\\'");
var search_ext_code = RegexUtils.GetStringQuery(ref inputData, "search_ext_code")?.Replace("'", "\\'");
var search_prod_name = RegexUtils.GetStringQuery(ref inputData, "search_prod_name")?.Replace("'", "\\'");
var search_notes = RegexUtils.GetStringQuery(ref inputData, "search_notes")?.Replace("'", "\\'");
var search_db_ids = RegexUtils.GetStringQuery(ref inputData, "search_db_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(id) from bxx.third_product where 1=1";
string where = "";
if (!string.IsNullOrWhiteSpace(search_spu))
where += " and spu_id like '%" + search_spu + "%'";
if (!string.IsNullOrWhiteSpace(search_skc))
where += " and skc_id like '%" + search_skc + "%'";
if (!string.IsNullOrWhiteSpace(search_cat))
where += " and cat_name like '%" + search_cat + "%'";
if (!string.IsNullOrWhiteSpace(search_ext_code))
where += " and ext_code like '%" + search_ext_code + "%'";
if (!string.IsNullOrWhiteSpace(search_prod_name))
where += " and product_name like '%" + search_prod_name + "%'";
if (!string.IsNullOrWhiteSpace(search_notes))
where += " and notes like '%" + search_notes + "%'";
if (!string.IsNullOrEmpty(search_db_ids))
where += " and id in (" + search_db_ids + ")";
sql += where;
var count = mySql.ExecuteRowCount(sql);
DataTable dt;
if (count == 0)
{
dt = new DataTable();
}
else
{
if (isDetail)
sql = "select * from bxx.third_product where 1=1";
else
sql = "select id,from_shop_id,spu_id,skc_id,cat_id,cat_name,change_cat_id,change_cat_name,ext_code,product_name,main_img,notes," +
"add_time,mdy_time from bxx.third_product where 1=1";
sql += where;
sql += " order by id desc";
sql += " limit " + Math.Max(page - 1, 0) * page_size + "," + page_size;
dt = mySql.ExecuteDataTable(sql);
}
mySql.Close();
if (dt != null)
{
try
{
List<DBProductResultParam> productLst = new List<DBProductResultParam>();
foreach (DataRow row in dt.Rows)
{
DBProductResultParam prod = new DBProductResultParam
{
id = Convert.ToInt32(row["id"]),
from_shop_id = row["from_shop_id"].ToString(),
skc_id = row["skc_id"].ToString(),
spu_id = row["spu_id"].ToString(),
cat_id = row["cat_id"].ToString(),
cat_name = row["cat_name"].ToString(),
change_cat_id = row["change_cat_id"].ToString(),
change_cat_name = row["change_cat_name"].ToString(),
product_name = row["product_name"].ToString(),
main_img = row["main_img"].ToString(),
ext_code = row["ext_code"].ToString(),
//product_json = row["product_json"].ToString(),
//size_json = row["size_json"].ToString(),
add_time = Convert.ToDateTime(row["add_time"]),
mdy_time = Convert.ToDateTime(row["mdy_time"]),
notes = row["notes"].ToString(),
};
if (isDetail)
{
prod.product_json = row["product_json"].ToString();
prod.size_json = row["size_json"].ToString();
}
productLst.Add(prod);
}
var data = JsonUtils.SerializeObjectToString(productLst);
return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"count\":" + count + "}";
}
catch (Exception ex)
{
return "{\"code\":500,\"msg\":\"" + ex.Message + "\",\"data\":[],\"count\":" + 0 + "}";
}
}
else
{
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\",\"data\":[],\"count\":" + 0 + "}";
}
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string 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("'", "\\'");
var id = RegexUtils.GetStringQuery(ref inputData, "db_id")?.Replace("'", "\\'");
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "delete from bxx.third_product 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 MdyProductCategory(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\":\"校验失败\"}";
var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name")?.Replace("'", "\\'");
var id = RegexUtils.GetStringQuery(ref inputData, "db_id")?.Replace("'", "\\'");
string change_cat_id = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "change_cat_id"))?.Replace("'", "\\'");
string change_cat_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "change_cat_name"))?.Replace("'", "\\'");
if (string.IsNullOrEmpty(user_name))
{
return "{\"code\":500,\"msg\":\"没有用户名\"}";
}
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "update bxx.third_product set";
if (change_cat_id != null)
sql += " change_cat_id='" + change_cat_id + "',";
if (change_cat_name != null)
sql += " change_cat_name='" + change_cat_name + "',";
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 AddUserSelectProduct(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\":\"校验失败\"}";
var out_product_Id = RegexUtils.GetStringQuery(ref inputData, "out_product_id")?.Replace("'", "\\'");
var shop_id = RegexUtils.GetStringQuery(ref inputData, "shop_id")?.Replace("'", "\\'");
var shop_account = RegexUtils.GetStringQuery(ref inputData, "shop_account")?.Replace("'", "\\'");
var user_name = RegexUtils.GetStringQuery(ref inputData, "main_user_name")?.Replace("'", "\\'");
var sub_user_name = RegexUtils.GetStringQuery(ref inputData, "sub_user_name")?.Replace("'", "\\'");
var notes = RegexUtils.GetStringQuery(ref inputData, "notes")?.Replace("'", "\\'");
var status = RegexUtils.GetStringQuery(ref inputData, "status")?.Replace("'", "\\'");
var add_product_remaining = RegexUtils.GetStringQuery(ref inputData, "add_product_remaining").ParseToInt();
if (string.IsNullOrEmpty(user_name))
{
return "{\"code\":500,\"msg\":\"没有用户名\"}";
}
if (string.IsNullOrEmpty(shop_id))
{
return "{\"code\":500,\"msg\":\"没有店铺信息\"}";
}
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "insert into bxx.third_product_select (out_product_Id,shop_id,shop_account,user_name,sub_user_name,notes,status,add_time,mdy_time) " +
"values ('" + out_product_Id + "','" + shop_id + "','" + shop_account + "','" + user_name + "','" + sub_user_name + "','" +
notes + "','" + status + "','" +
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','" +
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "');";
if (add_product_remaining > 0)
{
add_product_remaining = add_product_remaining - 1;
sql += "\r\n";
sql += "update bxx.shop set add_product_remaining=" + add_product_remaining + " where shop_id='" + shop_id + "';";
//sql += "update bxx.shop_add_prod_count set add_product_remaining=" + add_product_remaining + " where shop_id=" + shop_id + ";";
sql += "INSERT INTO bxx.shop_add_prod_count(shop_id, add_product_remaining) VALUES('" + shop_id + "'," + add_product_remaining + ")" +
"ON DUPLICATE KEY UPDATE add_product_remaining=VALUES(add_product_remaining)";
}
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 MdyUserSelectProductStatus(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\":\"校验失败\"}";
var id = RegexUtils.GetStringQuery(ref inputData, "db_id")?.Replace("'", "\\'");
var draft_id = RegexUtils.GetStringQuery(ref inputData, "draft_id")?.Replace("'", "\\'");
var up_spu_id = RegexUtils.GetStringQuery(ref inputData, "up_spu_id")?.Replace("'", "\\'");
var shop_id = RegexUtils.GetStringQuery(ref inputData, "shop_id")?.Replace("'", "\\'");
var status = RegexUtils.GetStringQuery(ref inputData, "status")?.Replace("'", "\\'");
var add_times = RegexUtils.GetStringQuery(ref inputData, "add_times")?.Replace("'", "\\'");
long l_draft_id = draft_id.ParseToLong();
long l_spu_map_table_id = l_draft_id % 128;
long l_select_map_table_id = id.ParseToLong() % 64;
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "";
// 使用事务一次提交多个sql操作
//sql += "set @@autocommit=0;\r\n";
sql += "START TRANSACTION;\r\n";
if (!string.IsNullOrEmpty(up_spu_id) && !string.IsNullOrEmpty(draft_id))
{
sql += "insert into kjd_map.spu_map_" + l_spu_map_table_id +
" (draft_id,from_spu_id,shop_id) values(" + draft_id + "," + up_spu_id + ",'" + shop_id + "');\r\n";
sql += "insert into kjd_map.product_third_select_map_" + l_select_map_table_id +
" (product_id,product_select_db_id,shop_id) values(" + draft_id + "," + id + ",'" + shop_id + "');\r\n";
}
sql += "update bxx.third_product_select set";
if (draft_id != null)
sql += " draft_id='" + draft_id + "',";
if (status != null)
sql += " status='" + status + "',";
if (status == "已上传")
sql += " add_times=add_times+1,";
sql += " mdy_time='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',";
sql = sql.TrimEnd(',');
sql += " where id=" + id + ";\r\n";
var rst = mySql.ExecuteNonQuery(sql);
string errMsg = mySql.Message;
if (string.IsNullOrEmpty(errMsg))
sql = "COMMIT;";
else
sql = "ROLLBACK;";
mySql.ExecuteNonQuery(sql);
mySql.Close();
if (rst)
{
return "{\"code\":200,\"msg\":\"success\"}";
}
else
{
return "{\"code\":500,\"msg\":\"" + errMsg + "\"}";
}
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string GetUserSelectProductList(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\":\"校验失败\"}";
var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name")?.Replace("'", "\\'");
if (string.IsNullOrEmpty(user_name))
{
return "{\"code\":500,\"msg\":\"没有用户名\"}";
}
var shop_ids = RegexUtils.GetStringQuery(ref inputData, "shop_ids")?.Replace("'", "\\'");
var search_shop_id = RegexUtils.GetStringQuery(ref inputData, "search_shop_id")?.Replace("'", "\\'");
var search_shop_account = RegexUtils.GetStringQuery(ref inputData, "search_shop_account");
var search_spu = RegexUtils.GetStringQuery(ref inputData, "search_spu")?.Replace("'", "\\'");
var search_skc = RegexUtils.GetStringQuery(ref inputData, "search_skc")?.Replace("'", "\\'");
var search_cat = RegexUtils.GetStringQuery(ref inputData, "search_cat")?.Replace("'", "\\'");
var search_ext_code = RegexUtils.GetStringQuery(ref inputData, "search_ext_code")?.Replace("'", "\\'");
var search_prod_name = RegexUtils.GetStringQuery(ref inputData, "search_prod_name");
var search_notes = RegexUtils.GetStringQuery(ref inputData, "search_notes")?.Replace("'", "\\'");
var search_user_notes = RegexUtils.GetStringQuery(ref inputData, "search_user_notes")?.Replace("'", "\\'");
var search_db_ids = RegexUtils.GetStringQuery(ref inputData, "search_db_ids")?.Replace("'", "\\'");
var search_sub_sa_name = RegexUtils.GetStringQuery(ref inputData, "search_sub_sa_name")?.Replace("'", "\\'");
var status = RegexUtils.GetStringQuery(ref inputData, "status")?.Replace("'", "\\'");
var operate_sub_sa_name = RegexUtils.GetStringQuery(ref inputData, "operate_sub_sa_name")?.Replace("'", "\\'");
var no_sub_sa = RegexUtils.GetStringQuery(ref inputData, "no_sub_sa")?.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(s.id) from bxx.third_product_select s " +
"left join bxx.third_product p on s.out_product_id=p.id " +
"left join bxx.user u on s.operate_sub_sa_name=u.user_name " +
"where 1=1";
string where = "";
if (!isAdmin)
where += " and (s.user_name='" + user_name + "' or s.sub_user_name like'%" + user_name + "%')";
if (!string.IsNullOrEmpty(operate_sub_sa_name))
{
where += " and s.operate_sub_sa_name = '" + operate_sub_sa_name + "'";
}
if (no_sub_sa == "true")
where += " and s.operate_sub_sa_name is null";
if (!string.IsNullOrEmpty(search_db_ids))
where += " and s.id in (" + search_db_ids + ")";
if (!string.IsNullOrEmpty(shop_ids))
where += " and s.shop_id in (" + shop_ids + ")";
if (!string.IsNullOrWhiteSpace(status))
where += " and s.status = '" + status + "'";
if (!string.IsNullOrWhiteSpace(search_shop_id))
where += " and s.shop_id like '%" + search_shop_id + "%'";
if (!string.IsNullOrWhiteSpace(search_shop_account))
where += " and s.shop_account like @search_shop_account";
if (!string.IsNullOrWhiteSpace(search_notes))
{
//核价成功 重复 核价成功(重复)
if (search_notes == "无备注")
where += " and s.notes = ''";
else if (search_notes == "重复")
where += " and s.notes like '%重复%' and s.notes not like '%核价成功%' and s.notes not like '%核价通过%'";
else if (search_notes == "核价成功")
where += " and (s.notes like '%核价成功%' or s.notes like '%核价通过%') and s.notes not like '%重复%'";
else if (search_notes == "核价成功(重复)")
where += " and (s.notes like '%核价成功%' or s.notes like '%核价通过%') and s.notes like '%重复%'";
else
where += " and s.notes like '%" + search_notes + "%'";
}
if (!string.IsNullOrWhiteSpace(search_user_notes))
where += " and s.user_notes like '%" + search_user_notes + "%'";
if (!string.IsNullOrWhiteSpace(search_spu))
where += " and p.spu_id like '%" + search_spu + "%'";
if (!string.IsNullOrWhiteSpace(search_skc))
where += " and p.skc_id like '%" + search_skc + "%'";
if (!string.IsNullOrWhiteSpace(search_cat))
where += " and p.cat_name like '%" + search_cat + "%'";
if (!string.IsNullOrWhiteSpace(search_ext_code))
where += " and p.ext_code like '%" + search_ext_code + "%'";
if (!string.IsNullOrWhiteSpace(search_prod_name))
where += " and p.product_name like @search_prod_name";
if (!string.IsNullOrEmpty(search_sub_sa_name))
{
where += " and (s.operate_sub_sa_name like '%" + search_sub_sa_name + "%'";
where += " or u.nick_name like '%" + operate_sub_sa_name + "%')";
}
sql += where;
List<MySqlParameter> paramLst = new List<MySqlParameter>();
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@search_shop_account", Value = "%" + search_shop_account + "%", });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@search_prod_name", Value = "%" + search_prod_name + "%", });
var count = mySql.ExecuteRowCount(sql, paramLst.ToArray());
DataTable dt;
if (count == 0)
{
dt = new DataTable();
}
else
{
//if (isDetail)
//sql = "select * from bxx.third_product_select where 1=1";
//else
sql = "select s.id,s.out_product_id,s.shop_id,s.shop_account,s.user_name," +
"s.sub_user_name,s.notes,s.user_notes,s.status,s.draft_id,s.add_times,s.add_time,s.mdy_time," +
"s.fission_product_name,s.operate_sub_sa_name,s.add_sub_sa_time," +
"p.from_shop_id,p.spu_id,p.skc_id,p.cat_id,p.cat_name,p.change_cat_id,p.change_cat_name,p.ext_code,p.product_name,p.main_img," +
"u.nick_name as operate_sub_sa_nick " +
"from bxx.third_product_select s left join bxx.third_product p on s.out_product_id=p.id " +
"left join bxx.user u on u.user_name=s.operate_sub_sa_name " +
"where 1=1";
sql += where; // where子句
sql += " order by id desc";
sql += " limit " + Math.Max(page - 1, 0) * page_size + "," + page_size;
dt = mySql.ExecuteDataTable(sql, paramLst.ToArray());
}
mySql.Close();
if (dt != null)
{
try
{
List<ProductSelectResultParam> productLst = new List<ProductSelectResultParam>();
foreach (DataRow row in dt.Rows)
{
ProductSelectResultParam prodSelect = new ProductSelectResultParam()
{
id = row["id"].ParseToInt(),
out_product_Id = row["out_product_Id"].ParseToString(),
shop_account = row["shop_account"].ParseToString(),
shop_id = row["shop_id"].ParseToString(),
status = row["status"].ParseToString(),
sub_user_name = row["sub_user_name"].ParseToString(),
user_name = row["user_name"].ParseToString(),
cat_id = row["cat_id"].ParseToString(),
cat_name = row["cat_name"].ParseToString(),
change_cat_id = row["change_cat_id"].ParseToString(),
change_cat_name = row["change_cat_name"].ParseToString(),
product_name = row["product_name"].ParseToString(),
main_img = row["main_img"].ParseToString(),
ext_code = row["ext_code"].ParseToString(),
add_time = Convert.ToDateTime(row["add_time"]),
mdy_time = Convert.ToDateTime(row["mdy_time"]),
notes = row["notes"].ParseToString(),
draft_id = row["draft_id"].ParseToString(),
add_times = row["add_times"].ParseToInt(),
skc_id = row["skc_id"].ToString(),
spu_id = row["spu_id"].ToString(),
operate_sub_sa_name = row["operate_sub_sa_name"].ToString(),
operate_sub_sa_nick = row["operate_sub_sa_nick"].ToString(),
fission_product_name = row["fission_product_name"].ToString(),
user_notes = row["user_notes"].ToString(),
from_shop_id = row["from_shop_id"].ToString(),
//product_json = row["product_json"].ToString(),
//size_json = row["size_json"].ToString(),
};
prodSelect.add_sub_sa_time = row["add_sub_sa_time"] as DateTime?;
productLst.Add(prodSelect);
}
var data = JsonUtils.SerializeObjectToString(productLst);
return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"count\":" + count + "}";
}
catch (Exception ex)
{
return "{\"code\":500,\"msg\":\"" + ex.Message + "\",\"data\":[],\"count\":" + 0 + "}";
}
}
else
{
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\",\"data\":[],\"count\":" + 0 + "}";
}
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string DelSelectProd(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("'", "\\'");
if (string.IsNullOrEmpty(user_name))
{
return "{\"code\":500,\"msg\":\"没有用户名\"}";
}
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "delete from bxx.third_product_select 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>
/// <returns></returns>
public string SetSelectProductSubSa(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 id = RegexUtils.GetStringQuery(ref inputData, "db_id")?.Replace("'", "\\'");
var shop_id = RegexUtils.GetStringQuery(ref inputData, "shop_id")?.Replace("'", "\\'");
var operate_sub_sa_name = RegexUtils.GetStringQuery(ref inputData, "operate_sub_sa_name")?.Replace("'", "\\'");
var status = RegexUtils.GetStringQuery(ref inputData, "status")?.Replace("'", "\\'");
if (string.IsNullOrEmpty(id) && string.IsNullOrEmpty(shop_id))
{
return "{\"code\":50002,\"msg\":\"未选择任何待上传\"}";
}
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "update bxx.third_product_select set";
if (operate_sub_sa_name != null)
sql += " operate_sub_sa_name='" + operate_sub_sa_name + "',";
sql += " add_sub_sa_time='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',";
sql = sql.TrimEnd(',');
if (!string.IsNullOrEmpty(id))
sql += " where id in (" + id + ")";
else if (!string.IsNullOrEmpty(shop_id))
sql += " where shop_id in ('" + shop_id.Replace(",","','") + "')";
else
sql += " where 1=2";
if(!string.IsNullOrEmpty(status))
sql += " and status='" + status + "';";
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 MdyProductSelectNotes(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\":\"校验失败\"}";
var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
var id = RegexUtils.GetStringQuery(ref inputData, "db_id");
string notes = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "notes"));
string user_notes = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "user_notes"));
string fission_product_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "fission_product_name"));
if (string.IsNullOrEmpty(user_name))
{
return "{\"code\":500,\"msg\":\"没有用户名\"}";
}
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "update bxx.third_product_select set";
if (notes != null)
sql += " notes=@notes,";
if (user_notes != null)
sql += " user_notes=@user_notes,";
if (fission_product_name != null)
sql += " fission_product_name=@fission_product_name,";
sql = sql.TrimEnd(',');
sql += " where id=@id;";
List<MySqlParameter> paramLst = new List<MySqlParameter>();
paramLst.Add(new MySqlParameter() { DbType = DbType.Int32, ParameterName = "@id", Value = id, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@fission_product_name", Value = fission_product_name, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@user_notes", Value = user_notes, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@notes", Value = notes, });
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\":\"输入为空\"}";
}
}
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,894 @@
using StoreHub.KJDWebService.Services;
using StoreHub.Framework.Repositorys;
using Microsoft.Extensions.Configuration;
using StoreHub.KJDWebService.Models;
using StoreHub.KJDWebService.Models.PddModel;
using StoreHub.KJDWebService.Models.ShopModel;
using StoreHub.KJDWebService.Commons;
using NaiBa.Util.Extension;
using NaiBa.Util.Helper;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Net;
using System.Reflection;
namespace StoreHub.KJDWebService.Services
{
public class BXXUserService : ServiceBase
{
public BXXUserService(SqlRepository sqlRepository, IConfiguration configuration) : base(sqlRepository, configuration)
{
}
public string CheckUserLogin(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
if (!WXUserService.GetSign(inputData, true))
return "{\"code\":999,\"msg\":\"校验失败\"}";
var mobile = RegexUtils.GetStringQuery(ref inputData, "mobile")?.Replace("'", "\\'");
var password = RegexUtils.GetStringQuery(ref inputData, "password")?.Replace("'", "\\'");
var r2 = RegexUtils.GetStringQuery(ref inputData, "r2").ParseToInt();
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "select * from bxx.user where user_name='"
+ mobile + "' and password='" + password + "'";
var dt = mySql.ExecuteDataTable(sql);
if (!string.IsNullOrEmpty(mySql.Message))
{
mySql.Close();
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}";
}
if (dt == null)
dt = new DataTable();
foreach (DataRow row in dt.Rows)
{
UserLoginResultParam user = new UserLoginResultParam
{
id = Convert.ToInt32(row["id"]),
user_name = row["user_name"].ToString(),
nick_name = row["nick_name"].ToString(),
mobile = row["user_name"].ToString(),
password = row["password"].ToString(),
group_id = row["group_id"].ToString(),
card_id = row["card_id"].ToString(),
company_name = row["company_name"].ToString(),
is_sa = row.Table.Columns.Contains("is_sa") ? row["is_sa"].ParseToInt() : 0,
sa_level = row.Table.Columns.Contains("sa_level") ? row["sa_level"].ParseToInt() : 0,
authority = row["authority"].ToString(),
forbidden_page = row["forbidden_page"].ToString(),
parent_user_name = row["parent_user_name"].ToString(),
};
if (string.IsNullOrEmpty(user.company_name))
{
user.company_name = "-";
}
if (user.group_id != "3" && !string.IsNullOrEmpty(user.parent_user_name))
{
sql = "select authority from bxx.user where user_name='" + user.parent_user_name + "'";
var rst = mySql.ExecuteFirst(sql);
if (mySql.Message.IsNullOrEmpty())
{
user.parent_authority = rst;
}
}
var data = JsonUtils.SerializeObjectToString(user);
mySql.Close();
return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"c\":\"" + EncrypUtil.Encryption(r2) + "\"}";
}
mySql.Close();
return "{\"code\":1,\"msg\":\"用户名或密码错误\"}";
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string AddSubUser(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
if (!WXUserService.GetSign(inputData))
return "{\"code\":999,\"msg\":\"校验失败\"}";
var parent_user_name = RegexUtils.GetStringQuery(ref inputData, "user_name")?.Replace("'", "\\'");
var nick_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sub_nick_name"))?.Replace("'", "\\'");
var user_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sub_name"))?.Replace("'", "\\'");
var mobile = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sub_mobile"))?.Replace("'", "\\'");
var password = RegexUtils.GetStringQuery(ref inputData, "sub_password")?.Replace("'", "\\'");
var group_id = RegexUtils.GetStringQuery(ref inputData, "group_id")?.Replace("'", "\\'");
var card_id = RegexUtils.GetStringQuery(ref inputData, "card_id")?.Replace("'", "\\'");
var company_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "company"))?.Replace("'", "\\'");
var notes = RegexUtils.GetStringQuery(ref inputData, "notes")?.Replace("'", "\\'");
var authority = RegexUtils.GetStringQuery(ref inputData, "authority")?.Replace("'", "\\'");
var forbidden_page = RegexUtils.GetStringQuery(ref inputData, "forbidden_page")?.Replace("'", "\\'");
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "";
sql = "select exists (select 1 from bxx.user where user_name='" + user_name + "')";
var exist = mySql.ExecuteFirstInt(sql);
if (exist > 0)
{
mySql.Close();
return "{\"code\":500,\"msg\":\"用户名已存在\"}";
}
sql = "insert into bxx.user (nick_name,user_name,mobile,password,card_id,group_id,company_name,notes,parent_user_name,authority,forbidden_page,add_time,mdy_time) " +
"values ('" + nick_name + "','" + user_name + "','" + mobile + "','" + password + "','" + card_id + "','" +
group_id + "','" + company_name + "','" + notes + "','" + parent_user_name + "','" + authority + "','" + forbidden_page + "','" +
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','" +
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "');";
var rst = mySql.ExecuteNonQuery(sql);
mySql.Close();
if (!rst)
return "{\"code\":501,\"msg\":\""+ mySql.Message + "\"}";
else
return "{\"code\":200,\"msg\":\"子账户创建成功!\"}";
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string GetSubUser(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
if (!WXUserService.GetSign(inputData))
return "{\"code\":999,\"msg\":\"校验失败\"}";
var r2 = RegexUtils.GetStringQuery(ref inputData, "r2").ParseToInt();
var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
var password = RegexUtils.GetStringQuery(ref inputData, "password");
var group = RegexUtils.GetStringQuery(ref inputData, "group");
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "select * from bxx.user where parent_user_name='"
+ user_name + "'";
var dt = mySql.ExecuteDataTable(sql);
mySql.Close();
if (dt != null)
{
List<UserLoginResultParam> userList = new List<UserLoginResultParam>();
foreach (DataRow row in dt.Rows)
{
UserLoginResultParam user = new UserLoginResultParam
{
id = Convert.ToInt32(row["id"]),
user_name = row["user_name"].ToString(),
nick_name = row["nick_name"].ToString(),
mobile = row["mobile"].ToString(),
password = row["password"].ToString(),
group_id = row["group_id"].ToString(),
card_id = row["card_id"].ToString(),
parent_user_name = row["parent_user_name"].ToString(),
company_name = row["company_name"].ToString(),
notes = row["notes"].ToString(),
authority = row.Table.Columns.Contains("authority") ? row["authority"].ParseToString() : "",
forbidden_page = row.Table.Columns.Contains("forbidden_page") ? row["forbidden_page"].ParseToString() : "",
};
if (string.IsNullOrEmpty(user.mobile))
{
user.mobile = row["user_name"].ToString();
}
userList.Add(user);
}
var data = JsonUtils.SerializeObjectToString(userList);
return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"c\":\"" + EncrypUtil.Encryption(r2) + "\"}";
}
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string UpdateSubUser(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
if (!WXUserService.GetSign(inputData))
return "{\"code\":999,\"msg\":\"校验失败\"}";
var id = RegexUtils.GetStringQuery(ref inputData, "id")?.Replace("'", "\\'");
var parent_user_name = RegexUtils.GetStringQuery(ref inputData, "user_name")?.Replace("'", "\\'");
var nick_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sub_nick_name"))?.Replace("'", "\\'");
var user_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sub_name"))?.Replace("'", "\\'");
var mobile = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sub_mobile"))?.Replace("'", "\\'");
var password = RegexUtils.GetStringQuery(ref inputData, "sub_password")?.Replace("'", "\\'");
var group_id = RegexUtils.GetStringQuery(ref inputData, "group_id")?.Replace("'", "\\'");
var card_id = RegexUtils.GetStringQuery(ref inputData, "card_id")?.Replace("'", "\\'");
var notes = RegexUtils.GetStringQuery(ref inputData, "notes")?.Replace("'", "\\'");
var authority = RegexUtils.GetStringQuery(ref inputData, "authority")?.Replace("'", "\\'");
var forbidden_page = RegexUtils.GetStringQuery(ref inputData, "forbidden_page")?.Replace("'", "\\'");
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "";
//sql = "select * from bxx.user where parent_user_name='"
// + user_name + "'";
sql = "update bxx.user set";
if (!string.IsNullOrEmpty(nick_name))
sql += " nick_name='" + nick_name + "',";
if (!string.IsNullOrEmpty(user_name))
sql += " user_name='" + user_name + "',";
if (!string.IsNullOrEmpty(mobile))
sql += " mobile='" + mobile + "',";
if (!string.IsNullOrEmpty(password))
sql += " password='" + password + "',";
if (!string.IsNullOrEmpty(group_id))
sql += " group_id=" + group_id + ",";
if (!string.IsNullOrEmpty(card_id))
sql += " card_id='" + card_id + "',";
if (!string.IsNullOrEmpty(notes))
sql += " notes='" + notes + "',";
if (authority != null)
sql += " authority='" + authority + "',";
if (forbidden_page != null)
sql += " forbidden_page='" + forbidden_page + "',";
sql = sql.TrimEnd(',');
sql += " where id=" + id + "";
var rst = mySql.ExecuteNonQuery(sql);
mySql.Close();
if (rst)
{
return "{\"code\":200,\"msg\":\"success\"}";
}
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string DelUser(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
if (!WXUserService.GetSign(inputData))
return "{\"code\":999,\"msg\":\"校验失败\"}";
var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
var id = RegexUtils.GetStringQuery(ref inputData, "id");
if (string.IsNullOrWhiteSpace(id))
return "{\"code\":500,\"msg\":\"id不能为空\"}";
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "delete from bxx.user where id='"
+ id + "'";
var rst = mySql.ExecuteNonQuery(sql);
mySql.Close();
if (rst)
{
return "{\"code\":200,\"msg\":\"success\"}";
}
else
return "{\"code\":500,\"msg\":\"删除失败,请稍后重试\"}";
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string GetAllUser(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
if (!WXUserService.GetSign(inputData))
return "{\"code\":999,\"msg\":\"校验失败\"}";
var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name")?.Replace("'", "\\'");
var password = RegexUtils.GetStringQuery(ref inputData, "password")?.Replace("'", "\\'");
var group_id = RegexUtils.GetStringQuery(ref inputData, "group_id")?.Replace("'", "\\'");
var search = RegexUtils.GetStringQuery(ref inputData, "search")?.Replace("'", "\\'");
var sa_level = RegexUtils.GetStringQuery(ref inputData, "sa_level")?.Replace("'", "\\'");
var r2 = RegexUtils.GetStringQuery(ref inputData, "r2").ParseToInt();
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
//string sql = "select * from bxx.user where group_id=3";
string sql = "select * from bxx.user where 1=1";
if (!string.IsNullOrEmpty(group_id))
sql += " and group_id=" + group_id;
if (!string.IsNullOrEmpty(sa_level))
sql += " and sa_level=" + sa_level;
if (!string.IsNullOrEmpty(search))
sql += " and (user_name like '%" + search +
"%' or nick_name like '%" + search +
"%' or company_name like '%" + search + "%')";
sql += " order by id desc";
var dt = mySql.ExecuteDataTable(sql);
mySql.Close();
if (dt != null)
{
List<UserLoginResultParam> userList = new List<UserLoginResultParam>();
foreach (DataRow row in dt.Rows)
{
UserLoginResultParam user = new UserLoginResultParam
{
id = Convert.ToInt32(row["id"]),
user_name = row["user_name"].ToString(),
nick_name = row["nick_name"].ToString(),
mobile = row["mobile"].ToString(),
password = row["password"].ToString(),
group_id = row["group_id"].ToString(),
card_id = row["card_id"].ToString(),
parent_user_name = row["parent_user_name"].ToString(),
company_name = row["company_name"].ToString(),
notes = row["notes"].ToString(),
is_sa = row.Table.Columns.Contains("is_sa") ? row["is_sa"].ParseToInt() : 0,
sa_level = row.Table.Columns.Contains("sa_level") ? row["sa_level"].ParseToInt() : 0,
authority = row.Table.Columns.Contains("authority") ? row["authority"].ParseToString() : "",
forbidden_page = row.Table.Columns.Contains("forbidden_page") ? row["forbidden_page"].ParseToString() : "",
};
if (string.IsNullOrEmpty(user.mobile))
{
user.mobile = row["user_name"].ToString();
}
userList.Add(user);
}
var data = JsonUtils.SerializeObjectToString(userList);
return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"c\":\"" + EncrypUtil.Encryption(r2) + "\"}";
}
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string AddUser(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
if (!WXUserService.GetSign(inputData))
return "{\"code\":999,\"msg\":\"校验失败\"}";
var nick_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "add_nick_name"))?.Replace("'", "\\'");
var user_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "add_user_name"))?.Replace("'", "\\'");
var mobile = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "add_mobile"))?.Replace("'", "\\'");
var password = RegexUtils.GetStringQuery(ref inputData, "add_password")?.Replace("'", "\\'");
var company_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "add_company"))?.Replace("'", "\\'");
var group_id = RegexUtils.GetStringQuery(ref inputData, "group_id")?.Replace("'", "\\'"); ;
var card_id = RegexUtils.GetStringQuery(ref inputData, "card_id")?.Replace("'", "\\'");
var notes = RegexUtils.GetStringQuery(ref inputData, "notes")?.Replace("'", "\\'");
var sa_level = RegexUtils.GetStringQuery(ref inputData, "sa_level")?.Replace("'", "\\'");
var authority = RegexUtils.GetStringQuery(ref inputData, "authority")?.Replace("'", "\\'");
var forbidden_page = RegexUtils.GetStringQuery(ref inputData, "forbidden_page")?.Replace("'", "\\'");
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "";
sql = "select exists (select 1 from bxx.user where user_name='" + user_name + "')";
var exist = mySql.ExecuteFirstInt(sql);
if (exist > 0)
{
mySql.Close();
return "{\"code\":500,\"msg\":\"用户名已存在\"}";
}
sql = "insert into bxx.user (nick_name,user_name,mobile,password,card_id,group_id,company_name,notes,sa_level,authority,add_time,mdy_time,forbidden_page) " +
"values ('" + nick_name + "','" + user_name + "','" + mobile + "','" + password + "','" + card_id + "','" +
group_id + "','" + company_name + "','" + notes + "'," + sa_level + ",'" + authority + "','" + forbidden_page + "','" +
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','" +
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "');";
var rst = mySql.ExecuteNonQuery(sql);
mySql.Close();
if (!rst)
return "{\"code\":501,\"msg\":\"" + mySql.Message + "\"}";
else
return "{\"code\":200,\"msg\":\"success\"}";
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string UpdateUser(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
if (!WXUserService.GetSign(inputData))
return "{\"code\":999,\"msg\":\"校验失败\"}";
var id = RegexUtils.GetStringQuery(ref inputData, "id")?.Replace("'", "\\'");
var nick_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "add_nick_name"))?.Replace("'", "\\'");
var user_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "add_user_name"))?.Replace("'", "\\'");
var mobile = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "add_mobile"))?.Replace("'", "\\'");
var company_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "add_company"))?.Replace("'", "\\'");
var password = RegexUtils.GetStringQuery(ref inputData, "add_password")?.Replace("'", "\\'");
var group_id = RegexUtils.GetStringQuery(ref inputData, "group_id")?.Replace("'", "\\'");
var card_id = RegexUtils.GetStringQuery(ref inputData, "card_id")?.Replace("'", "\\'");
var notes = RegexUtils.GetStringQuery(ref inputData, "notes")?.Replace("'", "\\'");
var sa_level = RegexUtils.GetStringQuery(ref inputData, "sa_level")?.Replace("'", "\\'");
var authority = RegexUtils.GetStringQuery(ref inputData, "authority")?.Replace("'", "\\'");
var forbidden_page = RegexUtils.GetStringQuery(ref inputData, "forbidden_page")?.Replace("'", "\\'");
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "";
//sql = "select * from bxx.user where parent_user_name='"
// + user_name + "'";
sql = "update bxx.user set";
if (!string.IsNullOrEmpty(nick_name))
sql += " nick_name='" + nick_name + "',";
if (!string.IsNullOrEmpty(user_name))
sql += " user_name='" + user_name + "',";
if (!string.IsNullOrEmpty(mobile))
sql += " mobile='" + mobile + "',";
if (!string.IsNullOrEmpty(company_name))
sql += " company_name='" + company_name + "',";
if (!string.IsNullOrEmpty(password))
sql += " password='" + password + "',";
if (!string.IsNullOrEmpty(group_id))
sql += " group_id=" + group_id + ",";
if (!string.IsNullOrEmpty(card_id))
sql += " card_id='" + card_id + "',";
if (!string.IsNullOrEmpty(notes))
sql += " notes='" + notes + "',";
if (!string.IsNullOrEmpty(sa_level))
sql += " sa_level=" + sa_level + ",";
if (authority != null)
sql += " authority='" + authority + "',";
if (forbidden_page != null)
sql += " forbidden_page='" + forbidden_page + "',";
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 ChangePassword(string inputData)
{
var userName = RegexUtils.GetStringJson(ref inputData, "user_name")?.Replace("'", "\\'");
var password = RegexUtils.GetStringJson(ref inputData, "password")?.Replace("'", "\\'");
var newPassword = RegexUtils.GetStringJson(ref inputData, "new_password")?.Replace("'", "\\'");
string conn = "Conn";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "select user_id,password from pepdtp.user where user_id='"
+ userName + "' and password='" + password + "'";
var dw = mySql.ExecuteDataTableRow(sql);
if (dw != null)
{
UserLoginResultParam user = new UserLoginResultParam
{
user_name = dw["user_id"].ToString(),
password = dw["password"].ToString(),
};
sql = "update pepdtp.user set password = '" + newPassword + "' where user_id='" + userName + "'";
var result = mySql.ExecuteNonQuery(sql);
mySql.Close();
if (result)
{
return "{\"code\":0,\"msg\":\"密码修改成功!\"}";
}
else
return "{\"code\":19999,\"msg\":\"密码修改失败!请稍后再试。\"}";
}
else
{
mySql.Close();
return "{\"code\":1,\"msg\":\"原密码错误。\"}";
}
}
public string return_package_secret_key { get; set; } = "aaMETt2bPe6YHzZ1ojbC+6wOvgtwehqc6A+/Rz+pCUU=";
public string GetPackageSign(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
var mobile = RegexUtils.GetStringQuery(ref inputData, "mobile")?.Replace("'", "\\'");
var password = RegexUtils.GetStringQuery(ref inputData, "password")?.Replace("'", "\\'");
var timestamp = RegexUtils.GetStringQuery(ref inputData, "timestamp")?.Replace("'", "\\'");
var mallId = RegexUtils.GetStringQuery(ref inputData, "mallId")?.Replace("'", "\\'");
var returnPackageNo = RegexUtils.GetStringQuery(ref inputData, "returnPackageNo")?.Replace("'", "\\'");
int r2 = RegexUtils.GetStringQuery(ref inputData, "r2").ParseToInt();
string c2 = RegexUtils.GetStringQuery(ref inputData, "c2");
if (EncrypUtil.Encryption(r2) != c2)
return "{\"code\":2,\"msg\":\"不合法的输入内容\"}";
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "select * from bxx.user where user_name='"
+ mobile + "' and password='" + password + "'";
sql = "select * from bxx.user where user_name='" + mobile + "'";
var dt = mySql.ExecuteDataTable(sql);
mySql.Close();
if (dt == null || dt.Rows.Count <=0)
{
return "{\"code\":1,\"msg\":\"用户不存在\"}";
}
string sign = EncrypUtil.GetMd5(timestamp + return_package_secret_key + mallId + returnPackageNo).ToLower();
return "{\"code\":200, \"sign\":\"" + sign + "\", \"msg\":\"\"}";
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string UpdateScm121Cookie(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
var id = (RegexUtils.GetStringQuery(ref inputData, "db_id")?.Replace("'", "\\'")).ParseToInt();
if (id == 0)
id = 1;
var cookie = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "cookie"))?.Replace("'", "\\'");
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 conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "update bxx.scm121_user set cookie='" + cookie + "' WHERE id=" + id + ";";
var rst = mySql.ExecuteNonQuery(sql);
mySql.Close();
if (rst && string.IsNullOrEmpty(mySql.Message))
{
return "{\"code\":200,\"msg\":\"success\"}";
}
if (!string.IsNullOrEmpty(mySql.Message))
{
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}";
}
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string GetScm121Cookie(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
var id = (RegexUtils.GetStringQuery(ref inputData, "db_id")?.Replace("'", "\\'")).ParseToInt();
if (id == 0)
id = 1;
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 conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "select cookie from bxx.scm121_user WHERE id=" + id + ";";
var rst = mySql.ExecuteDataTableRow(sql);
mySql.Close();
if (string.IsNullOrEmpty(mySql.Message))
{
return "{\"code\":200,\"cookie\":" + rst["cookie"] + "}";
}
if (!string.IsNullOrEmpty(mySql.Message))
{
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}";
}
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string AddBuyer(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
string user_name = RegexUtils.GetStringQuery(ref inputData, "user_name")?.Replace("'", "\\'");
string buyer_id = RegexUtils.GetStringQuery(ref inputData, "buyer_id")?.Replace("'", "\\'");
string buyer_name = RegexUtils.GetStringQuery(ref inputData, "buyer_name")?.Replace("'", "\\'");
string buyer_nick = RegexUtils.GetStringQuery(ref inputData, "buyer_nick")?.Replace("'", "\\'");
string cookie = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "cookie"))?.Replace("'", "\\'");
string notes = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "notes"))?.Replace("'", "\\'");
int r2 = 0;
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
if (string.IsNullOrEmpty(user_name))
{
return "{\"code\":500,\"msg\":\"没有用户名\"}";
}
if (string.IsNullOrEmpty(buyer_name))
{
return "{\"code\":501,\"msg\":\"没有买手登录名\"}";
}
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "select exists (select 1 from bxx.shop where buyer_id='" + buyer_id + "' and user_name='" + user_name + "')";
var exist = mySql.ExecuteFirstInt(sql);
if (exist > 0)
{
mySql.Close();
return "{\"code\":500,\"msg\":\"买手" + buyer_name + " " + buyer_nick + "已存在\"}";
}
sql = "insert into bxx.buyer (user_name,buyer_id,buyer_name,buyer_nick,cookie,notes) " +
"values ('" + user_name + "','" + buyer_id + "','" + buyer_name + "','" + buyer_nick + "','" + cookie + "','" + notes + "');";
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 MdyBuyer(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
string user_name = RegexUtils.GetStringQuery(ref inputData, "user_name")?.Replace("'", "\\'");
string buyer_id = RegexUtils.GetStringQuery(ref inputData, "buyer_id")?.Replace("'", "\\'");
string buyer_name = RegexUtils.GetStringQuery(ref inputData, "buyer_name")?.Replace("'", "\\'"); ;
string buyer_nick = RegexUtils.GetStringQuery(ref inputData, "buyer_nick")?.Replace("'", "\\'"); ;
string cookie = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "cookie"))?.Replace("'", "\\'"); ;
string notes = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "notes"))?.Replace("'", "\\'");
string status = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "status"))?.Replace("'", "\\'");
int r2 = 0;
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
if (string.IsNullOrEmpty(user_name))
{
return "{\"code\":500,\"msg\":\"没有用户名\"}";
}
if (string.IsNullOrEmpty(buyer_id))
{
return "{\"code\":501,\"msg\":\"没有买手号\"}";
}
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "update bxx.buyer set";
if (buyer_name != null)
sql += " buyer_name='" + buyer_name + "',";
if (buyer_nick != null)
sql += " buyer_nick='" + buyer_nick + "',";
if (cookie != null)
sql += " cookie='" + cookie + "',";
if (notes != null)
sql += " notes='" + notes + "',";
if (status != null)
sql += " status='" + status + "',";
sql = sql.TrimEnd(',');
sql += " where buyer_id='" + buyer_id + "' and user_name='" + user_name + "'";
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 MdyBuyerCookie(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
string user_name = RegexUtils.GetStringQuery(ref inputData, "buyer_user_name")?.Replace("'", "\\'");
string buyer_id = RegexUtils.GetStringQuery(ref inputData, "buyer_id")?.Replace("'", "\\'");
string cookie = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "cookie"))?.Replace("'", "\\'");
string status = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "status"))?.Replace("'", "\\'");
int r2 = 0;
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
if (string.IsNullOrEmpty(buyer_id))
{
return "{\"code\":501,\"msg\":\"没有买手号\"}";
}
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "update bxx.buyer set";
if (cookie != null)
sql += " cookie='" + cookie + "',";
if (status != null)
sql += " status='" + status + "',";
sql = sql.TrimEnd(',');
sql += " where buyer_id='" + buyer_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 GetBuyer(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
var password = RegexUtils.GetStringQuery(ref inputData, "password");
if (string.IsNullOrEmpty(user_name))
{
return "{\"code\":500,\"msg\":\"没有用户名\"}";
}
var search_notes = RegexUtils.GetStringQuery(ref inputData, "search_notes");
var search_buyer_id = RegexUtils.GetStringQuery(ref inputData, "search_buyer_id");
var search_buyer_name = RegexUtils.GetStringQuery(ref inputData, "search_buyer_name");
var search_buyer_nick = RegexUtils.GetStringQuery(ref inputData, "search_buyer_nick");
var buyer_ids = RegexUtils.GetStringQuery(ref inputData, "buyer_ids")?.Replace("'", "");
if (!string.IsNullOrWhiteSpace(buyer_ids))
{
List<string> shopIdLst = buyer_ids.Split(',').ToList();
buyer_ids = "'" + string.Join("','", shopIdLst) + "'";
}
var buyer_names = RegexUtils.GetStringQuery(ref inputData, "buyer_names");
if (!string.IsNullOrWhiteSpace(buyer_names))
{
List<string> shopNameLst = buyer_names.Split(',').ToList();
buyer_names = "'" + string.Join("','", shopNameLst) + "'";
}
var buyer_nicks = RegexUtils.GetStringQuery(ref inputData, "buyer_nicks");
if (!string.IsNullOrWhiteSpace(buyer_nicks))
{
List<string> shopNotesLst = buyer_nicks.Split(',').ToList();
buyer_nicks = "'" + string.Join("','", shopNotesLst) + "'";
}
var page = RegexUtils.GetStringQuery(ref inputData, "page").ParseToInt();
var page_size = RegexUtils.GetStringQuery(ref inputData, "page_size").ParseToInt();
if (page_size == 0)
page_size = 50;
int r2 = 0;
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "SELECT COUNT(s.id) FROM bxx.buyer s WHERE 1=1";
//where子句
string where = "";
if (!string.IsNullOrWhiteSpace(search_notes))
where += " and s.notes like '%" + search_notes + "%'";
if (!string.IsNullOrWhiteSpace(search_buyer_id))
where += " and s.buyer_id like '%" + search_buyer_id + "%'";
if (!string.IsNullOrWhiteSpace(search_buyer_name))
where += " and s.buyer_name like '%" + search_buyer_name + "%'";
if (!string.IsNullOrWhiteSpace(search_buyer_nick))
where += " and s.buyer_nick like '%" + search_buyer_nick + "%'";
if (!string.IsNullOrWhiteSpace(buyer_ids))
where += " and s.buyer_id in (" + buyer_ids + ")";
if (!string.IsNullOrWhiteSpace(buyer_names))
where += " and s.buyer_name in (" + buyer_names + ")";
if (!string.IsNullOrWhiteSpace(buyer_nicks))
where += " and s.buyer_nick in (" + buyer_nicks + ")";
if (!string.IsNullOrWhiteSpace(user_name))
where += " and s.user_name='" + user_name + "'";
sql += where;
var count = mySql.ExecuteRowCount(sql);
DataTable dt;
if (count == 0)
{
dt = new DataTable();
}
else
{
sql = "SELECT s.*";
sql += " FROM bxx.buyer s WHERE 1=1";
sql += where; // where 子句
sql += " ORDER BY s.id DESC";
sql += " LIMIT " + Math.Max(page - 1, 0) * page_size + "," + page_size;
dt = mySql.ExecuteDataTable(sql);
}
mySql.Close();
if (dt != null)
{
List<BuyerLoginInfo> buyerList = new List<BuyerLoginInfo>();
foreach (DataRow row in dt.Rows)
{
BuyerLoginInfo shop = new BuyerLoginInfo
{
id = Convert.ToInt32(row["id"]),
cookie = row["cookie"].ToString(),
user_name = row["user_name"].ToString(),
notes = row["notes"].ToString(),
add_time = row["add_time"].ParseToString().ParseToDateTime(),
mdy_time = row["mdy_time"].ParseToString().ParseToDateTime(),
buyer_id = row["buyer_id"].ToString(),
buyer_name = row["buyer_name"].ToString(),
buyer_nick = row["buyer_nick"].ToString(),
status = row["status"].ToString(),
};
buyerList.Add(shop);
}
var data = JsonUtils.SerializeObjectToString(buyerList);
return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"count\":" + count + "}";
}
}
return "{\"code\":19999,\"msg\":\"未知错误\"}";
}
public string DelBuyer(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
var password = RegexUtils.GetStringQuery(ref inputData, "password");
if (string.IsNullOrEmpty(user_name))
{
return "{\"code\":500,\"msg\":\"没有用户名\"}";
}
var buyer_id = RegexUtils.GetStringQuery(ref inputData, "buyer_id");
if (string.IsNullOrEmpty(buyer_id))
{
return "{\"code\":500,\"msg\":\"没有买手号\"}";
}
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "DELETE FROM bxx.buyer WHERE user_name='" + user_name + "' and buyer_id='" + buyer_id + "'";
var rst = mySql.ExecuteNonQuery(sql);
mySql.Close();
if (rst)
{
return "{\"code\":200,\"msg\":\"success\"}";
}
else
{
return "{\"code\":501,\"msg\":" + mySql.Message + "}";
}
}
return "{\"code\":19999,\"msg\":\"未知错误\"}";
}
}
}
@@ -0,0 +1,788 @@
using StoreHub.KJDWebService.Models;
using StoreHub.Framework.Repositorys;
using Microsoft.Extensions.Configuration;
using StoreHub.KJDWebService.Models.ShopModel;
using StoreHub.KJDWebService.Commons;
using NaiBa.Util.Extension;
using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Linq;
namespace StoreHub.KJDWebService.Services
{
public class DYShopService : ServiceBase
{
public DYShopService(SqlRepository sqlRepository, IConfiguration configuration) : base(sqlRepository, configuration)
{
}
public string GetShop(string inputData, bool isAdmin = false)
{
if (!string.IsNullOrEmpty(inputData))
{
var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
var password = RegexUtils.GetStringQuery(ref inputData, "password");
var search_id = RegexUtils.GetStringQuery(ref inputData, "search_id");
var search_user_name = RegexUtils.GetStringQuery(ref inputData, "search_user_name");
var search_login_name = RegexUtils.GetStringQuery(ref inputData, "search_login_name");
var search_notes = RegexUtils.GetStringQuery(ref inputData, "search_notes");
var search_name = RegexUtils.GetStringQuery(ref inputData, "search_name");
var operate_sub_sa_name = RegexUtils.GetStringQuery(ref inputData, "operate_sub_sa_name")?.Replace("'", "\\'");
var shop_ids = RegexUtils.GetStringQuery(ref inputData, "shop_ids")?.Replace("'", "");
if (!string.IsNullOrWhiteSpace(shop_ids))
{
List<string> shopIdLst = shop_ids.Split(',').ToList();
shop_ids = "'" + string.Join("','", shopIdLst) + "'";
}
var shop_names = RegexUtils.GetStringQuery(ref inputData, "shop_names");
if (!string.IsNullOrWhiteSpace(shop_names))
{
List<string> shopNameLst = shop_names.Split(',').ToList();
shop_names = "'" + string.Join("','", shopNameLst) + "'";
}
var shop_notes = RegexUtils.GetStringQuery(ref inputData, "shop_notes");
if (!string.IsNullOrWhiteSpace(shop_notes))
{
List<string> shopNotesLst = shop_notes.Split(',').ToList();
shop_notes = "'" + string.Join("','", shopNotesLst) + "'";
}
var page = RegexUtils.GetStringQuery(ref inputData, "page").ParseToInt();
var page_size = RegexUtils.GetStringQuery(ref inputData, "page_size").ParseToInt();
if (page_size == 0)
page_size = 50;
int r2 = 0;
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "SELECT COUNT(s.id) FROM dyxd.shop s WHERE 1=1";
//where子句
string where = "";
if (isAdmin)
where += " and (s.cookie='' or s.shop_id!='')";
if (!isAdmin)
where += " and (s.user_name='" + user_name + "' or s.sub_user_name like '%" + user_name + "%')";
if (!string.IsNullOrWhiteSpace(operate_sub_sa_name))
where += " and s.operate_sub_sa_name='" + operate_sub_sa_name + "'";
if (!string.IsNullOrWhiteSpace(search_user_name))
where += " and s.user_name like '%" + search_user_name + "%'";
if (!string.IsNullOrWhiteSpace(search_login_name))
where += " and s.login_name like '%" + search_login_name + "%'";
if (!string.IsNullOrWhiteSpace(search_notes))
where += " and s.notes like '%" + search_notes + "%'";
if (!string.IsNullOrWhiteSpace(search_id))
where += " and s.shop_id like '%" + search_id + "%'";
if (!string.IsNullOrWhiteSpace(search_name))
where += " and s.shop_account like '%" + search_name + "%'";
if (!string.IsNullOrWhiteSpace(shop_ids))
where += " and s.shop_id in (" + shop_ids + ")";
if (!string.IsNullOrWhiteSpace(shop_names))
where += " and s.shop_account in (" + shop_names + ")";
if (!string.IsNullOrWhiteSpace(shop_notes))
where += " and s.notes in (" + shop_notes + ")";
sql += where;
var count = mySql.ExecuteRowCount(sql);
DataTable dt;
if (count == 0)
{
dt = new DataTable();
}
else
{
sql = "SELECT s.id,s.login_name,s.login_pass,s.cookie,s.cookie2,s.anti_contents,s.pddid,s.shop_id,s.shop_account,s.sub_user_name," +
"s.user_name,s.company_name,s.notes,s.login_status,s.login_status2,c.add_product_remaining,c.add_product_month," +
"s.add_time,s.mdy_time,s.add_sub_sa_time,s.operate_sub_sa_name";
//sql += " FROM dyxd.shop s WHERE 1=1";
sql += " FROM dyxd.shop s LEFT JOIN dyxd.shop_add_prod_count c ON s.shop_id=c.shop_id WHERE 1=1";
sql += where; // where 子句
sql += " ORDER BY s.id DESC";
sql += " LIMIT " + Math.Max(page - 1, 0) * page_size + "," + page_size;
dt = mySql.ExecuteDataTable(sql);
}
mySql.Close();
if (dt != null)
{
List<ShopParam> shopList=new List<ShopParam>();
foreach (DataRow row in dt.Rows)
{
ShopParam shop = new ShopParam
{
id = Convert.ToInt32(row["id"]),
login_name = row["login_name"].ToString(),
login_pass = row["login_pass"].ToString(),
cookie = row["cookie"].ToString(),
cookie2 = row["cookie2"].ToString(),
anti_contents = row["anti_contents"].ToString(),
shop_id = row["shop_id"].ToString(),
shop_account = row["shop_account"].ToString(),
sub_user_name = row["sub_user_name"].ToString(),
user_name = row["user_name"].ToString(),
company_name = row["company_name"].ToString(),
notes = row["notes"].ToString(),
login_status = row["login_status"].ToString(),
login_status2 = row["login_status2"].ToString(),
add_product_remaining = row["add_product_remaining"].ParseToInt(),
add_product_month = row["add_product_month"].ParseToInt(),
operate_sub_sa_name = row["operate_sub_sa_name"].ParseToString(),
pddid = row["pddid"].ParseToString(),
};
shopList.Add(shop);
}
//sql = "\r\nINSERT INTO dyxd.shop_add_prod_count(shop_id,shop_account,add_product_remaining,add_product_month) VALUES ";
//foreach (var shop in shopList)
//{
// sql += "\r\n('" + shop.shop_id + "','" + shop.shop_account + "'," + shop.add_product_remaining + "," + shop.add_product_month + "),";
//}
//sql = sql.TrimEnd(',') + " \r\n";
//sql += "ON DUPLICATE KEY UPDATE " +
// "shop_account=VALUES(shop_account)," +
// "add_product_remaining=VALUES(add_product_remaining)," +
// "add_product_month=VALUES(add_product_month);";
//var result = mySql.ExecuteNonQuery(sql);
//mySql.Close();
int month = DateTime.Now.Month;
var shopMonthList = shopList.Where(s => s.add_product_month != month);
if (shopMonthList.Count() > 0)
{
int remainCount = 300;
var shopMonthIdList = shopMonthList.Select(s => s.id);
mySql = new MysqlUtils(conn);
string ids = string.Join(",", shopMonthIdList);
sql = "";
sql += "update dyxd.shop set add_product_remaining=" + remainCount + ", add_product_month=" + month +
" where 1=1 and id in (" + ids + ");";
sql += "\r\nINSERT INTO dyxd.shop_add_prod_count(shop_id,shop_account,add_product_remaining,add_product_month) VALUES ";
foreach (var shop in shopMonthList)
{
sql+= "\r\n('" + shop.shop_id + "','" + shop.shop_account + "'," + remainCount + "," + month + "),";
}
sql = sql.TrimEnd(',') + " \r\n";
sql += "ON DUPLICATE KEY UPDATE " +
"shop_account=VALUES(shop_account)," +
"add_product_remaining=VALUES(add_product_remaining)," +
"add_product_month=VALUES(add_product_month);";
var rst = mySql.ExecuteNonQuery(sql);
mySql.Close();
if (rst)
{
foreach (var shop in shopMonthList)
{
shop.add_product_month = month;
shop.add_product_remaining = remainCount;
}
}
}
var data = JsonUtils.SerializeObjectToString(shopList);
//return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"c\":\"" + EncrypUtil.Encryption(r2) + "\"}";
return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"count\":" + count + "}";
}
}
return "{\"code\":19999,\"msg\":\"未知错误\"}";
}
public string SubSaGetSelectProdShop(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
var password = RegexUtils.GetStringQuery(ref inputData, "password");
var search_id = RegexUtils.GetStringQuery(ref inputData, "search_id");
var search_user_name = RegexUtils.GetStringQuery(ref inputData, "search_user_name");
var search_login_name = RegexUtils.GetStringQuery(ref inputData, "search_login_name");
var search_notes = RegexUtils.GetStringQuery(ref inputData, "search_notes");
var search_name = RegexUtils.GetStringQuery(ref inputData, "search_name");
var operate_sub_sa_name = RegexUtils.GetStringQuery(ref inputData, "operate_sub_sa_name")?.Replace("'", "\\'");
var shop_ids = RegexUtils.GetStringQuery(ref inputData, "shop_ids")?.Replace("'", "");
if (!string.IsNullOrWhiteSpace(shop_ids))
{
List<string> shopIdLst = shop_ids.Split(',').ToList();
shop_ids = "'" + string.Join("','", shopIdLst) + "'";
}
var shop_names = RegexUtils.GetStringQuery(ref inputData, "shop_names");
if (!string.IsNullOrWhiteSpace(shop_names))
{
List<string> shopNameLst = shop_names.Split(',').ToList();
shop_names = "'" + string.Join("','", shopNameLst) + "'";
}
var shop_notes = RegexUtils.GetStringQuery(ref inputData, "shop_notes");
if (!string.IsNullOrWhiteSpace(shop_notes))
{
List<string> shopNotesLst = shop_notes.Split(',').ToList();
shop_notes = "'" + string.Join("','", shopNotesLst) + "'";
}
var page = RegexUtils.GetStringQuery(ref inputData, "page").ParseToInt();
var page_size = RegexUtils.GetStringQuery(ref inputData, "page_size").ParseToInt();
if (page_size == 0)
page_size = 50;
int r2 = 0;
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "SELECT COUNT(s.id) FROM dyxd.shop s WHERE 1=1";
//where子句
string where = "";
if (!string.IsNullOrWhiteSpace(operate_sub_sa_name))
where += " and (s.shop_id in (SELECT DISTINCT shop_id From dyxd.product_select WHERE operate_sub_sa_name='" + operate_sub_sa_name + "') or " +
"s.shop_id in (SELECT DISTINCT shop_id From dyxd.third_product_select WHERE operate_sub_sa_name='" + operate_sub_sa_name + "'))";
where += " and (s.cookie='' or s.shop_id!='')";
//if (!string.IsNullOrWhiteSpace(operate_sub_sa_name))
// where += " and s.operate_sub_sa_name='" + operate_sub_sa_name + "'";
if (!string.IsNullOrWhiteSpace(search_user_name))
where += " and s.user_name like '%" + search_user_name + "%'";
if (!string.IsNullOrWhiteSpace(search_login_name))
where += " and s.login_name like '%" + search_login_name + "%'";
if (!string.IsNullOrWhiteSpace(search_notes))
where += " and s.notes like '%" + search_notes + "%'";
if (!string.IsNullOrWhiteSpace(search_id))
where += " and s.shop_id like '%" + search_id + "%'";
if (!string.IsNullOrWhiteSpace(search_name))
where += " and s.shop_account like '%" + search_name + "%'";
if (!string.IsNullOrWhiteSpace(shop_ids))
where += " and s.shop_id in (" + shop_ids + ")";
if (!string.IsNullOrWhiteSpace(shop_names))
where += " and s.shop_account in (" + shop_names + ")";
if (!string.IsNullOrWhiteSpace(shop_notes))
where += " and s.notes in (" + shop_notes + ")";
sql += where;
var count = mySql.ExecuteRowCount(sql);
DataTable dt;
if (count == 0)
{
dt = new DataTable();
}
else
{
sql = "SELECT s.id,s.login_name,s.login_pass,s.cookie,s.cookie2,s.anti_contents,s.shop_id,s.shop_account,s.sub_user_name,s.user_name," +
"s.company_name,s.notes,s.login_status,s.login_status2,c.add_product_remaining,c.add_product_month,s.add_time,s.mdy_time," +
"s.add_sub_sa_time,s.operate_sub_sa_name";
sql += " FROM dyxd.shop s LEFT JOIN dyxd.shop_add_prod_count c ON s.shop_id=c.shop_id WHERE 1=1";
sql += where; // where 子句
sql += " ORDER BY s.id DESC";
sql += " LIMIT " + Math.Max(page - 1, 0) * page_size + "," + page_size;
dt = mySql.ExecuteDataTable(sql);
}
mySql.Close();
if (dt != null)
{
List<ShopParam> shopList = new List<ShopParam>();
foreach (DataRow row in dt.Rows)
{
ShopParam shop = new ShopParam
{
id = Convert.ToInt32(row["id"]),
login_name = row["login_name"].ToString(),
login_pass = row["login_pass"].ToString(),
cookie = row["cookie"].ToString(),
cookie2 = row["cookie2"].ToString(),
anti_contents = row["anti_contents"].ToString(),
shop_id = row["shop_id"].ToString(),
shop_account = row["shop_account"].ToString(),
sub_user_name = row["sub_user_name"].ToString(),
user_name = row["user_name"].ToString(),
company_name = row["company_name"].ToString(),
notes = row["notes"].ToString(),
login_status = row["login_status"].ToString(),
login_status2 = row["login_status2"].ToString(),
add_product_remaining = row["add_product_remaining"].ParseToInt(),
add_product_month = row["add_product_month"].ParseToInt(),
operate_sub_sa_name = row["operate_sub_sa_name"].ParseToString(),
};
shopList.Add(shop);
}
//sql = "\r\nINSERT INTO dyxd.shop_add_prod_count(shop_id,shop_account,add_product_remaining,add_product_month) VALUES ";
//foreach (var shop in shopList)
//{
// sql += "\r\n('" + shop.shop_id + "','" + shop.shop_account + "'," + shop.add_product_remaining + "," + shop.add_product_month + "),";
//}
//sql = sql.TrimEnd(',') + " \r\n";
//sql += "ON DUPLICATE KEY UPDATE " +
// "shop_account=VALUES(shop_account)," +
// "add_product_remaining=VALUES(add_product_remaining)," +
// "add_product_month=VALUES(add_product_month);";
//var result = mySql.ExecuteNonQuery(sql);
//mySql.Close();
int month = DateTime.Now.Month;
var shopMonthList = shopList.Where(s => s.add_product_month != month);
if (shopMonthList.Count() > 0)
{
int remainCount = 300;
var shopMonthIdList = shopMonthList.Select(s => s.id);
mySql = new MysqlUtils(conn);
string ids = string.Join(",", shopMonthIdList);
sql = "";
sql += "update dyxd.shop set add_product_remaining=" + remainCount + ", add_product_month=" + month +
" where 1=1 and id in (" + ids + ");";
sql += "\r\nINSERT INTO dyxd.shop_add_prod_count(shop_id,shop_account,add_product_remaining,add_product_month) VALUES ";
foreach (var shop in shopMonthList)
{
sql += "\r\n('" + shop.shop_id + "','" + shop.shop_account + "'," + remainCount + "," + month + "),";
}
sql = sql.TrimEnd(',') + " \r\n";
sql += "ON DUPLICATE KEY UPDATE " +
"shop_account=VALUES(shop_account)," +
"add_product_remaining=VALUES(add_product_remaining)," +
"add_product_month=VALUES(add_product_month);";
var rst = mySql.ExecuteNonQuery(sql);
mySql.Close();
if (rst)
{
foreach (var shop in shopMonthList)
{
shop.add_product_month = month;
shop.add_product_remaining = remainCount;
}
}
}
var data = JsonUtils.SerializeObjectToString(shopList);
//return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"c\":\"" + EncrypUtil.Encryption(r2) + "\"}";
return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"count\":" + count + "}";
}
}
return "{\"code\":19999,\"msg\":\"未知错误\"}";
}
public string UpdateAddProdRemaining(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");
var password = RegexUtils.GetStringQuery(ref inputData, "password");
var remainCount = RegexUtils.GetStringQuery(ref inputData, "remain_count");
var shop_ids = RegexUtils.GetStringQuery(ref inputData, "shop_ids")?.Replace("'", "");
if (!string.IsNullOrWhiteSpace(shop_ids))
{
List<string> shopIdLst = shop_ids.Split(',').ToList();
shop_ids = "'" + string.Join("','", shopIdLst) + "'";
}
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "";
sql += "update dyxd.shop_add_prod_count set add_product_remaining=" + remainCount +
" where 1=1 and shop_id in (" + shop_ids + ");";
var rst = mySql.ExecuteNonQuery(sql);
var msg = mySql.Message;
mySql.Close();
if (rst)
return "{\"code\":200,\"msg\":\"success\"}";
else
return "{\"code\":50000,\"msg\":\"" + msg + "\"}";
}
else
{
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
}
//获取一个手机登录号码下的所有店铺(以便有则更新,无则新增)
public string GetOneLoginNameShop(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
var login_name = RegexUtils.GetStringQuery(ref inputData, "login_name");
var password = RegexUtils.GetStringQuery(ref inputData, "password");
int r2 = 0;
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "select id,login_name,login_pass,cookie,cookie2,anti_contents,shop_id,shop_account,sub_user_name,user_name from dyxd.shop where user_name='"
+ user_name + "' and login_name='" + login_name + "'";
var dt = mySql.ExecuteDataTable(sql);
mySql.Close();
if (dt != null)
{
List<ShopParam> shopList = new List<ShopParam>();
foreach (DataRow row in dt.Rows)
{
ShopParam shop = new ShopParam
{
id = Convert.ToInt32(row["id"]),
login_name = row["login_name"].ToString(),
login_pass = row["login_pass"].ToString(),
cookie = row["cookie"].ToString(),
cookie2 = row["cookie2"].ToString(),
anti_contents = row["anti_contents"].ToString(),
shop_id = row["shop_id"].ToString(),
shop_account = row["shop_account"].ToString(),
sub_user_name = row["sub_user_name"].ToString(),
user_name = row["user_name"].ToString(),
company_name = row["company_name"].ToString(),
notes = row["notes"].ToString(),
login_status = row["login_status"].ToString(),
};
shopList.Add(shop);
}
var data = JsonUtils.SerializeObjectToString(shopList);
return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"c\":\"" + EncrypUtil.Encryption(r2) + "\"}";
}
}
return "{\"code\":19999,\"msg\":\"未知错误\"}";
}
//获取一个手机登录号码下特定ID的店铺
public string GetOneIdShop(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
var login_name = RegexUtils.GetStringQuery(ref inputData, "login_name");
var shop_id = RegexUtils.GetStringQuery(ref inputData, "shop_id");
var password = RegexUtils.GetStringQuery(ref inputData, "password");
int r2 = 0;
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "select id,login_name,login_pass,cookie,cookie2,anti_contents,shop_id,shop_account,sub_user_name,user_name from dyxd.shop where user_name='"
+ user_name + "' and login_name='" + login_name + "' and shop_id='" + shop_id + "'";
var dt = mySql.ExecuteDataTable(sql);
mySql.Close();
if (dt != null)
{
List<ShopParam> shopList = new List<ShopParam>();
foreach (DataRow row in dt.Rows)
{
ShopParam shop = new ShopParam
{
id = Convert.ToInt32(row["id"]),
login_name = row["login_name"].ToString(),
login_pass = row["login_pass"].ToString(),
cookie = row["cookie"].ToString(),
cookie2 = row["cookie2"].ToString(),
anti_contents = row["anti_contents"].ToString(),
shop_id = row["shop_id"].ToString(),
shop_account = row["shop_account"].ToString(),
sub_user_name = row["sub_user_name"].ToString(),
user_name = row["user_name"].ToString(),
company_name = row["company_name"].ToString(),
notes = row["notes"].ToString(),
login_status = row["login_status"].ToString(),
};
shopList.Add(shop);
}
var data = JsonUtils.SerializeObjectToString(shopList);
return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"c\":\"" + EncrypUtil.Encryption(r2) + "\"}";
}
}
return "{\"code\":19999,\"msg\":\"未知错误\"}";
}
public string AddShop(string inputData, bool isAdmin=false)
{
if (!string.IsNullOrEmpty(inputData))
{
string user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
if (isAdmin)
user_name = RegexUtils.GetStringQuery(ref inputData, "shop_user_name");
string login_name = RegexUtils.GetStringQuery(ref inputData, "login_name");
string login_pass = RegexUtils.GetStringQuery(ref inputData, "login_pass");
string sub_user_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sub_user_name"));
string cookie = RegexUtils.GetStringQuery(ref inputData, "cookie");
string cookie2 = RegexUtils.GetStringQuery(ref inputData, "cookie2");
string anti_contents = RegexUtils.GetStringQuery(ref inputData, "anti_contents");
string shop_id = RegexUtils.GetStringQuery(ref inputData, "shop_id");
string shop_account = RegexUtils.GetStringQuery(ref inputData, "shop_account");
string group_name = RegexUtils.GetStringQuery(ref inputData, "group_name");
string notes = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "notes"));
int r2 = 0;
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
if (string.IsNullOrEmpty(user_name))
{
return "{\"code\":500,\"msg\":\"没有用户名\"}";
}
if (string.IsNullOrEmpty(login_name))
{
return "{\"code\":501,\"msg\":\"没有店铺登录名\"}";
}
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "";
if (string.IsNullOrEmpty(shop_id))
sql = "select exists (select 1 from dyxd.shop where login_name='" + login_name + "' and user_name='" + user_name + "')";
else
sql = "select exists (select 1 from dyxd.shop where login_name='" + login_name + "' and user_name='" + user_name +
"' and shop_id='" + shop_id + "')";
var exist = mySql.ExecuteFirstInt(sql);
if (exist>0)
{
mySql.Close();
return "{\"code\":500,\"msg\":\"店铺" + login_name +" " + shop_account + "已存在\"}";
}
sql = "insert into dyxd.shop (login_name,login_pass,cookie,cookie2,anti_contents,shop_account,shop_id,sub_user_name,user_name,group_name,notes,add_time,mdy_time) " +
"values ('" + login_name + "','" + login_pass + "','" + cookie + "','" + cookie2 + "','" + anti_contents + "','" + shop_account + "','" + shop_id + "','" +
sub_user_name + "','" + user_name + "','" + group_name + "','" + notes + "','" +
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','" +
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "');";
var rst = mySql.ExecuteNonQuery(sql);
mySql.Close();
if (rst)
{
return "{\"code\":200,\"msg\":\"success\"}";
}
}
return "{\"code\":19999,\"msg\":\"未知错误\"}";
}
public string MdyShop(string inputData, bool isAdmin=false)
{
if (!string.IsNullOrEmpty(inputData))
{
string user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
if (isAdmin)
user_name = RegexUtils.GetStringQuery(ref inputData, "shop_user_name");
string login_name = RegexUtils.GetStringQuery(ref inputData, "login_name");
string login_pass = RegexUtils.GetStringQuery(ref inputData, "login_pass");
string sub_user_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sub_user_name"));
string cookie = RegexUtils.GetStringQuery(ref inputData, "cookie");
string cookie2 = RegexUtils.GetStringQuery(ref inputData, "cookie2");
string anti_contents = RegexUtils.GetStringQuery(ref inputData, "anti_contents");
string new_shop_id = RegexUtils.GetStringQuery(ref inputData, "new_shop_id");
string old_shop_id = RegexUtils.GetStringQuery(ref inputData, "shop_id");
string shop_account = RegexUtils.GetStringQuery(ref inputData, "shop_account");
string group_name = RegexUtils.GetStringQuery(ref inputData, "group_name");
string notes = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "notes"));
string login_status = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "login_status"));
int r2 = 0;
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
if (string.IsNullOrEmpty(user_name))
{
return "{\"code\":500,\"msg\":\"没有用户名\"}";
}
if (string.IsNullOrEmpty(login_name))
{
return "{\"code\":501,\"msg\":\"没有店铺登录名\"}";
}
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "update dyxd.shop set";
if (login_pass != null)
sql += " login_pass='" + login_pass + "',";
if (cookie != null)
sql += " cookie='" + cookie + "',";
if (cookie2 != null)
sql += " cookie2='" + cookie2 + "',";
if (anti_contents != null)
sql += " anti_contents='" + anti_contents + "',";
if (new_shop_id != null)
sql += " shop_id='" + new_shop_id + "',";
if (shop_account != null)
sql += " shop_account='" + shop_account + "',";
if (sub_user_name != null)
sql += " sub_user_name='" + sub_user_name + "',";
if (group_name != null)
sql += " group_name='" + group_name + "',";
if (notes != null)
sql += " notes='" + notes + "',";
if (login_status != null)
sql += " login_status='" + login_status + "',";
sql = sql.TrimEnd(',');
sql += " where login_name='" + login_name + "' and (user_name='" + user_name + "' or sub_user_name like '%" + user_name + "%')";
if (!string.IsNullOrEmpty(old_shop_id))
sql += " and shop_id='" + old_shop_id + "'";
var rst = mySql.ExecuteNonQuery(sql);
mySql.Close();
if (rst)
{
return "{\"code\":200,\"msg\":\"success\"}";
}
}
return "{\"code\":19999,\"msg\":\"未知错误\"}";
}
public string MdyCookieAndLoginStatus(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
string login_name = RegexUtils.GetStringQuery(ref inputData, "login_name");
string cookie = RegexUtils.GetStringQuery(ref inputData, "cookie");
string cookie2 = RegexUtils.GetStringQuery(ref inputData, "cookie2");
string login_status = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "login_status"));
string login_status2 = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "login_status2"));
string pddid = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "pddid"));
int r2 = 0;
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
if (string.IsNullOrEmpty(login_name))
{
return "{\"code\":500,\"msg\":\"店铺没有登录名\"}";
}
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "update dyxd.shop set";
if (cookie != null)
sql += " cookie='" + cookie + "',";
if (cookie2 != null)
sql += " cookie2='" + cookie2 + "',";
if (login_status != null)
sql += " login_status='" + login_status + "',";
if (login_status2 != null)
sql += " login_status2='" + login_status2 + "',";
if (pddid != null)
sql += " pddid='" + pddid + "',";
sql = sql.TrimEnd(',');
sql += " where login_name='" + login_name + "'";
var rst = mySql.ExecuteNonQuery(sql);
mySql.Close();
if (rst)
{
return "{\"code\":200,\"msg\":\"success\"}";
}
}
return "{\"code\":19999,\"msg\":\"未知错误\"}";
}
public string DelShop(string inputData, bool isAdmin=false)
{
if (!string.IsNullOrEmpty(inputData))
{
var login_name = RegexUtils.GetStringQuery(ref inputData, "login_name");
var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
if (isAdmin)
user_name = RegexUtils.GetStringQuery(ref inputData, "shop_user_name");
var shop_id = RegexUtils.GetStringQuery(ref inputData, "shop_id");
var password = RegexUtils.GetStringQuery(ref inputData, "password");
int r2 = 0;
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
if (string.IsNullOrEmpty(user_name))
{
return "{\"code\":500,\"msg\":\"没有用户名\"}";
}
if (string.IsNullOrEmpty(login_name))
{
return "{\"code\":501,\"msg\":\"没有店铺登录名\"}";
}
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "delete from dyxd.shop where user_name='" + user_name + "' and login_name='" + login_name + "'";
if (!string.IsNullOrEmpty(shop_id))
sql += " and shop_id='" + shop_id + "'";
var rst = mySql.ExecuteNonQuery(sql);
mySql.Close();
if (rst)
{
return "{\"code\":200,\"msg\":\"success\"}";
}
}
return "{\"code\":19999,\"msg\":\"未知错误\"}";
}
/// <summary>
/// 设置店铺的二级超管
/// </summary>
/// <returns></returns>
public string SetShopSubSa(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 id = RegexUtils.GetStringQuery(ref inputData, "db_id")?.Replace("'", "\\'");
var login_name = RegexUtils.GetStringQuery(ref inputData, "shop_login_name")?.Replace("'", "\\'");
var operate_sub_sa_name = RegexUtils.GetStringQuery(ref inputData, "operate_sub_sa_name")?.Replace("'", "\\'");
if (string.IsNullOrEmpty(id) && string.IsNullOrEmpty(login_name))
{
return "{\"code\":50002,\"msg\":\"未选择任何待上传\"}";
}
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "update dyxd.shop set";
if (operate_sub_sa_name != null)
sql += " operate_sub_sa_name='" + operate_sub_sa_name + "',";
sql += " add_sub_sa_time='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',";
sql = sql.TrimEnd(',');
if (!string.IsNullOrEmpty(id))
sql += " where id in (" + id + ")";
else if (!string.IsNullOrEmpty(login_name))
sql += " where login_name in ('" + login_name.Replace(",", "','") + "')";
else
sql += " where 1=2";
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\":\"输入为空\"}";
}
}
}
@@ -0,0 +1,481 @@
using StoreHub.KJDWebService.Models;
using StoreHub.Framework.Repositorys;
using Microsoft.Extensions.Configuration;
using StoreHub.KJDWebService.Commons;
using NaiBa.Util.Extension;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Net;
using System.Reflection;
namespace StoreHub.KJDWebService.Services
{
public class DYUserService : ServiceBase
{
public DYUserService(SqlRepository sqlRepository, IConfiguration configuration) : base(sqlRepository, configuration)
{
}
public string CheckUserLogin(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
var mobile = RegexUtils.GetStringQuery(ref inputData, "mobile")?.Replace("'", "\\'");
var password = RegexUtils.GetStringQuery(ref inputData, "password")?.Replace("'", "\\'");
var version = RegexUtils.GetStringQuery(ref inputData, "version").ParseToInt();
if (version < (System.Configuration.ConfigurationManager.ConnectionStrings["LimitVersion"]?.ConnectionString).ParseToInt())
return "{\"code\":1,\"msg\":\"当前版本过于陈旧,请立即升级新版\"}";
int r2 = 0;
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "select * from dyxd.user where user_name='"
+ mobile + "' and password='" + password + "'";
var dt = mySql.ExecuteDataTable(sql);
mySql.Close();
if (dt != null)
{
foreach (DataRow row in dt.Rows)
{
UserLoginResultParam user = new UserLoginResultParam
{
id = Convert.ToInt32(row["id"]),
user_name = row["user_name"].ToString(),
nick_name = row["nick_name"].ToString(),
mobile = row["user_name"].ToString(),
password = row["password"].ToString(),
group_id = row["group_id"].ToString(),
card_id = row["card_id"].ToString(),
company_name = row["company_name"].ToString(),
is_sa = row.Table.Columns.Contains("is_sa") ? row["is_sa"].ParseToInt() : 0,
sa_level = row.Table.Columns.Contains("sa_level") ? row["sa_level"].ParseToInt() : 0,
};
if (string.IsNullOrEmpty(user.company_name))
{
user.company_name = "-";
}
var data = JsonUtils.SerializeObjectToString(user);
return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"c\":\"" + EncrypUtil.Encryption(r2) + "\"}";
}
return "{\"code\":1,\"msg\":\"用户名或密码错误\"}";
}
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string AddSubUser(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
var parent_user_name = RegexUtils.GetStringQuery(ref inputData, "user_name")?.Replace("'", "\\'");
var nick_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sub_nick_name"))?.Replace("'", "\\'");
var user_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sub_name"))?.Replace("'", "\\'");
var mobile = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sub_mobile"))?.Replace("'", "\\'");
var password = RegexUtils.GetStringQuery(ref inputData, "sub_password")?.Replace("'", "\\'");
var group_id = RegexUtils.GetStringQuery(ref inputData, "group_id")?.Replace("'", "\\'");
var card_id = RegexUtils.GetStringQuery(ref inputData, "card_id")?.Replace("'", "\\'");
var company_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "company"))?.Replace("'", "\\'");
var notes = RegexUtils.GetStringQuery(ref inputData, "notes")?.Replace("'", "\\'");
int r2 = 0;
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "";
sql = "select exists (select 1 from dyxd.user where user_name='" + user_name + "')";
var exist = mySql.ExecuteFirstInt(sql);
if (exist > 0)
{
mySql.Close();
return "{\"code\":500,\"msg\":\"用户名已存在\"}";
}
sql = "insert into dyxd.user (nick_name,user_name,mobile,password,card_id,group_id,company_name,notes,parent_user_name,add_time,mdy_time) " +
"values ('" + nick_name + "','" + user_name + "','" + mobile + "','" + password + "','" + card_id + "','" +
group_id + "','" + company_name + "','" + notes + "','" + parent_user_name + "','" +
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','" +
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "');";
var rst = mySql.ExecuteNonQuery(sql);
mySql.Close();
if (!rst)
return "{\"code\":501,\"msg\":\""+ mySql.Message + "\"}";
else
return "{\"code\":200,\"msg\":\"子账户创建成功!\"}";
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string GetSubUser(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
var password = RegexUtils.GetStringQuery(ref inputData, "password");
var group = RegexUtils.GetStringQuery(ref inputData, "group");
int r2 = 0;
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "select * from dyxd.user where parent_user_name='"
+ user_name + "'";
var dt = mySql.ExecuteDataTable(sql);
mySql.Close();
if (dt != null)
{
List<UserLoginResultParam> userList = new List<UserLoginResultParam>();
foreach (DataRow row in dt.Rows)
{
UserLoginResultParam user = new UserLoginResultParam
{
id = Convert.ToInt32(row["id"]),
user_name = row["user_name"].ToString(),
nick_name = row["nick_name"].ToString(),
mobile = row["mobile"].ToString(),
password = row["password"].ToString(),
group_id = row["group_id"].ToString(),
card_id = row["card_id"].ToString(),
parent_user_name = row["parent_user_name"].ToString(),
company_name = row["company_name"].ToString(),
notes = row["notes"].ToString(),
};
if (string.IsNullOrEmpty(user.mobile))
{
user.mobile = row["user_name"].ToString();
}
userList.Add(user);
}
var data = JsonUtils.SerializeObjectToString(userList);
return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"c\":\"" + EncrypUtil.Encryption(r2) + "\"}";
}
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string UpdateSubUser(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
var id = RegexUtils.GetStringQuery(ref inputData, "id")?.Replace("'", "\\'");
var parent_user_name = RegexUtils.GetStringQuery(ref inputData, "user_name")?.Replace("'", "\\'");
var nick_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sub_nick_name"))?.Replace("'", "\\'");
var user_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sub_name"))?.Replace("'", "\\'");
var mobile = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sub_mobile"))?.Replace("'", "\\'");
var password = RegexUtils.GetStringQuery(ref inputData, "sub_password")?.Replace("'", "\\'");
var group_id = RegexUtils.GetStringQuery(ref inputData, "group_id")?.Replace("'", "\\'");
var card_id = RegexUtils.GetStringQuery(ref inputData, "card_id")?.Replace("'", "\\'");
var notes = RegexUtils.GetStringQuery(ref inputData, "notes")?.Replace("'", "\\'");
int r2 = 0;
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "";
//sql = "select * from dyxd.user where parent_user_name='"
// + user_name + "'";
sql = "update dyxd.user set";
if (!string.IsNullOrEmpty(nick_name))
sql += " nick_name='" + nick_name + "',";
if (!string.IsNullOrEmpty(user_name))
sql += " user_name='" + user_name + "',";
if (!string.IsNullOrEmpty(mobile))
sql += " mobile='" + mobile + "',";
if (!string.IsNullOrEmpty(password))
sql += " password='" + password + "',";
if (!string.IsNullOrEmpty(group_id))
sql += " group_id=" + group_id + ",";
if (!string.IsNullOrEmpty(card_id))
sql += " card_id='" + card_id + "',";
if (!string.IsNullOrEmpty(notes))
sql += " notes='" + notes + "',";
sql = sql.TrimEnd(',');
sql += " where id=" + id + "";
var rst = mySql.ExecuteNonQuery(sql);
mySql.Close();
if (rst)
{
return "{\"code\":200,\"msg\":\"success\"}";
}
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string DelUser(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
var id = RegexUtils.GetStringQuery(ref inputData, "id");
int r2 = 0;
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "delete from dyxd.user where id='"
+ id + "'";
var rst = mySql.ExecuteNonQuery(sql);
mySql.Close();
if (rst)
{
return "{\"code\":200,\"msg\":\"success\"}";
}
else
return "{\"code\":500,\"msg\":\"删除失败,请稍后重试\"}";
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string GetAllUser(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name")?.Replace("'", "\\'");
var password = RegexUtils.GetStringQuery(ref inputData, "password")?.Replace("'", "\\'");
var group_id = RegexUtils.GetStringQuery(ref inputData, "group_id")?.Replace("'", "\\'");
var search = RegexUtils.GetStringQuery(ref inputData, "search")?.Replace("'", "\\'");
var sa_level = RegexUtils.GetStringQuery(ref inputData, "sa_level")?.Replace("'", "\\'");
int r2 = 0;
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
//string sql = "select * from dyxd.user where group_id=3";
string sql = "select * from dyxd.user where 1=1";
if (!string.IsNullOrEmpty(group_id))
sql += " and group_id=" + group_id;
if (!string.IsNullOrEmpty(sa_level))
sql += " and sa_level=" + sa_level;
if (!string.IsNullOrEmpty(search))
sql += " and (user_name like '%" + search +
"%' or nick_name like '%" + search +
"%' or company_name like '%" + search + "%')";
sql += " order by id desc";
var dt = mySql.ExecuteDataTable(sql);
mySql.Close();
if (dt != null)
{
List<UserLoginResultParam> userList = new List<UserLoginResultParam>();
foreach (DataRow row in dt.Rows)
{
UserLoginResultParam user = new UserLoginResultParam
{
id = Convert.ToInt32(row["id"]),
user_name = row["user_name"].ToString(),
nick_name = row["nick_name"].ToString(),
mobile = row["mobile"].ToString(),
password = row["password"].ToString(),
group_id = row["group_id"].ToString(),
card_id = row["card_id"].ToString(),
parent_user_name = row["parent_user_name"].ToString(),
company_name = row["company_name"].ToString(),
notes = row["notes"].ToString(),
is_sa = row.Table.Columns.Contains("is_sa") ? row["is_sa"].ParseToInt() : 0,
sa_level = row.Table.Columns.Contains("sa_level") ? row["sa_level"].ParseToInt() : 0,
};
if (string.IsNullOrEmpty(user.mobile))
{
user.mobile = row["user_name"].ToString();
}
userList.Add(user);
}
var data = JsonUtils.SerializeObjectToString(userList);
return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"c\":\"" + EncrypUtil.Encryption(r2) + "\"}";
}
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string AddUser(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
var nick_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "add_nick_name"))?.Replace("'", "\\'");
var user_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "add_user_name"))?.Replace("'", "\\'");
var mobile = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "add_mobile"))?.Replace("'", "\\'");
var password = RegexUtils.GetStringQuery(ref inputData, "add_password")?.Replace("'", "\\'");
var company_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "add_company"))?.Replace("'", "\\'");
var group_id = RegexUtils.GetStringQuery(ref inputData, "group_id")?.Replace("'", "\\'"); ;
var card_id = RegexUtils.GetStringQuery(ref inputData, "card_id")?.Replace("'", "\\'");
var notes = RegexUtils.GetStringQuery(ref inputData, "notes")?.Replace("'", "\\'");
var sa_level = RegexUtils.GetStringQuery(ref inputData, "sa_level")?.Replace("'", "\\'");
int r2 = 0;
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "";
sql = "select exists (select 1 from dyxd.user where user_name='" + user_name + "')";
var exist = mySql.ExecuteFirstInt(sql);
if (exist > 0)
{
mySql.Close();
return "{\"code\":500,\"msg\":\"用户名已存在\"}";
}
sql = "insert into dyxd.user (nick_name,user_name,mobile,password,card_id,group_id,company_name,notes,sa_level,add_time,mdy_time) " +
"values ('" + nick_name + "','" + user_name + "','" + mobile + "','" + password + "','" + card_id + "','" +
group_id + "','" + company_name + "','" + notes + "'," + sa_level + ",'" +
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','" +
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "');";
var rst = mySql.ExecuteNonQuery(sql);
mySql.Close();
if (!rst)
return "{\"code\":501,\"msg\":\"" + mySql.Message + "\"}";
else
return "{\"code\":200,\"msg\":\"success\"}";
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string UpdateUser(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
var id = RegexUtils.GetStringQuery(ref inputData, "id")?.Replace("'", "\\'");
var nick_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "add_nick_name"))?.Replace("'", "\\'");
var user_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "add_user_name"))?.Replace("'", "\\'");
var mobile = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "add_mobile"))?.Replace("'", "\\'");
var company_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "add_company"))?.Replace("'", "\\'");
var password = RegexUtils.GetStringQuery(ref inputData, "add_password")?.Replace("'", "\\'");
var group_id = RegexUtils.GetStringQuery(ref inputData, "group_id")?.Replace("'", "\\'");
var card_id = RegexUtils.GetStringQuery(ref inputData, "card_id")?.Replace("'", "\\'");
var notes = RegexUtils.GetStringQuery(ref inputData, "notes")?.Replace("'", "\\'");
var sa_level = RegexUtils.GetStringQuery(ref inputData, "sa_level")?.Replace("'", "\\'");
int r2 = 0;
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "";
//sql = "select * from dyxd.user where parent_user_name='"
// + user_name + "'";
sql = "update dyxd.user set";
if (!string.IsNullOrEmpty(nick_name))
sql += " nick_name='" + nick_name + "',";
if (!string.IsNullOrEmpty(user_name))
sql += " user_name='" + user_name + "',";
if (!string.IsNullOrEmpty(mobile))
sql += " mobile='" + mobile + "',";
if (!string.IsNullOrEmpty(company_name))
sql += " company_name='" + company_name + "',";
if (!string.IsNullOrEmpty(password))
sql += " password='" + password + "',";
if (!string.IsNullOrEmpty(group_id))
sql += " group_id=" + group_id + ",";
if (!string.IsNullOrEmpty(card_id))
sql += " card_id='" + card_id + "',";
if (!string.IsNullOrEmpty(notes))
sql += " notes='" + notes + "',";
if (!string.IsNullOrEmpty(sa_level))
sql += " sa_level=" + sa_level + ",";
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 ChangePassword(string inputData)
{
var userName = RegexUtils.GetStringJson(ref inputData, "user_name")?.Replace("'", "\\'");
var password = RegexUtils.GetStringJson(ref inputData, "password")?.Replace("'", "\\'");
var newPassword = RegexUtils.GetStringJson(ref inputData, "new_password")?.Replace("'", "\\'");
string conn = "Conn";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "select user_id,password from pepdtp.user where user_id='"
+ userName + "' and password='" + password + "'";
var dw = mySql.ExecuteDataTableRow(sql);
if (dw != null)
{
UserLoginResultParam user = new UserLoginResultParam
{
user_name = dw["user_id"].ToString(),
password = dw["password"].ToString(),
};
sql = "update pepdtp.user set password = '" + newPassword + "' where user_id='" + userName + "'";
var result = mySql.ExecuteNonQuery(sql);
mySql.Close();
if (result)
{
return "{\"code\":0,\"msg\":\"密码修改成功!\"}";
}
else
return "{\"code\":19999,\"msg\":\"密码修改失败!请稍后再试。\"}";
}
else
{
mySql.Close();
return "{\"code\":1,\"msg\":\"原密码错误。\"}";
}
}
public string return_package_secret_key { get; set; } = "aaMETt2bPe6YHzZ1ojbC+6wOvgtwehqc6A+/Rz+pCUU=";
public string GetPackageSign(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
var mobile = RegexUtils.GetStringQuery(ref inputData, "mobile")?.Replace("'", "\\'");
var password = RegexUtils.GetStringQuery(ref inputData, "password")?.Replace("'", "\\'");
var timestamp = RegexUtils.GetStringQuery(ref inputData, "timestamp")?.Replace("'", "\\'");
var mallId = RegexUtils.GetStringQuery(ref inputData, "mallId")?.Replace("'", "\\'");
var returnPackageNo = RegexUtils.GetStringQuery(ref inputData, "returnPackageNo")?.Replace("'", "\\'");
int r2 = RegexUtils.GetStringQuery(ref inputData, "r2").ParseToInt();
string c2 = RegexUtils.GetStringQuery(ref inputData, "c2");
if (EncrypUtil.Encryption(r2) != c2)
return "{\"code\":2,\"msg\":\"不合法的输入内容\"}";
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "select * from dyxd.user where user_name='"
+ mobile + "' and password='" + password + "'";
sql = "select * from dyxd.user where user_name='" + mobile + "'";
var dt = mySql.ExecuteDataTable(sql);
mySql.Close();
if (dt == null || dt.Rows.Count <=0)
{
return "{\"code\":1,\"msg\":\"用户不存在\"}";
}
string sign = EncrypUtil.GetMd5(timestamp + return_package_secret_key + mallId + returnPackageNo).ToLower();
return "{\"code\":200, \"sign\":\"" + sign + "\", \"msg\":\"\"}";
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
}
}
@@ -0,0 +1,675 @@
using StoreHub.KJDWebService.Models;
using StoreHub.Framework.Repositorys;
using Microsoft.Extensions.Configuration;
using StoreHub.KJDWebService.Commons;
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.Diagnostics;
using System.Linq;
namespace StoreHub.KJDWebService.Services
{
public class OrderService : ServiceBase
{
public OrderService(SqlRepository sqlRepository, IConfiguration configuration) : base(sqlRepository, configuration)
{
}
public List<string> year_mounth_lst = new List<string>() { "202510", "202511", "202512",
"202601", "202602", "202603", "202604", "202605", "202606", "202607", "202608", "202609", "202610", "202611", "202612",
"202701", "202702", "202703", "202704", "202705", "202706", "202707", "202708", "202709", "202710", "202711", "202712",
"202801", "202802", "202803", "202804", "202805", "202806", "202807", "202808", "202809", "202810", "202811", "202812",
"202901", "202902", "202903", "202904", "202905", "202906", "202907", "202908", "202909", "202910", "202911", "202912",
"203001", "203002", "203003", "203004", "203005", "203006", "203007", "203008", "203009", "203010", "203011", "203012",
"203101", "203102", "203103", "203104", "203105", "203106", "203107", "203108", "203109", "203110", "203111", "203112",
"203201", "203202", "203203", "203204", "203205", "203206", "203207", "203208", "203209", "203210", "203211", "203212",
"203301", "203302", "203303", "203304", "203305", "203306", "203307", "203308", "203309", "203310", "203311", "203312" };
public string AddOrder(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");
if (string.IsNullOrEmpty(user_name))
{
return "{\"code\":500,\"msg\":\"没有用户名\"}";
}
var shop_id = RegexUtils.GetStringQuery(ref inputData, "shop_id")?.Replace("'", "\\'");
if (string.IsNullOrEmpty(shop_id))
return "{\"code\":500,\"msg\":\"请输入店铺\"}";
string order_data = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "order_data"))?.Replace("'", "\\'");
if (string.IsNullOrEmpty(order_data))
return "{\"code\":500,\"msg\":\"请输入订单参数\"}";
//string orderPurchaseTime = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "order_data"))?.Replace("'", "\\'");
//if (string.IsNullOrEmpty(order_data))
// return "{\"code\":500,\"msg\":\"请输入订单创建时间\"}";
JObject jObj = null;
try
{
jObj = JObject.Parse(order_data);
}
catch
{
return "{\"code\":500,\"msg\":\"数据格式错误\"}";
}
//long table_id = shop_id.ParseToLong() % 128;
string table_id = "999999";
try
{
table_id = TimeUtils.StampMillisecondsToDateTime(long.Parse(jObj["purchaseTime"].ToString())).ToString("yyyyMM");
}
catch (Exception ex)
{
return "{\"code\":500,\"msg\":\"" + ex.Message + "\"}";
}
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "";
sql = "insert into kjd_order.order_" + table_id + " (";
foreach (var item in jObj)
{
if (item.Key.ParseToString() != "id" && JsonConvert.SerializeObject(item.Value) != "null" &&
item.Key.ParseToString() != "add_time" && item.Key.ParseToString() != "mdy_time")
sql += item.Key + ",";
}
sql = sql.Trim(',');
sql += ")";
sql += "values (";
foreach (var item in jObj)
{
if (item.Key.ParseToString() != "id" && JsonConvert.SerializeObject(item.Value) != "null" &&
item.Key.ParseToString() != "add_time" && item.Key.ParseToString() != "mdy_time")
sql += "'" + item.Value.ParseToString().Replace("\\'", "'").Replace("'", "\\'") + "',";
}
sql = sql.Trim(',');
sql += ");";
var rst = mySql.ExecuteInsertId(sql);
mySql.Close();
if (rst > 0)
{
return "{\"code\":200,\"msg\":\"success\"}";
}
else
{
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}";
}
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string GetOrderList(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 shop_id = RegexUtils.GetStringQuery(ref inputData, "shop_id")?.Replace("'", "\\'");
//if (string.IsNullOrEmpty(shop_id))
// return "{\"code\":500,\"msg\":\"请输入查询店铺\",\"data\":[],\"count\":" + 0 + "}";
var upload_order_status = RegexUtils.GetStringQuery(ref inputData, "upload_order_status")?.Replace("'", "\\'");
//var start_time = RegexUtils.GetStringQuery(ref inputData, "start_time")?.Replace("'", "\\'");
var start_time = TimeUtils.DateTimeToTimestampMilliseconds(DateTime.Now.Date.AddDays(-30));
int page = RegexUtils.GetStringQuery(ref inputData, "page").ParseToInt();
int page_size = RegexUtils.GetStringQuery(ref inputData, "page_size").ParseToInt(50);
string startTimeStr = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "startTime"))?.Replace("'", "\\'");
string endTimeStr = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "endTime"))?.Replace("'", "\\'");
if (string.IsNullOrEmpty(endTimeStr))
{
var datetime = DateTime.Now;
startTimeStr = datetime.AddMonths(-1).ToString("yyyyMM");
endTimeStr = datetime.ToString("yyyyMM");
}
var startIndex = year_mounth_lst.IndexOf(startTimeStr);
var endIndex = year_mounth_lst.IndexOf(endTimeStr);
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
//long table_id = shop_id.ParseToLong() % 128;
//sql = "select count(id) from kjd_order.order_" + table_id + " o where 1=1";
string sql = "";
sql += " SELECT count(*) FROM ( ";
for (int i = startIndex; i<=endIndex; i++)
{
if (i > startIndex)
sql += " UNION ALL ";
sql += " SELECT id,purchaseTime,supplierId,upLoadStatus FROM kjd_order.order_" + year_mounth_lst[i];
}
sql += " ) AS o WHERE 1=1";
string where = "";
if (start_time > 0)
where += " and o.purchaseTime > " + start_time;
if (!string.IsNullOrWhiteSpace(shop_id))
where += " and o.supplierId = '" + shop_id + "'";
if (!string.IsNullOrEmpty(upload_order_status))
where += " and upLoadStatus >= " + upload_order_status;
sql += where;
var count = mySql.ExecuteRowCount(sql);
DataTable dt;
if (count == 0)
{
dt = new DataTable();
}
else
{
//sql = "SELECT * FROM kjd_order.order_" + table_id + " o where 1=1"; // p.is_del=0
sql = " SELECT * FROM ( ";
for (int i = startIndex; i <= endIndex; i++)
{
if (i > startIndex)
sql += " UNION ALL ";
sql += " SELECT * FROM kjd_order.order_" + year_mounth_lst[i];
}
sql += " ) AS o WHERE 1=1";
//where子句
sql += where;
sql += " ORDER BY o.purchaseTime desc";
//sql += " ORDER BY o.select_total_count desc, 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<TemuDBOrderInfo> orderLst = new List<TemuDBOrderInfo>();
foreach (DataRow row in dt.Rows)
{
TemuDBOrderInfo prod = new TemuDBOrderInfo
{
id = Convert.ToInt32(row["id"]),
add_time = Convert.ToDateTime(row["add_time"]),
mdy_time = Convert.ToDateTime(row["mdy_time"]),
notes = row["notes"].ParseToString(),
availableSaleDays = row["availableSaleDays"].ParseToNullableDecimal(),
barCodeMd5 = row["barCodeMd5"].ParseToString(),
category = row["category"].ParseToString(),
className = row["className"].ParseToString(),
costPrice = row["costPrice"].ParseToNullableInt(),
currencyType = row["currencyType"].ParseToString(),
deliverQuantity = row["deliverQuantity"].ParseToInt(),
deliverTime = row["deliverTime"].ParseToNullableLong(),
deliveryFee = row["deliveryFee"].ParseToNullableInt(),
deliveryOrderSn = row["deliveryOrderSn"].ParseToString(),
expectLatestArrivalTimeOrDefault = row["expectLatestArrivalTimeOrDefault"].ParseToLong(),
expectLatestDeliverTimeOrDefault = row["expectLatestDeliverTimeOrDefault"].ParseToLong(),
extCode = row["extCode"].ParseToString(),
jiaTongCode = row["jiaTongCode"].ParseToString(),
markFee = row["markFee"].ParseToNullableInt(),
originalPurchaseOrderSn = row["originalPurchaseOrderSn"].ParseToString(),
productId = row["productId"].ParseToString(),
productName = row["productName"].ParseToString(),
productSkcPicture = row["productSkcPicture"].ParseToString(),
productSkcId = row["productSkcId"].ParseToString(),
productSkuId = row["productSkuId"].ParseToString(),
productSn = row["productSn"].ParseToString(),
purchaseQuantity = row["purchaseQuantity"].ParseToInt(),
purchaseTime = row["purchaseTime"].ParseToLong(),
qcResult = row["qcResult"].ParseToNullableInt(),
realReceiveAuthenticQuantity = row["realReceiveAuthenticQuantity"].ParseToInt(),
receiveTime = row["receiveTime"].ParseToNullableLong(),
receiveWarehouseId = row["receiveWarehouseId"].ParseToString(),
receiveWarehouseName = row["receiveWarehouseName"].ParseToString(),
shippingMarkMd5 = row["shippingMarkMd5"].ParseToString(),
status = row["status"].ParseToInt(),
subPurchaseOrderSn = row["subPurchaseOrderSn"].ParseToString(),
supplierId = row["supplierId"].ParseToString(),
supplierName = row["supplierName"].ParseToString(),
supplierPrice = row["supplierPrice"].ParseToInt(),
thumbUrlList = row["thumbUrlList"].ParseToString(),
upLoadStatus = row["upLoadStatus"].ParseToInt(),
upProductId = row["upProductId"].ParseToString(),
warehouseGroupId = row["warehouseGroupId"].ParseToString(),
};
orderLst.Add(prod);
}
var data = JsonUtils.SerializeObjectToString(orderLst);
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 UpdateOrderStatus1(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 shop_id = RegexUtils.GetStringQuery(ref inputData, "shop_id")?.Replace("'", "\\'");
// if (string.IsNullOrEmpty(shop_id))
// return "{\"code\":500,\"msg\":\"请输入查询店铺\"}";
// var product_id = RegexUtils.GetStringQuery(ref inputData, "product_id")?.Replace("'", "\\'");
// if (string.IsNullOrEmpty(product_id))
// return "{\"code\":500,\"msg\":\"请输入商品编号\"}";
// int page = RegexUtils.GetStringQuery(ref inputData, "page").ParseToInt();
// int page_size = RegexUtils.GetStringQuery(ref inputData, "page_size").ParseToInt(50);
// string conn = "ConnKJD";
// MysqlUtils mySql = new MysqlUtils(conn);
// long table_id = shop_id.ParseToLong() % 128;
// string sql = "update kjd_order.order_" + table_id + " o set o.upLoadStatus=1";
// string where = "";
// where += " and o.supplierId = '" + shop_id + "'";
// where += " and o.productId = '" + product_id + "'";
// where += " and o.upLoadStatus < 1";
// sql += where;
// 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 AddOrderCodeFile(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");
if (string.IsNullOrEmpty(user_name))
{
return "{\"code\":500,\"msg\":\"没有用户名\"}";
}
var shop_id = RegexUtils.GetStringQuery(ref inputData, "shop_id")?.Replace("'", "\\'");
if (string.IsNullOrEmpty(shop_id))
return "{\"code\":500,\"msg\":\"请输入店铺\"}";
string file_md5 = RegexUtils.GetStringQuery(ref inputData, "file_md5")?.Replace("'", "\\'");
string file_base64 = RegexUtils.GetStringQuery(ref inputData, "file_base64")?.Replace("'", "\\'");
if (string.IsNullOrEmpty(file_md5) || string.IsNullOrEmpty(file_base64))
return "{\"code\":500,\"msg\":\"请输入文件信息\"}";
//long table_id = shop_id.ParseToLong() % 128;
string purchaseTime = RegexUtils.GetStringQuery(ref inputData, "purchaseTime")?.Replace("'", "\\'");
string table_id = "999999";
try
{
table_id = TimeUtils.StampMillisecondsToDateTime(long.Parse(purchaseTime)).ToString("yyyyMM");
}
catch (Exception ex)
{
return "{\"code\":500,\"msg\":\"请输入正确的时间:" + ex.Message + "\"}";
}
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "";
sql = "select count(fileCodeMd5) from kjd_order.order_code_" + table_id + " where fileCodeMd5='" + file_md5 + "';";
var rowCount = mySql.ExecuteRowCount(sql);
if (!string.IsNullOrEmpty(mySql.Message))
{
mySql.Close();
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}";
}
else if (rowCount > 0)
{
mySql.Close();
return "{\"code\":200,\"msg\":\"success\"}";
}
sql = "insert into kjd_order.order_code_" + table_id + " (supplierId,fileCodeMd5,fileCodeBase64)";
sql += " values ('" + shop_id + "','" + file_md5 + "','" + file_base64 + "')";
var rst = mySql.ExecuteNonQuery(sql);
mySql.Close();
if (!rst)
{
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}";
}
return "{\"code\":200,\"msg\":\"success\"}";
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string SaveOrderCodeFileLink(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");
if (string.IsNullOrEmpty(user_name))
{
return "{\"code\":500,\"msg\":\"没有用户名\"}";
}
var shop_id = RegexUtils.GetStringQuery(ref inputData, "shop_id")?.Replace("'", "\\'");
if (string.IsNullOrEmpty(shop_id))
return "{\"code\":500,\"msg\":\"请输入店铺\"}";
var sub_order_sn = RegexUtils.GetStringQuery(ref inputData, "sub_order_sn")?.Replace("'", "\\'");
if (string.IsNullOrEmpty(sub_order_sn))
return "{\"code\":500,\"msg\":\"请输入子单号\"}";
string jia_tong_code = RegexUtils.GetStringQuery(ref inputData, "jia_tong_code")?.Replace("'", "\\'"); // 佳同码
string bar_code_md5 = RegexUtils.GetStringQuery(ref inputData, "bar_code_md5")?.Replace("'", "\\'"); // 商品条码md5
string shipping_mark_md5 = RegexUtils.GetStringQuery(ref inputData, "shipping_mark_md5")?.Replace("'", "\\'"); // 箱唛md5
if (string.IsNullOrEmpty(jia_tong_code) && string.IsNullOrEmpty(bar_code_md5) && string.IsNullOrEmpty(shipping_mark_md5))
return "{\"code\":500,\"msg\":\"请输入文件信息\"}";
//long table_id = shop_id.ParseToLong() % 128;
string purchaseTime = RegexUtils.GetStringQuery(ref inputData, "purchaseTime")?.Replace("'", "\\'"); // 佳同码
string table_id = "999999";
try
{
table_id = TimeUtils.StampMillisecondsToDateTime(long.Parse(purchaseTime)).ToString("yyyyMM");
}
catch (Exception ex)
{
return "{\"code\":500,\"msg\":\"请输入正确的时间:" + ex.Message + "\"}";
}
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "";
sql = "update kjd_order.order_" + table_id;
sql += " set";
if (jia_tong_code != null)
sql += " jiaTongCode='" + jia_tong_code + "',";
if (bar_code_md5 != null)
sql += " barCodeMd5='" + bar_code_md5 + "',";
if (shipping_mark_md5 != null)
sql += " shippingMarkMd5='" + shipping_mark_md5 + "',";
sql = sql.TrimEnd(',');
sql += " where subPurchaseOrderSn='" + sub_order_sn + "';";
var rst = mySql.ExecuteNonQuery(sql);
mySql.Close();
if (rst)
{
return "{\"code\":200,\"msg\":\"success\"}";
}
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}";
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string getOrderCodeFile(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");
if (string.IsNullOrEmpty(user_name))
{
return "{\"code\":500,\"msg\":\"没有用户名\"}";
}
var shop_id = RegexUtils.GetStringQuery(ref inputData, "shop_id")?.Replace("'", "\\'");
if (string.IsNullOrEmpty(shop_id))
return "{\"code\":500,\"msg\":\"请输入店铺\"}";
string file_md5 = RegexUtils.GetStringQuery(ref inputData, "file_md5")?.Replace("'", "\\'");
if (string.IsNullOrEmpty(file_md5))
return "{\"code\":500,\"msg\":\"请输入文件信息\"}";
//long table_id = shop_id.ParseToLong() % 128;
string purchaseTime = RegexUtils.GetStringQuery(ref inputData, "purchaseTime")?.Replace("'", "\\'");
string table_id = "999999";
try
{
table_id = TimeUtils.StampMillisecondsToDateTime(long.Parse(purchaseTime)).ToString("yyyyMM");
}
catch (Exception ex)
{
return "{\"code\":500,\"msg\":\"请输入正确的时间:" + ex.Message + "\"}";
}
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "";
sql = "select fileCodeMd5,fileCodeBase64 from kjd_order.order_code_" + table_id + " where fileCodeMd5='" + file_md5 + "';";
var dt = mySql.ExecuteDataTable(sql);
mySql.Close();
if (!string.IsNullOrEmpty(mySql.Message))
{
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}";
}
else
{
string file_md5_rst = "";
string file_base64_rst = "";
if (dt.Rows.Count > 0)
{
file_md5_rst = dt.Rows[0]["fileCodeMd5"].ParseToString();
file_base64_rst = dt.Rows[0]["fileCodeBase64"].ParseToString();
}
return "{\"code\":200,\"msg\":\"success\",\"data\":\"{\"file_md5\":\"" + file_md5_rst + "\",\"file_base64\":\"" + file_base64_rst + "\"}\"}";
}
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string UploadOrder(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\":\"没有用户名\"}";
}
var shop_id = RegexUtils.GetStringQuery(ref inputData, "shop_id")?.Replace("'", "\\'");
if (string.IsNullOrEmpty(shop_id))
return "{\"code\":500,\"msg\":\"请输入店铺\"}";
string subPurchaseOrderSn = RegexUtils.GetStringQuery(ref inputData, "subPurchaseOrderSn")?.Replace("'", "\\'");
if (string.IsNullOrEmpty(subPurchaseOrderSn))
return "{\"code\":500,\"msg\":\"请输入订单编号\"}";
string feeStr = RegexUtils.GetStringQuery(ref inputData, "fee")?.Replace("'", "\\'");
if (string.IsNullOrEmpty(feeStr))
return "{\"code\":500,\"msg\":\"请输入费用\"}";
decimal fee = feeStr.ParseToDecimal();
//long table_id = shop_id.ParseToLong() % 128;
string purchaseTime = RegexUtils.GetStringQuery(ref inputData, "purchaseTime")?.Replace("'", "\\'");
string table_id = "999999";
try
{
table_id = TimeUtils.StampMillisecondsToDateTime(long.Parse(purchaseTime)).ToString("yyyyMM");
}
catch (Exception ex)
{
return "{\"code\":500,\"msg\":\"请输入正确的时间:" + ex.Message + "\"}";
}
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "";
sql = "select authorized_amount from kjd.user where user_name='" + user_name + "'";
var value = mySql.ExecuteFirst(sql);
if (!string.IsNullOrEmpty(mySql.Message))
{
mySql.Close();
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}";
}
if (value.IsNullOrEmpty())
{
mySql.Close();
return "{\"code\":500,\"msg\":\"用户不存\"}";
}
if (value.ParseToDecimal() < fee)
{
mySql.Close();
return "{\"code\":500,\"msg\":\"授权金不足\"}";
}
sql = "update kjd_order.order_" + table_id + " set upLoadStatus=2 where upLoadStatus < 2 and subPurchaseOrderSn in('" + subPurchaseOrderSn + "');";
var rst = mySql.ExecuteAffectedRows(sql);
if (!string.IsNullOrEmpty(mySql.Message))
{
mySql.Close();
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}";
}
if (rst == 0)
{
mySql.Close();
return "{\"code\":500,\"msg\":\"订单不存在或已上传\"}";
}
sql = "update kjd.user set authorized_amount=authorized_amount-" + fee + " where user_name='" + user_name + "';";
rst = mySql.ExecuteAffectedRows(sql);
mySql.Close();
if (!string.IsNullOrEmpty(mySql.Message))
{
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}";
}
if(rst == 0)
{
return "{\"code\":500,\"msg\":\"订单已提交但扣费失败\"}";
}
return "{\"code\":200,\"msg\":\"success\"}";
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string UpdateOrderStatus(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");
if (string.IsNullOrEmpty(user_name))
{
return "{\"code\":500,\"msg\":\"没有用户名\"}";
}
var shop_id = RegexUtils.GetStringQuery(ref inputData, "shop_id")?.Replace("'", "\\'");
if (string.IsNullOrEmpty(shop_id))
return "{\"code\":500,\"msg\":\"请输入店铺\"}";
string subPurchaseOrderSn = RegexUtils.GetStringQuery(ref inputData, "subPurchaseOrderSn")?.Replace("'", "\\'");
if (string.IsNullOrEmpty(subPurchaseOrderSn))
return "{\"code\":500,\"msg\":\"请输入订单编号\"}";
string new_status = RegexUtils.GetStringQuery(ref inputData, "new_status")?.Replace("'", "\\'");
string old_status = RegexUtils.GetStringQuery(ref inputData, "old_status")?.Replace("'", "\\'");
if (string.IsNullOrEmpty(new_status))
return "{\"code\":500,\"msg\":\"请输入订单状态\"}";
//long table_id = shop_id.ParseToLong() % 128;
string purchaseTime = RegexUtils.GetStringQuery(ref inputData, "purchaseTime")?.Replace("'", "\\'");
string table_id = "999999";
try
{
table_id = TimeUtils.StampMillisecondsToDateTime(long.Parse(purchaseTime)).ToString("yyyyMM");
}
catch (Exception ex)
{
return "{\"code\":500,\"msg\":\"请输入正确的时间:" + ex.Message + "\"}";
}
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "";
sql = "update kjd_order.order_" + table_id + " set upLoadStatus=" + new_status + " where 1=1";
if (!string.IsNullOrEmpty(old_status))
sql += " and upLoadStatus=" + old_status;
sql += " and subPurchaseOrderSn in('" + subPurchaseOrderSn + "');";
var rst = mySql.ExecuteAffectedRows(sql);
mySql.Close();
if (!string.IsNullOrEmpty(mySql.Message))
{
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}";
}
else
{
return "{\"code\":200,\"msg\":\"success\"}";
}
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
}
}
@@ -0,0 +1,607 @@
using StoreHub.KJDWebService.Models;
using StoreHub.Framework.Repositorys;
using Microsoft.Extensions.Configuration;
using StoreHub.KJDWebService.Commons;
using MySql.Data.MySqlClient;
using NaiBa.Util.Extension;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
namespace StoreHub.KJDWebService.Services
{
public class PriceService : ServiceBase
{
public PriceService(SqlRepository sqlRepository, IConfiguration configuration) : base(sqlRepository, configuration)
{
}
public string AddPrice(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 user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
string ext_code = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "ext_code")).ParseToString();
int original_price = RegexUtils.GetStringQuery(ref inputData, "original_price").ParseToInt();
int markup_times = RegexUtils.GetStringQuery(ref inputData, "markup_times").ParseToInt();
int extra_price = RegexUtils.GetStringQuery(ref inputData, "extra_price").ParseToInt();
string notes = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "notes")).ParseToString();
if (string.IsNullOrEmpty(user_name))
{
return "{\"code\":500,\"msg\":\"没有用户名\"}";
}
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sqlExist = "select count(ext_code) from kjd.price_markup where ext_code=@ext_code";
string sql = "insert into kjd.price_markup " +
"(ext_code,original_price,markup_times,extra_price,notes) " +
"values (@ext_code,@original_price,@markup_times,@extra_price,@notes);";
List<MySqlParameter> paramLst = new List<MySqlParameter>();
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@ext_code", Value = ext_code, });
paramLst.Add(new MySqlParameter() { DbType = DbType.Int32, ParameterName = "@original_price", Value = original_price, });
paramLst.Add(new MySqlParameter() { DbType = DbType.Int32, ParameterName = "@markup_times", Value = markup_times, });
paramLst.Add(new MySqlParameter() { DbType = DbType.Int32, ParameterName = "@extra_price", Value = extra_price, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@notes", Value = notes, });
var has = mySql.ExecuteFirst(sqlExist, paramLst.ToArray());
if (has != "0")
{
mySql.Close();
return "{\"code\":501,\"msg\":\"货号 " + ext_code + " 价格数据已存在\"}";
}
var rst = mySql.ExecuteNonQuery(sql, paramLst.ToArray());
mySql.Close();
if (rst)
{
return "{\"code\":200,\"msg\":\"success\"}";
}
else
{
return "{\"code\":502,\"msg\":\"" + mySql.Message + "\"}";
}
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string GetPriceList(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");
var password = RegexUtils.GetStringQuery(ref inputData, "password");
string start_original_price = RegexUtils.GetStringQuery(ref inputData, "start_original_price");
string end_original_price = RegexUtils.GetStringQuery(ref inputData, "end_original_price");
string start_markup_times = RegexUtils.GetStringQuery(ref inputData, "start_markup_times");
string end_markup_times = RegexUtils.GetStringQuery(ref inputData, "end_markup_times");
string start_extra_price = RegexUtils.GetStringQuery(ref inputData, "start_extra_price");
string end_extra_price = RegexUtils.GetStringQuery(ref inputData, "end_extra_price");
var search_ext_code = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "search_ext_code"));
var search_notes = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "search_notes"));
var in_ext_code = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "in_ext_code"));
int page = RegexUtils.GetStringQuery(ref inputData, "page").ParseToInt();
int page_size = RegexUtils.GetStringQuery(ref inputData, "page_size").ParseToInt(50);
if (string.IsNullOrEmpty(user_name))
{
return "{\"code\":500,\"msg\":\"没有用户名\"}";
}
List<MySqlParameter> paramLst = new List<MySqlParameter>();
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@search_ext_code", Value = "%" + search_ext_code + "%", });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@search_notes", Value = "%" + search_notes + "%", });
paramLst.Add(new MySqlParameter() { DbType = DbType.Int32, ParameterName = "@start_original_price", Value = start_original_price.ParseToInt(), });
paramLst.Add(new MySqlParameter() { DbType = DbType.Int32, ParameterName = "@end_original_price", Value = end_original_price.ParseToInt(), });
paramLst.Add(new MySqlParameter() { DbType = DbType.Int32, ParameterName = "@start_markup_times", Value = start_markup_times.ParseToInt(), });
paramLst.Add(new MySqlParameter() { DbType = DbType.Int32, ParameterName = "@end_markup_times", Value = end_markup_times.ParseToInt(), });
paramLst.Add(new MySqlParameter() { DbType = DbType.Int32, ParameterName = "@start_extra_price", Value = start_extra_price.ParseToInt(), });
paramLst.Add(new MySqlParameter() { DbType = DbType.Int32, ParameterName = "@end_extra_price", Value = end_extra_price.ParseToInt(), });
//paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@in_ext_code", Value = "'" + in_ext_code?.Replace(",", "','") + "'", });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@in_ext_code", Value = in_ext_code.ParseToString() });
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "select count(id) from kjd.price_markup p where 1=1";
string where = "";
if (!string.IsNullOrWhiteSpace(search_ext_code))
where += " and p.ext_code like @search_ext_code";
if (!string.IsNullOrWhiteSpace(search_notes))
where += " and p.notes like @search_notes";
if (!string.IsNullOrWhiteSpace(start_original_price))
where += " and p.original_price >= @start_original_price";
if (!string.IsNullOrWhiteSpace(end_original_price))
where += " and p.original_price <= @end_original_price";
if (!string.IsNullOrWhiteSpace(start_markup_times))
where += " and p.markup_times >= @start_markup_times";
if (!string.IsNullOrWhiteSpace(end_markup_times))
where += " and p.markup_times <= @end_markup_times";
if (!string.IsNullOrWhiteSpace(start_extra_price))
where += " and p.extra_price >= @start_extra_price";
if (!string.IsNullOrWhiteSpace(end_extra_price))
where += " and p.extra_price <= @end_extra_price";
if (!string.IsNullOrEmpty(in_ext_code))
where += " and p.ext_code in ('" + in_ext_code?.Replace(",", "','") + "')";
sql += where;
var count = mySql.ExecuteRowCount(sql, paramLst.ToArray());
DataTable dt;
if (count == 0)
{
dt = new DataTable();
}
else
{
sql = "select * from kjd.price_markup 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, paramLst.ToArray());
}
mySql.Close();
if (dt != null)
{
try
{
List<DBPriceResultParam> priceList = new List<DBPriceResultParam>();
foreach (DataRow row in dt.Rows)
{
DBPriceResultParam price = new DBPriceResultParam
{
id = row["id"].ParseToInt(),
extra_price = row["extra_price"].ParseToInt(),
markup_times = row["markup_times"].ParseToInt(),
original_price = row["original_price"].ParseToInt(),
notes = row["notes"].ParseToString(),
ext_code = row["ext_code"].ParseToString(),
add_time = Convert.ToDateTime(row["add_time"]),
mdy_time = Convert.ToDateTime(row["mdy_time"]),
};
priceList.Add(price);
}
var data = JsonUtils.SerializeObjectToString(priceList);
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 DelDbPrice(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("'", "\\'");
if (string.IsNullOrEmpty(user_name))
{
return "{\"code\":500,\"msg\":\"没有用户名\"}";
}
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "delete from kjd.price_markup 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 MdyDBPrice(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\":\"校验失败\"}";
var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
var db_id = RegexUtils.GetStringQuery(ref inputData, "db_id");
string notes = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "notes"));
string ext_code = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "ext_code"));
string original_price = RegexUtils.GetStringQuery(ref inputData, "original_price");
string markup_times = RegexUtils.GetStringQuery(ref inputData, "markup_times");
string extra_price = RegexUtils.GetStringQuery(ref inputData, "extra_price");
if (string.IsNullOrEmpty(user_name))
{
return "{\"code\":500,\"msg\":\"没有用户名\"}";
}
List<MySqlParameter> paramLst = new List<MySqlParameter>();
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@ext_code", Value = ext_code, });
paramLst.Add(new MySqlParameter() { DbType = DbType.Int32, ParameterName = "@original_price", Value = original_price.ParseToInt(), });
paramLst.Add(new MySqlParameter() { DbType = DbType.Int32, ParameterName = "@markup_times", Value = markup_times.ParseToInt(), });
paramLst.Add(new MySqlParameter() { DbType = DbType.Int32, ParameterName = "@extra_price", Value = extra_price.ParseToInt(), });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@notes", Value = notes, });
paramLst.Add(new MySqlParameter() { DbType = DbType.Int32, ParameterName = "@db_id", Value = db_id, });
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sqlExist = "select count(ext_code) from kjd.price_markup where ext_code=@ext_code and id!=@db_id";
var has = mySql.ExecuteFirst(sqlExist, paramLst.ToArray());
if (has != "0")
{
mySql.Close();
return "{\"code\":501,\"msg\":\"货号 " + ext_code + " 价格数据已存在\"}";
}
string sql = "update kjd.price_markup set";
if (notes != null)
sql += " notes=@notes,";
if (ext_code != null)
sql += " ext_code=@ext_code,";
if (original_price != null)
sql += " original_price=@original_price,";
if (markup_times != null)
sql += " markup_times=@markup_times,";
if (extra_price != null)
sql += " extra_price=@extra_price,";
sql = sql.TrimEnd(',');
sql += " where id=@db_id;";
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 AddPurchasePrice(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 user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
if (string.IsNullOrEmpty(user_name))
{
return "{\"code\":500,\"msg\":\"没有用户名\"}";
}
string shop_id = RegexUtils.GetStringQuery(ref inputData, "shop_id");
string shop_name = RegexUtils.GetStringQuery(ref inputData, "shop_name");
string spu_id = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "spu_id")).ParseToString();
string skc_id = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "skc_id")).ParseToString();
string cat_id = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "cat_id")).ParseToString();
string cat_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "cat_name")).ParseToString();
string ext_code = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "ext_code")).ParseToString();
string product_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "product_name")).ParseToString();
string main_img = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "main_img")).ParseToString();
string discount = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "discount")).ParseToString();
string price_text = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "price_text")).ParseToString();
string sku_purchase_price_json = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sku_purchase_price_json")).ParseToString();
string notes = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "notes")).ParseToString();
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sqlExist = "select count(spu_id) from kjd.product_purchase_price where spu_id=@spu_id";
string sql = "insert into kjd.product_purchase_price " +
"(shop_id,shop_name,spu_id,skc_id,cat_id,cat_name,ext_code,product_name,main_img,discount,price_text,sku_purchase_price_json,notes) " +
"values (@shop_id,@shop_name,@spu_id,@skc_id,@cat_id,@cat_name,@ext_code,@product_name,@main_img,@discount,@price_text,@sku_purchase_price_json,@notes);";
List<MySqlParameter> paramLst = new List<MySqlParameter>();
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@shop_id", Value = shop_id, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@shop_name", Value = shop_name, });
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 = "@ext_code", Value = ext_code, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@product_name", Value = product_name, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@main_img", Value = main_img, });
paramLst.Add(new MySqlParameter() { DbType = DbType.Int32, ParameterName = "@discount", Value = discount.ParseToInt(), });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@price_text", Value = price_text, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@sku_purchase_price_json", Value = sku_purchase_price_json, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@notes", Value = notes, });
var has = mySql.ExecuteFirst(sqlExist, paramLst.ToArray());
if (has != "0")
{
mySql.Close();
return "{\"code\":501,\"msg\":\"货号 " + ext_code + " 价格数据已存在\"}";
}
var rst = mySql.ExecuteNonQuery(sql, paramLst.ToArray());
mySql.Close();
if (rst)
{
return "{\"code\":200,\"msg\":\"success\"}";
}
else
{
return "{\"code\":502,\"msg\":\"" + mySql.Message + "\"}";
}
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string MdyPurchasePrice(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\":\"校验失败\"}";
var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
if (string.IsNullOrEmpty(user_name))
{
return "{\"code\":500,\"msg\":\"没有用户名\"}";
}
var db_id = RegexUtils.GetStringQuery(ref inputData, "db_id");
string shop_id = RegexUtils.GetStringQuery(ref inputData, "shop_id");
string shop_name = RegexUtils.GetStringQuery(ref inputData, "shop_name");
string cat_id = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "cat_id")).ParseToString();
string cat_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "cat_name")).ParseToString();
string ext_code = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "ext_code")).ParseToString();
string product_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "product_name")).ParseToString();
string main_img = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "main_img")).ParseToString();
string discount = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "discount")).ParseToString();
string price_text = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "price_text")).ParseToString();
string sku_purchase_price_json = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sku_purchase_price_json")).ParseToString();
string notes = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "notes")).ParseToString();
List<MySqlParameter> paramLst = new List<MySqlParameter>();
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@db_id", Value = db_id, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@shop_id", Value = shop_id, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@shop_name", Value = shop_name, });
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 = "@ext_code", Value = ext_code, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@product_name", Value = product_name, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@main_img", Value = main_img, });
paramLst.Add(new MySqlParameter() { DbType = DbType.Int32, ParameterName = "@discount", Value = discount.ParseToInt(), });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@price_text", Value = price_text, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@sku_purchase_price_json", Value = sku_purchase_price_json, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@notes", Value = notes, });
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "update kjd.product_purchase_price set";
if (shop_id != null)
sql += " shop_id=@shop_id,";
if (shop_name != null)
sql += " shop_name=@shop_name,";
if (cat_id != null)
sql += " cat_id=@cat_id,";
if (cat_name != null)
sql += " cat_name=@cat_name,";
if (ext_code != null)
sql += " ext_code=@ext_code,";
if (product_name != null)
sql += " product_name=@product_name,";
if (main_img != null)
sql += " main_img=@main_img,";
if (discount != null)
sql += " discount=@discount,";
if (price_text != null)
sql += " price_text=@price_text,";
if (sku_purchase_price_json != null)
sql += " sku_purchase_price_json=@sku_purchase_price_json,";
if (notes != null)
sql += " notes=@notes,";
sql = sql.TrimEnd(',');
sql += " where id=@db_id;";
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 GetPurchasePriceList(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");
var password = RegexUtils.GetStringQuery(ref inputData, "password");
var search_spu_id = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "search_spu_id"));
var search_skc_id = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "search_skc_id"));
var search_ext_code = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "search_ext_code"));
var search_notes = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "search_notes"));
var in_spu_id = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "in_spu_id"));
int page = RegexUtils.GetStringQuery(ref inputData, "page").ParseToInt();
int page_size = RegexUtils.GetStringQuery(ref inputData, "page_size").ParseToInt(50);
if (string.IsNullOrEmpty(user_name))
{
return "{\"code\":500,\"msg\":\"没有用户名\"}";
}
List<MySqlParameter> paramLst = new List<MySqlParameter>();
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@search_spu_id", Value = "%" + search_spu_id + "%", });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@search_skc_id", Value = "%" + search_skc_id + "%", });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@search_ext_code", Value = "%" + search_ext_code + "%", });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@search_notes", Value = "%" + search_notes + "%", });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@in_spu_id", Value = in_spu_id.ParseToString() });
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "select count(id) from kjd.product_purchase_price p where 1=1";
string where = "";
if (!string.IsNullOrWhiteSpace(search_spu_id))
where += " and p.spu_id like @search_spu_id";
if (!string.IsNullOrWhiteSpace(search_skc_id))
where += " and p.skc_id like @search_skc_id";
if (!string.IsNullOrWhiteSpace(search_ext_code))
where += " and p.ext_code like @search_ext_code";
if (!string.IsNullOrWhiteSpace(search_notes))
where += " and p.notes like @search_notes";
if (!string.IsNullOrEmpty(in_spu_id))
where += " and p.spu_id in ('" + in_spu_id?.Replace(",", "','") + "')";
sql += where;
var count = mySql.ExecuteRowCount(sql, paramLst.ToArray());
DataTable dt;
if (count == 0)
{
dt = new DataTable();
}
else
{
sql = "select * from kjd.product_purchase_price 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, paramLst.ToArray());
}
mySql.Close();
if (dt != null)
{
try
{
List<ProductPurchasePriceResultParam> purchasePriceList = new List<ProductPurchasePriceResultParam>();
foreach (DataRow row in dt.Rows)
{
ProductPurchasePriceResultParam price = new ProductPurchasePriceResultParam
{
id = row["id"].ParseToInt(),
shop_id = row["shop_id"].ParseToString(),
shop_name = row["shop_name"].ParseToString(),
cat_id = row["cat_id"].ParseToString(),
cat_name = row["cat_name"].ParseToString(),
main_img = row["main_img"].ParseToString(),
discount = row["discount"].ParseToInt(),
price_text = row["price_text"].ParseToString(),
product_name = row["product_name"].ParseToString(),
skc_id = row["skc_id"].ParseToString(),
sku_purchase_price_json = row["sku_purchase_price_json"].ParseToString(),
spu_id = row["spu_id"].ParseToString(),
notes = row["notes"].ParseToString(),
ext_code = row["ext_code"].ParseToString(),
add_time = Convert.ToDateTime(row["add_time"]),
mdy_time = Convert.ToDateTime(row["mdy_time"]),
};
purchasePriceList.Add(price);
}
var data = JsonUtils.SerializeObjectToString(purchasePriceList);
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 DelPurchasePrice(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("'", "\\'");
if (string.IsNullOrEmpty(user_name))
{
return "{\"code\":500,\"msg\":\"没有用户名\"}";
}
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "delete from kjd.product_purchase_price 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\":\"输入为空\"}";
}
}
}
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,40 @@
using FreeSql;
using MAX.Core.DependencyInjection;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using StoreHub.Framework.Repositorys;
using StoreHub.KJDWebService.Commons;
namespace StoreHub.KJDWebService.Services
{
/// <summary>
/// 迁移服务基类:注入 SqlRepository(提供 KJDDB IAdo)与 IConfiguration。
/// 提供 MySql(connKey[, isUseTrans]) 创建与旧 MysqlUtils 兼容的执行器(内部参数化执行)。
/// </summary>
public abstract class ServiceBase : ITransientDependency
{
protected readonly SqlRepository _sqlRepository;
protected readonly IConfiguration _configuration;
protected ServiceBase(SqlRepository sqlRepository, IConfiguration configuration)
{
_sqlRepository = sqlRepository;
_configuration = configuration;
}
/// <summary>KJDDB 的 IAdo(等效旧 ConnKJD)</summary>
protected IAdo Ado => _sqlRepository.Ado;
/// <summary>创建 MysqlUtils(等效旧 new MysqlUtils(conn[, isUseTrans]))</summary>
protected MysqlUtils MySql(string connKey, bool isUseTrans = false)
{
return new MysqlUtils(AdoProvider.Get(connKey), isUseTrans);
}
/// <summary>读取配置(旧 ConfigurationManager.ConnectionStrings["key"].ConnectionString)</summary>
protected string Config(string key)
{
return KJDConfig.Get(key);
}
}
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,232 @@
using StoreHub.KJDWebService.Commons;
using StoreHub.Framework.Repositorys;
using Microsoft.Extensions.Configuration;
using NaiBa.Util.Extension;
using System;
using System.Collections.Generic;
using System.Linq;
namespace StoreHub.KJDWebService.Services
{
public class ToolService : ServiceBase
{
public ToolService(SqlRepository sqlRepository, IConfiguration configuration) : base(sqlRepository, configuration)
{
}
//mysql workbench 存储过程,可以使用分隔符重定义
// string 存储过程1 = @"
//DELIMITER $
//DROP PROCEDURE IF EXISTS add_spu_map;
//CREATE PROCEDURE add_spu_map()
//BEGIN
//insert into kjd_map.spu_map_0 (draft_id,from_spu_id,shop_id) values(9122600878,727585921,'3049342434562');
//update kjd.third_product_select set draft_id='9122600878', status='已上传', add_times=add_times+1, mdy_time='2025-08-06 11:54:50' where id=6532;
//END $
//DELIMITER ;
//CALL add_spu_map();";
//腾讯云服务器存储过程,不能使用分隔符重定义
// string 存储过程2 = @"
//DROP PROCEDURE IF EXISTS add_spu_map;
//CREATE PROCEDURE add_spu_map()
//BEGIN
//insert into kjd_map.spu_map_1 (draft_id,from_spu_id,shop_id) values(9122600878,727585921,'3049342434562');
//update kjd.third_product_select set draft_id='9122600878', status='已上传', add_times=add_times+1, mdy_time='2025-08-06 11:54:50' where id=6532;
//END ;
//CALL add_spu_map();";
public void CreateTable()
{
//string conn = "ConnKJD";
//MysqlUtils mySql = new MysqlUtils(conn);
//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') + @" (
// `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`),
// KEY `index_add_time` (`add_time`) USING BTREE,
// KEY `index_up_spu_id` (`up_spu_id`) 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);
//}
//mySql.Close();
//string conn = "ConnKJD";
//MysqlUtils mySql = new MysqlUtils(conn);
//string sql = "";
//for (int i = 0; i < 1024; i++)
//{
// sql = @"drop table if exists wxxd_product_up_map.product_up_map_" + i.ParseToString().PadLeft(4, '0') + ";\r\n";
// sql += @"
//CREATE TABLE wxxd_product_up_map.product_up_map_" + i.ParseToString().PadLeft(4, '0') + @" (
// `id` int NOT NULL AUTO_INCREMENT,
// `up_secret_spu_id` varchar(50) NOT NULL COMMENT '加密源商品id信息,此字段为分表依据,对应商品货号字段',
// `up_spu_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`),
// KEY `index_add_time` (`add_time`) USING BTREE,
// KEY `index_up_secret_spu_id_shop_id` (`up_secret_spu_id`, `shop_id`) USING BTREE
//) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '记录微信商品上传到哪些店铺的信息'";
// var rst = mySql.ExecuteNonQuery(sql);
//}
//mySql.Close();
// string conn = "ConnKJD";
// MysqlUtils mySql = new MysqlUtils(conn);
// string sql = "";
// string sql1 = "";
// for (int i = 0; i < 64; i++)
// {
// //sql = @"drop table if exists kjd_map.spu_map_" + i + ";\r\n";
// sql = @"CREATE TABLE IF NOT EXISTS kjd_map.jit_product_select_map_" + i + @" (
// `id` int NOT NULL AUTO_INCREMENT,
// `product_id` bigint NOT NULL COMMENT '草稿箱/商品Id',
// `product_select_db_id` bigint NOT NULL COMMENT '选品上传数据库Id',
// `shop_id` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '上传的店铺',
// PRIMARY KEY (`id`)
//) ENGINE = InnoDB AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '上传商品kjd库Id与商品DraftId映射关系';";
// sql += @"
//ALTER TABLE
// kjd_map.jit_product_select_map_" + i + @"
//ADD
// COLUMN `add_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP";
// var rst = mySql.ExecuteNonQuery(sql);
// }
// mySql.Close();
// string conn = "ConnKJD";
// MysqlUtils mySql = new MysqlUtils(conn);
// string sql = "";
// for (int i = 0; i < 128; i++)
// {
// //sql = @"drop table if exists kjd_map.spu_map_" + i + ";\r\n";
// sql = @"CREATE TABLE IF NOT EXISTS kjd_order.order_code_" + i + @" (
// `id` int unsigned NOT NULL AUTO_INCREMENT,
// `supplierId` varchar(25) COLLATE utf8mb4_general_ci NOT NULL,
// `subPurchaseOrderSn` varchar(25) COLLATE utf8mb4_general_ci DEFAULT NULL,
// `jiaTongCode` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
// `barCodeMd5` varchar(32) COLLATE utf8mb4_general_ci DEFAULT NULL,
// `barCodeBase64` longtext COLLATE utf8mb4_general_ci,
// `shippingMark​Md5` varchar(32) COLLATE utf8mb4_general_ci DEFAULT NULL,
// `shippingMarkBase64` longtext COLLATE utf8mb4_general_ci,
// `add_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
// `mdy_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
// PRIMARY KEY (`id`),
// UNIQUE KEY `index_subPurchaseOrderSn` (`subPurchaseOrderSn`) USING BTREE
//) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci";
// sql = "ALTER TABLE\r\n kjd_order.order_code_" + i + "\r\nMODIFY\r\n COLUMN `jiaTongCode` varchar (50) NULL COMMENT '佳同码'\r\nAFTER\r\n `subPurchaseOrderSn`";
// var rst = mySql.ExecuteNonQuery(sql);
// }
// mySql.Close();
//string conn = "ConnKJD";
//MysqlUtils mySql = new MysqlUtils(conn);
//string sql = "";
// for (int i = 1; i <= 12; i++)
// {
// //sql = @"drop table if exists kjd_order.order_code_" + i + ";\r\n";
// sql = @"CREATE TABLE IF NOT EXISTS kjd_order.order_2026" + i.ToString("D2") + @" (
// `id` int NOT NULL AUTO_INCREMENT,
// `supplierId` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '店铺Id',
// `supplierName` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '店铺名称',
// `originalPurchaseOrderSn` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '备母货单号',
// `subPurchaseOrderSn` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '备货单号',
// `productName` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
// `category` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
// `productId` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '商品编号',
// `upProductId` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '上家编号',
// `productSkcId` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
// `productSkcPicture` varchar(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '主图',
// `productSn` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '货号',
// `status` int NOT NULL COMMENT '状态 1待发货 2已送货 7已入库 8已作废',
// `productSkuId` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
// `extCode` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'sku货号',
// `className` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'sku规格',
// `currencyType` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
// `supplierPrice` int NOT NULL COMMENT '申报价格',
// `costPrice` int DEFAULT NULL COMMENT '成本价',
// `deliveryFee` int DEFAULT NULL COMMENT '车队费',
// `markFee` int DEFAULT NULL COMMENT '贴标费',
// `purchaseQuantity` int NOT NULL COMMENT '备货件数',
// `deliverQuantity` int NOT NULL COMMENT '送货件数',
// `realReceiveAuthenticQuantity` int NOT NULL COMMENT '入库件数',
// `availableSaleDays` decimal(10, 0) DEFAULT NULL COMMENT '可售天数',
// `qcResult` int DEFAULT NULL COMMENT '抽检结果 1合格 2不合格',
// `thumbUrlList` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT 'sku图片',
// `purchaseTime` bigint NOT NULL COMMENT '备货单创建时间',
// `deliverTime` bigint DEFAULT NULL COMMENT '发货时间',
// `receiveTime` bigint DEFAULT NULL COMMENT '收货时间',
// `expectLatestDeliverTimeOrDefault` bigint NOT NULL COMMENT '最迟发货时间',
// `expectLatestArrivalTimeOrDefault` bigint NOT NULL COMMENT '最迟到货时间',
// `deliveryOrderSn` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '发货单号',
// `receiveWarehouseId` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '实际收货仓库Id',
// `receiveWarehouseName` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '实际收货仓库',
// `warehouseGroupId` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '仓组Id',
// `jiaTongCode` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '佳同码',
// `barCodeMd5` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '商品条码MD5',
// `shippingMarkMd5` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '箱唛文件MD5',
// `notes` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '备注',
// `upLoadStatus` int NOT NULL DEFAULT '0' COMMENT '是否上传订单(上传后扣除用户授权金额,产生扣费记录)',
// `add_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
// `mdy_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
// PRIMARY KEY (`id`),
// UNIQUE KEY `index_subPurchaseOrderSn` (`subPurchaseOrderSn`) USING BTREE
//) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '订单推送表'";
// //sql = @"drop table if exists kjd_order.order_code_" + i + ";\r\n";
// sql = @"CREATE TABLE IF NOT EXISTS kjd_order.order_code_2026" + i.ToString("D2") + @" (
// `id` int unsigned NOT NULL AUTO_INCREMENT,
// `supplierId` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
// `fileCodeMd5` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
// `fileCodeBase64` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
// `add_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
// `mdy_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
// PRIMARY KEY (`id`),
// UNIQUE KEY `index_fileCodeMd5` (`fileCodeMd5`) USING BTREE
//) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci";
// // sql = "ALTER TABLE\r\n kjd_order.order_" + i + "\r\nADD\r\n COLUMN `upLoadStatus` int NOT NULL DEFAULT 0 COMMENT '是否上传订单(上传后扣除用户授权金额,产生扣费记录)',\r\nMODIFY\r\n COLUMN `add_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP\r\nAFTER\r\n `upLoadStatus`,\r\nMODIFY\r\n COLUMN `mdy_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP\r\nAFTER\r\n `add_time`";
// // sql = "ALTER TABLE\r\n kjd_order.order_" + i + "\r\nADD\r\n COLUMN `extCode` varchar (50) NOT NULL COMMENT 'sku货号',\r\nMODIFY\r\n COLUMN `className` varchar (100) NOT NULL COMMENT 'sku规格'\r\nAFTER\r\n `extCode`,\r\nMODIFY\r\n COLUMN `currencyType` varchar (10) NOT NULL\r\nAFTER\r\n `className`,\r\nMODIFY\r\n COLUMN `supplierPrice` int NOT NULL COMMENT '申报价格'\r\nAFTER\r\n `currencyType`,\r\nMODIFY\r\n COLUMN `purchaseQuantity` int NOT NULL COMMENT '备货件数'\r\nAFTER\r\n `supplierPrice`,\r\nMODIFY\r\n COLUMN `deliverQuantity` int NOT NULL COMMENT '送货件数'\r\nAFTER\r\n `purchaseQuantity`,\r\nMODIFY\r\n COLUMN `realReceiveAuthenticQuantity` int NOT NULL COMMENT '入库件数'\r\nAFTER\r\n `deliverQuantity`,\r\nMODIFY\r\n COLUMN `availableSaleDays` decimal (10, 0) NOT NULL COMMENT '可售天数'\r\nAFTER\r\n `realReceiveAuthenticQuantity`,\r\nMODIFY\r\n COLUMN `qcResult` int NULL COMMENT '抽检结果 1合格 2不合格'\r\nAFTER\r\n `availableSaleDays`,\r\nMODIFY\r\n COLUMN `thumbUrlList` varchar (500) NULL COMMENT 'sku图片'\r\nAFTER\r\n `qcResult`,\r\nMODIFY\r\n COLUMN `purchaseTime` bigint NOT NULL COMMENT '备货单创建时间'\r\nAFTER\r\n `thumbUrlList`,\r\nMODIFY\r\n COLUMN `deliverTime` bigint NULL COMMENT '发货时间'\r\nAFTER\r\n `purchaseTime`,\r\nMODIFY\r\n COLUMN `receiveTime` bigint NULL COMMENT '收货时间'\r\nAFTER\r\n `deliverTime`,\r\nMODIFY\r\n COLUMN `expectLatestDeliverTimeOrDefault` bigint NOT NULL COMMENT '最迟发货时间'\r\nAFTER\r\n `receiveTime`,\r\nMODIFY\r\n COLUMN `expectLatestArrivalTimeOrDefault` bigint NOT NULL COMMENT '最迟到货时间'\r\nAFTER\r\n `expectLatestDeliverTimeOrDefault`,\r\nMODIFY\r\n COLUMN `deliveryOrderSn` varchar (50) NULL COMMENT '发货单号'\r\nAFTER\r\n `expectLatestArrivalTimeOrDefault`,\r\nMODIFY\r\n COLUMN `receiveWarehouseId` varchar (25) NULL COMMENT '实际收货仓库Id'\r\nAFTER\r\n `deliveryOrderSn`,\r\nMODIFY\r\n COLUMN `receiveWarehouseName` varchar (50) NULL COMMENT '实际收货仓库'\r\nAFTER\r\n `receiveWarehouseId`,\r\nMODIFY\r\n COLUMN `warehouseGroupId` varchar (25) NULL COMMENT '仓组Id'\r\nAFTER\r\n `receiveWarehouseName`,\r\nMODIFY\r\n COLUMN `jiaTongCode` varchar (50) NULL COMMENT '佳同码'\r\nAFTER\r\n `warehouseGroupId`,\r\nMODIFY\r\n COLUMN `barCodeMd5` varchar (32) NULL COMMENT '商品条码MD5'\r\nAFTER\r\n `jiaTongCode`,\r\nMODIFY\r\n COLUMN `shippingMark​Md5` varchar (32) NULL COMMENT '箱唛文件MD5'\r\nAFTER\r\n `barCodeMd5`,\r\nMODIFY\r\n COLUMN `notes` varchar (50) NULL COMMENT '备注'\r\nAFTER\r\n `shippingMark​Md5`,\r\nMODIFY\r\n COLUMN `add_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP\r\nAFTER\r\n `notes`,\r\nMODIFY\r\n COLUMN `mdy_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP\r\nAFTER\r\n `add_time`";
// // sql = "ALTER TABLE\r\n kjd_order.order_" + i + "\r\nMODIFY\r\n COLUMN `extCode` varchar (50) NOT NULL COMMENT 'sku货号'\r\nAFTER\r\n `productSkuId`,\r\nMODIFY\r\n COLUMN `className` varchar (100) NOT NULL COMMENT 'sku规格'\r\nAFTER\r\n `extCode`,\r\nMODIFY\r\n COLUMN `currencyType` varchar (10) NOT NULL\r\nAFTER\r\n `className`,\r\nMODIFY\r\n COLUMN `supplierPrice` int NOT NULL COMMENT '申报价格'\r\nAFTER\r\n `currencyType`,\r\nMODIFY\r\n COLUMN `purchaseQuantity` int NOT NULL COMMENT '备货件数'\r\nAFTER\r\n `supplierPrice`,\r\nMODIFY\r\n COLUMN `deliverQuantity` int NOT NULL COMMENT '送货件数'\r\nAFTER\r\n `purchaseQuantity`,\r\nMODIFY\r\n COLUMN `realReceiveAuthenticQuantity` int NOT NULL COMMENT '入库件数'\r\nAFTER\r\n `deliverQuantity`,\r\nMODIFY\r\n COLUMN `availableSaleDays` decimal (10, 0) NOT NULL COMMENT '可售天数'\r\nAFTER\r\n `realReceiveAuthenticQuantity`,\r\nMODIFY\r\n COLUMN `qcResult` int NULL COMMENT '抽检结果 1合格 2不合格'\r\nAFTER\r\n `availableSaleDays`,\r\nMODIFY\r\n COLUMN `thumbUrlList` varchar (500) NULL COMMENT 'sku图片'\r\nAFTER\r\n `qcResult`,\r\nMODIFY\r\n COLUMN `purchaseTime` bigint NOT NULL COMMENT '备货单创建时间'\r\nAFTER\r\n `thumbUrlList`,\r\nMODIFY\r\n COLUMN `deliverTime` bigint NULL COMMENT '发货时间'\r\nAFTER\r\n `purchaseTime`,\r\nMODIFY\r\n COLUMN `receiveTime` bigint NULL COMMENT '收货时间'\r\nAFTER\r\n `deliverTime`,\r\nMODIFY\r\n COLUMN `expectLatestDeliverTimeOrDefault` bigint NOT NULL COMMENT '最迟发货时间'\r\nAFTER\r\n `receiveTime`,\r\nMODIFY\r\n COLUMN `expectLatestArrivalTimeOrDefault` bigint NOT NULL COMMENT '最迟到货时间'\r\nAFTER\r\n `expectLatestDeliverTimeOrDefault`,\r\nMODIFY\r\n COLUMN `deliveryOrderSn` varchar (50) NULL COMMENT '发货单号'\r\nAFTER\r\n `expectLatestArrivalTimeOrDefault`,\r\nMODIFY\r\n COLUMN `receiveWarehouseId` varchar (25) NULL COMMENT '实际收货仓库Id'\r\nAFTER\r\n `deliveryOrderSn`,\r\nMODIFY\r\n COLUMN `receiveWarehouseName` varchar (50) NULL COMMENT '实际收货仓库'\r\nAFTER\r\n `receiveWarehouseId`,\r\nMODIFY\r\n COLUMN `warehouseGroupId` varchar (25) NULL COMMENT '仓组Id'\r\nAFTER\r\n `receiveWarehouseName`,\r\nMODIFY\r\n COLUMN `jiaTongCode` varchar (50) NULL COMMENT '佳同码'\r\nAFTER\r\n `warehouseGroupId`,\r\nMODIFY\r\n COLUMN `barCodeMd5` varchar (32) NULL COMMENT '商品条码MD5'\r\nAFTER\r\n `jiaTongCode`,\r\nMODIFY\r\n COLUMN `shippingMark​Md5` varchar (32) NULL COMMENT '箱唛文件MD5'\r\nAFTER\r\n `barCodeMd5`,\r\nMODIFY\r\n COLUMN `notes` varchar (50) NULL COMMENT '备注'\r\nAFTER\r\n `shippingMark​Md5`,\r\nMODIFY\r\n COLUMN `upLoadStatus` int NOT NULL DEFAULT '0' COMMENT '是否上传订单(上传后扣除用户授权金额,产生扣费记录)'\r\nAFTER\r\n `notes`";
// // sql = "ALTER TABLE\r\n kjd_order.order_" + i + "\r\nADD\r\n COLUMN `costPrice` int NULL COMMENT '成本价',\r\nADD\r\n COLUMN `deliveryFee` int NULL COMMENT '车队费',\r\nADD\r\n COLUMN `markFee` int NULL COMMENT '贴标费',\r\nMODIFY\r\n COLUMN `purchaseQuantity` int NOT NULL COMMENT '备货件数'\r\nAFTER\r\n `markFee`,\r\nMODIFY\r\n COLUMN `deliverQuantity` int NOT NULL COMMENT '送货件数'\r\nAFTER\r\n `purchaseQuantity`,\r\nMODIFY\r\n COLUMN `realReceiveAuthenticQuantity` int NOT NULL COMMENT '入库件数'\r\nAFTER\r\n `deliverQuantity`,\r\nMODIFY\r\n COLUMN `availableSaleDays` decimal (10, 0) NOT NULL COMMENT '可售天数'\r\nAFTER\r\n `realReceiveAuthenticQuantity`,\r\nMODIFY\r\n COLUMN `qcResult` int NULL COMMENT '抽检结果 1合格 2不合格'\r\nAFTER\r\n `availableSaleDays`,\r\nMODIFY\r\n COLUMN `thumbUrlList` varchar (500) NULL COMMENT 'sku图片'\r\nAFTER\r\n `qcResult`,\r\nMODIFY\r\n COLUMN `purchaseTime` bigint NOT NULL COMMENT '备货单创建时间'\r\nAFTER\r\n `thumbUrlList`,\r\nMODIFY\r\n COLUMN `deliverTime` bigint NULL COMMENT '发货时间'\r\nAFTER\r\n `purchaseTime`,\r\nMODIFY\r\n COLUMN `receiveTime` bigint NULL COMMENT '收货时间'\r\nAFTER\r\n `deliverTime`,\r\nMODIFY\r\n COLUMN `expectLatestDeliverTimeOrDefault` bigint NOT NULL COMMENT '最迟发货时间'\r\nAFTER\r\n `receiveTime`,\r\nMODIFY\r\n COLUMN `expectLatestArrivalTimeOrDefault` bigint NOT NULL COMMENT '最迟到货时间'\r\nAFTER\r\n `expectLatestDeliverTimeOrDefault`,\r\nMODIFY\r\n COLUMN `deliveryOrderSn` varchar (50) NULL COMMENT '发货单号'\r\nAFTER\r\n `expectLatestArrivalTimeOrDefault`,\r\nMODIFY\r\n COLUMN `receiveWarehouseId` varchar (25) NULL COMMENT '实际收货仓库Id'\r\nAFTER\r\n `deliveryOrderSn`,\r\nMODIFY\r\n COLUMN `receiveWarehouseName` varchar (50) NULL COMMENT '实际收货仓库'\r\nAFTER\r\n `receiveWarehouseId`,\r\nMODIFY\r\n COLUMN `warehouseGroupId` varchar (25) NULL COMMENT '仓组Id'\r\nAFTER\r\n `receiveWarehouseName`,\r\nMODIFY\r\n COLUMN `jiaTongCode` varchar (50) NULL COMMENT '佳同码'\r\nAFTER\r\n `warehouseGroupId`,\r\nMODIFY\r\n COLUMN `barCodeMd5` varchar (32) NULL COMMENT '商品条码MD5'\r\nAFTER\r\n `jiaTongCode`,\r\nMODIFY\r\n COLUMN `shippingMark​Md5` varchar (32) NULL COMMENT '箱唛文件MD5'\r\nAFTER\r\n `barCodeMd5`,\r\nMODIFY\r\n COLUMN `notes` varchar (50) NULL COMMENT '备注'\r\nAFTER\r\n `shippingMark​Md5`,\r\nMODIFY\r\n COLUMN `upLoadStatus` int NOT NULL DEFAULT '0' COMMENT '是否上传订单(上传后扣除用户授权金额,产生扣费记录)'\r\nAFTER\r\n `notes`,\r\nMODIFY\r\n COLUMN `add_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP\r\nAFTER\r\n `upLoadStatus`,\r\nMODIFY\r\n COLUMN `mdy_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP\r\nAFTER\r\n `add_time`";
// // sql = "ALTER TABLE\r\n kjd_order.order_" + i + "\r\nMODIFY\r\n COLUMN `originalPurchaseOrderSn` varchar (25) NOT NULL COMMENT '备母货单号'\r\nAFTER\r\n `supplierId`,\r\nMODIFY\r\n COLUMN `subPurchaseOrderSn` varchar (25) NOT NULL COMMENT '备货单号'\r\nAFTER\r\n `originalPurchaseOrderSn`";
// // sql = "ALTER TABLE\r\n kjd_order.order_" + i + "\r\nMODIFY\r\n COLUMN `availableSaleDays` decimal (10, 0) NULL COMMENT '可售天数'\r\nAFTER\r\n `realReceiveAuthenticQuantity`";
// // sql = "ALTER TABLE\r\n kjd_order.order_" + i + "\r\nADD\r\n COLUMN `upProductId` varchar (25) NOT NULL COMMENT '上家编号',\r\nMODIFY\r\n COLUMN `productSkcId` varchar (25) NOT NULL\r\nAFTER\r\n `upProductId`,\r\nMODIFY\r\n COLUMN `productSkcPicture` varchar (250) NOT NULL COMMENT '主图'\r\nAFTER\r\n `productSkcId`,\r\nMODIFY\r\n COLUMN `productSn` varchar (50) NULL COMMENT '货号'\r\nAFTER\r\n `productSkcPicture`,\r\nMODIFY\r\n COLUMN `status` int NOT NULL COMMENT '状态 1待发货 2已送货 7已入库 8已作废'\r\nAFTER\r\n `productSn`,\r\nMODIFY\r\n COLUMN `productSkuId` varchar (25) NOT NULL\r\nAFTER\r\n `status`,\r\nMODIFY\r\n COLUMN `extCode` varchar (50) NOT NULL COMMENT 'sku货号'\r\nAFTER\r\n `productSkuId`,\r\nMODIFY\r\n COLUMN `className` varchar (100) NOT NULL COMMENT 'sku规格'\r\nAFTER\r\n `extCode`,\r\nMODIFY\r\n COLUMN `currencyType` varchar (10) NOT NULL\r\nAFTER\r\n `className`,\r\nMODIFY\r\n COLUMN `supplierPrice` int NOT NULL COMMENT '申报价格'\r\nAFTER\r\n `currencyType`,\r\nMODIFY\r\n COLUMN `costPrice` int NULL COMMENT '成本价'\r\nAFTER\r\n `supplierPrice`,\r\nMODIFY\r\n COLUMN `deliveryFee` int NULL COMMENT '车队费'\r\nAFTER\r\n `costPrice`,\r\nMODIFY\r\n COLUMN `markFee` int NULL COMMENT '贴标费'\r\nAFTER\r\n `deliveryFee`,\r\nMODIFY\r\n COLUMN `purchaseQuantity` int NOT NULL COMMENT '备货件数'\r\nAFTER\r\n `markFee`,\r\nMODIFY\r\n COLUMN `deliverQuantity` int NOT NULL COMMENT '送货件数'\r\nAFTER\r\n `purchaseQuantity`,\r\nMODIFY\r\n COLUMN `realReceiveAuthenticQuantity` int NOT NULL COMMENT '入库件数'\r\nAFTER\r\n `deliverQuantity`,\r\nMODIFY\r\n COLUMN `availableSaleDays` decimal (10, 0) NULL COMMENT '可售天数'\r\nAFTER\r\n `realReceiveAuthenticQuantity`,\r\nMODIFY\r\n COLUMN `qcResult` int NULL COMMENT '抽检结果 1合格 2不合格'\r\nAFTER\r\n `availableSaleDays`,\r\nMODIFY\r\n COLUMN `thumbUrlList` varchar (500) NULL COMMENT 'sku图片'\r\nAFTER\r\n `qcResult`,\r\nMODIFY\r\n COLUMN `purchaseTime` bigint NOT NULL COMMENT '备货单创建时间'\r\nAFTER\r\n `thumbUrlList`,\r\nMODIFY\r\n COLUMN `deliverTime` bigint NULL COMMENT '发货时间'\r\nAFTER\r\n `purchaseTime`,\r\nMODIFY\r\n COLUMN `receiveTime` bigint NULL COMMENT '收货时间'\r\nAFTER\r\n `deliverTime`,\r\nMODIFY\r\n COLUMN `expectLatestDeliverTimeOrDefault` bigint NOT NULL COMMENT '最迟发货时间'\r\nAFTER\r\n `receiveTime`,\r\nMODIFY\r\n COLUMN `expectLatestArrivalTimeOrDefault` bigint NOT NULL COMMENT '最迟到货时间'\r\nAFTER\r\n `expectLatestDeliverTimeOrDefault`,\r\nMODIFY\r\n COLUMN `deliveryOrderSn` varchar (50) NULL COMMENT '发货单号'\r\nAFTER\r\n `expectLatestArrivalTimeOrDefault`,\r\nMODIFY\r\n COLUMN `receiveWarehouseId` varchar (25) NULL COMMENT '实际收货仓库Id'\r\nAFTER\r\n `deliveryOrderSn`,\r\nMODIFY\r\n COLUMN `receiveWarehouseName` varchar (50) NULL COMMENT '实际收货仓库'\r\nAFTER\r\n `receiveWarehouseId`,\r\nMODIFY\r\n COLUMN `warehouseGroupId` varchar (25) NULL COMMENT '仓组Id'\r\nAFTER\r\n `receiveWarehouseName`,\r\nMODIFY\r\n COLUMN `jiaTongCode` varchar (50) NULL COMMENT '佳同码'\r\nAFTER\r\n `warehouseGroupId`,\r\nMODIFY\r\n COLUMN `barCodeMd5` varchar (32) NULL COMMENT '商品条码MD5'\r\nAFTER\r\n `jiaTongCode`,\r\nMODIFY\r\n COLUMN `shippingMark​Md5` varchar (32) NULL COMMENT '箱唛文件MD5'\r\nAFTER\r\n `barCodeMd5`,\r\nMODIFY\r\n COLUMN `notes` varchar (50) NULL COMMENT '备注'\r\nAFTER\r\n `shippingMark​Md5`,\r\nMODIFY\r\n COLUMN `upLoadStatus` int NOT NULL DEFAULT '0' COMMENT '是否上传订单(上传后扣除用户授权金额,产生扣费记录)'\r\nAFTER\r\n `notes`,\r\nMODIFY\r\n COLUMN `add_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP\r\nAFTER\r\n `upLoadStatus`,\r\nMODIFY\r\n COLUMN `mdy_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP\r\nAFTER\r\n `add_time`";
// // sql = "ALTER TABLE\r\n kjd_order.order_" + i + "\r\nMODIFY\r\n COLUMN `upProductId` varchar (25) NULL COMMENT '上家编号'\r\nAFTER\r\n `productId`";
// // sql = "ALTER TABLE\r\n kjd_order.order_" + i + "\r\nADD\r\n COLUMN `supplierName` varchar (50) NOT NULL COMMENT '店铺名称',\r\nMODIFY\r\n COLUMN `originalPurchaseOrderSn` varchar (25) NOT NULL COMMENT '备母货单号'\r\nAFTER\r\n `supplierName`,\r\nMODIFY\r\n COLUMN `subPurchaseOrderSn` varchar (25) NOT NULL COMMENT '备货单号'\r\nAFTER\r\n `originalPurchaseOrderSn`,\r\nMODIFY\r\n COLUMN `productName` varchar (1000) NOT NULL\r\nAFTER\r\n `subPurchaseOrderSn`,\r\nMODIFY\r\n COLUMN `category` varchar (50) NOT NULL\r\nAFTER\r\n `productName`,\r\nMODIFY\r\n COLUMN `productId` varchar (25) NOT NULL COMMENT '商品编号'\r\nAFTER\r\n `category`,\r\nMODIFY\r\n COLUMN `upProductId` varchar (25) NULL COMMENT '上家编号'\r\nAFTER\r\n `productId`,\r\nMODIFY\r\n COLUMN `productSkcId` varchar (25) NOT NULL\r\nAFTER\r\n `upProductId`,\r\nMODIFY\r\n COLUMN `productSkcPicture` varchar (250) NOT NULL COMMENT '主图'\r\nAFTER\r\n `productSkcId`,\r\nMODIFY\r\n COLUMN `productSn` varchar (50) NULL COMMENT '货号'\r\nAFTER\r\n `productSkcPicture`,\r\nMODIFY\r\n COLUMN `status` int NOT NULL COMMENT '状态 1待发货 2已送货 7已入库 8已作废'\r\nAFTER\r\n `productSn`,\r\nMODIFY\r\n COLUMN `productSkuId` varchar (25) NOT NULL\r\nAFTER\r\n `status`,\r\nMODIFY\r\n COLUMN `extCode` varchar (50) NOT NULL COMMENT 'sku货号'\r\nAFTER\r\n `productSkuId`,\r\nMODIFY\r\n COLUMN `className` varchar (100) NOT NULL COMMENT 'sku规格'\r\nAFTER\r\n `extCode`,\r\nMODIFY\r\n COLUMN `currencyType` varchar (10) NOT NULL\r\nAFTER\r\n `className`,\r\nMODIFY\r\n COLUMN `supplierPrice` int NOT NULL COMMENT '申报价格'\r\nAFTER\r\n `currencyType`,\r\nMODIFY\r\n COLUMN `costPrice` int NULL COMMENT '成本价'\r\nAFTER\r\n `supplierPrice`,\r\nMODIFY\r\n COLUMN `deliveryFee` int NULL COMMENT '车队费'\r\nAFTER\r\n `costPrice`,\r\nMODIFY\r\n COLUMN `markFee` int NULL COMMENT '贴标费'\r\nAFTER\r\n `deliveryFee`,\r\nMODIFY\r\n COLUMN `purchaseQuantity` int NOT NULL COMMENT '备货件数'\r\nAFTER\r\n `markFee`,\r\nMODIFY\r\n COLUMN `deliverQuantity` int NOT NULL COMMENT '送货件数'\r\nAFTER\r\n `purchaseQuantity`,\r\nMODIFY\r\n COLUMN `realReceiveAuthenticQuantity` int NOT NULL COMMENT '入库件数'\r\nAFTER\r\n `deliverQuantity`,\r\nMODIFY\r\n COLUMN `availableSaleDays` decimal (10, 0) NULL COMMENT '可售天数'\r\nAFTER\r\n `realReceiveAuthenticQuantity`,\r\nMODIFY\r\n COLUMN `qcResult` int NULL COMMENT '抽检结果 1合格 2不合格'\r\nAFTER\r\n `availableSaleDays`,\r\nMODIFY\r\n COLUMN `thumbUrlList` varchar (500) NULL COMMENT 'sku图片'\r\nAFTER\r\n `qcResult`,\r\nMODIFY\r\n COLUMN `purchaseTime` bigint NOT NULL COMMENT '备货单创建时间'\r\nAFTER\r\n `thumbUrlList`,\r\nMODIFY\r\n COLUMN `deliverTime` bigint NULL COMMENT '发货时间'\r\nAFTER\r\n `purchaseTime`,\r\nMODIFY\r\n COLUMN `receiveTime` bigint NULL COMMENT '收货时间'\r\nAFTER\r\n `deliverTime`,\r\nMODIFY\r\n COLUMN `expectLatestDeliverTimeOrDefault` bigint NOT NULL COMMENT '最迟发货时间'\r\nAFTER\r\n `receiveTime`,\r\nMODIFY\r\n COLUMN `expectLatestArrivalTimeOrDefault` bigint NOT NULL COMMENT '最迟到货时间'\r\nAFTER\r\n `expectLatestDeliverTimeOrDefault`,\r\nMODIFY\r\n COLUMN `deliveryOrderSn` varchar (50) NULL COMMENT '发货单号'\r\nAFTER\r\n `expectLatestArrivalTimeOrDefault`,\r\nMODIFY\r\n COLUMN `receiveWarehouseId` varchar (25) NULL COMMENT '实际收货仓库Id'\r\nAFTER\r\n `deliveryOrderSn`,\r\nMODIFY\r\n COLUMN `receiveWarehouseName` varchar (50) NULL COMMENT '实际收货仓库'\r\nAFTER\r\n `receiveWarehouseId`,\r\nMODIFY\r\n COLUMN `warehouseGroupId` varchar (25) NULL COMMENT '仓组Id'\r\nAFTER\r\n `receiveWarehouseName`,\r\nMODIFY\r\n COLUMN `jiaTongCode` varchar (50) NULL COMMENT '佳同码'\r\nAFTER\r\n `warehouseGroupId`,\r\nMODIFY\r\n COLUMN `barCodeMd5` varchar (32) NULL COMMENT '商品条码MD5'\r\nAFTER\r\n `jiaTongCode`,\r\nMODIFY\r\n COLUMN `shippingMark​Md5` varchar (32) NULL COMMENT '箱唛文件MD5'\r\nAFTER\r\n `barCodeMd5`,\r\nMODIFY\r\n COLUMN `notes` varchar (50) NULL COMMENT '备注'\r\nAFTER\r\n `shippingMark​Md5`,\r\nMODIFY\r\n COLUMN `upLoadStatus` int NOT NULL DEFAULT '0' COMMENT '是否上传订单(上传后扣除用户授权金额,产生扣费记录)'\r\nAFTER\r\n `notes`,\r\nMODIFY\r\n COLUMN `add_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP\r\nAFTER\r\n `upLoadStatus`,\r\nMODIFY\r\n COLUMN `mdy_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP\r\nAFTER\r\n `add_time`";
// // sql = "ALTER TABLE\r\n kjd_order.order_" + i + " CHANGE COLUMN `shippingMark​Md5` `shippingMarkMd5` varchar (32) NULL COMMENT '箱唛文件MD5'";
// // sql = "ALTER TABLE\r\n kjd_order.order_code_" + i + " DROP COLUMN `subPurchaseOrderSn`,\r\n DROP COLUMN `jiaTongCode`,\r\n DROP COLUMN `shippingMark​Md5`,\r\n DROP COLUMN `shippingMarkBase64`,\r\n CHANGE COLUMN `barCodeMd5` `fileCodeMd5` varchar (32) NOT NULL,\r\n CHANGE COLUMN `barCodeBase64` `fileCodeBase64` longtext NOT NULL,\r\nMODIFY\r\n COLUMN `add_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP\r\nAFTER\r\n `fileCodeBase64`,\r\nMODIFY\r\n COLUMN `mdy_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP\r\nAFTER\r\n `add_time`,\r\n DROP INDEX `index_subPurchaseOrderSn`,\r\nADD\r\n UNIQUE `index_fileCodeMd5` USING btree (`fileCodeMd5`)";
// var rst = mySql.ExecuteNonQuery(sql);
//}
//mySql.Close();
}
}
}
@@ -0,0 +1,230 @@
using StoreHub.KJDWebService.Commons;
using StoreHub.Framework.Repositorys;
using Microsoft.Extensions.Configuration;
using NaiBa.Util.Extension;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace StoreHub.KJDWebService.Services
{
public class UpdateService : ServiceBase
{
public UpdateService(SqlRepository sqlRepository, IConfiguration configuration) : base(sqlRepository, configuration)
{
}
public string GetUpdate(string inputData)
{
//string time1 = Encryption(time);
//return "time=" + time + "&code=" + time1 + "&NbCodeVersion=1" + "&version=" + BaseClass.VersionCount
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\":\"校验失败\"}";
var version = RegexUtils.GetStringQuery(ref inputData, "version").ParseToInt();
var serverVersion = Config("UpdateVersion");
var UpdateFiles = ""; //Config("UpdateFiles");
var UpdateExe = Config("UpdateExe");
var UpdateExeChk = Config("UpdateExeChk");
var LowVersion = Config("LowVersion");
serverVersion = "1115";
UpdateFiles = "http://weidian.e57.cn/kjd_update/Update1115.zip";
if (version > LowVersion.ParseToInt())
{
return "{\"code\":200,\"msg\":\"success\",\"next_version\":" + serverVersion + ",\"exe_check\":\"" + UpdateExeChk +
"\",\"exe_address\":\"" + UpdateExe + "\",\"file_address\":\"" + UpdateFiles + "\"}";
}
else if (version > 0)
{
return "{\"code\":501,\"msg\":\"版本过低已无法直接升级,请联系管理员获取最新安装包\"}";
}
else
{
return "{\"code\":502,\"msg\":\"get update version failed\"}";
}
}
return "{\"code\":19999,\"msg\":\"未知错误\"}";
}
public string GetUpdateNew(string inputData)
{
//string time1 = Encryption(time);
//return "time=" + time + "&code=" + time1 + "&NbCodeVersion=1" + "&version=" + BaseClass.VersionCount
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\":\"校验失败\"}";
var path = RegexUtils.GetStringQuery(ref inputData, "path");
var version = RegexUtils.GetStringQuery(ref inputData, "version").ParseToInt();
var serverVersion = Config("UpdateVersion");
var UpdateNewUrl = Config("UpdateNewUrl");
var UpdateExe = Config("UpdateExe");
var UpdateExeChk = Config("UpdateExeChk");
var LowVersion = Config("LowVersion");
int MaxVersion = 999999;
if (version <= 1200)
MaxVersion = 1200;
if (version <= 1159)
MaxVersion = 1159;
if (version > LowVersion.ParseToInt())
{
if (path != null)
{
try
{
var fileDir = Config("UpdateFileDir");
if (path == "29wx")
{
var file = Directory.GetFiles(fileDir);
var versionTmp = 0;
foreach (var f in file)
{
var v = Path.GetFileName(f).Replace("Update29wx", "").Replace(".zip", "").ParseToInt();
if (v > versionTmp && v <= serverVersion.ParseToInt() && v <= MaxVersion)
{
versionTmp = v;
}
}
if (versionTmp > 0)
{
serverVersion = versionTmp.ToString();
return "{\"code\":200,\"msg\":\"success\",\"next_version\":" + serverVersion + ",\"exe_check\":\"" + UpdateExeChk +
"\",\"exe_address\":\"" + UpdateExe + "\",\"file_address\":\"" + UpdateNewUrl + "Update" + serverVersion + ".zip\"}";
}
}
if (path == "29pdd")
{
var file = Directory.GetFiles(fileDir);
var versionTmp = 0;
foreach (var f in file)
{
var v = Path.GetFileName(f).Replace("Update29pdd", "").Replace(".zip", "").ParseToInt();
if (v > versionTmp && v <= serverVersion.ParseToInt() && v <= MaxVersion)
{
versionTmp = v;
}
}
if (versionTmp > 0)
{
serverVersion = versionTmp.ToString();
return "{\"code\":200,\"msg\":\"success\",\"next_version\":" + serverVersion + ",\"exe_check\":\"" + UpdateExeChk +
"\",\"exe_address\":\"" + UpdateExe + "\",\"file_address\":\"" + UpdateNewUrl + "Update" + serverVersion + ".zip\"}";
}
}
}
catch (Exception ex)
{
//return "{\"code\":500,\"msg\":\"升级文件查询失败\"}";
}
}
if (serverVersion.ParseToInt() > MaxVersion)
serverVersion = MaxVersion.ParseToString();
return "{\"code\":200,\"msg\":\"success\",\"next_version\":" + serverVersion + ",\"exe_check\":\"" + UpdateExeChk +
"\",\"exe_address\":\"" + UpdateExe + "\",\"file_address\":\"" + UpdateNewUrl + "Update" + serverVersion + ".zip\"}";
}
else if (version > 0)
{
return "{\"code\":501,\"msg\":\"版本过低已无法直接升级,请联系管理员获取最新安装包\"}";
}
else
{
return "{\"code\":502,\"msg\":\"get update version failed\"}";
}
}
return "{\"code\":19999,\"msg\":\"未知错误\"}";
}
public string GetWxFindOrderUpdate(string inputData)
{
//string time1 = Encryption(time);
//return "time=" + time + "&code=" + time1 + "&NbCodeVersion=1" + "&version=" + BaseClass.VersionCount
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\":\"校验失败\"}";
var path = RegexUtils.GetStringQuery(ref inputData, "path");
var version = RegexUtils.GetStringQuery(ref inputData, "version").ParseToInt();
var serverVersion = Config("UpdateVersion");
var UpdateFileNewUrl = Config("UpdateWxFindOrderUrl");
var UpdateExe = Config("UpdateExe");
var UpdateExeChk = Config("UpdateExeChk");
var LowVersion = Config("WxFindOrderLowVersion");
if (version > LowVersion.ParseToInt())
{
//if (path != null)
{
try
{
var fileDir = Config("UpdateWxFindOrderFileDir");
//if (path == "29wx")
{
var file = Directory.GetFiles(fileDir);
var versionTmp = 0;
foreach (var f in file)
{
var v = Path.GetFileName(f).Replace("WxFindOrderUpdate", "").Replace(".zip", "").ParseToInt();
if (v > versionTmp && v <= serverVersion.ParseToInt())
{
versionTmp = v;
}
}
if (versionTmp > 0)
{
serverVersion = versionTmp.ToString();
return "{\"code\":200,\"msg\":\"success\",\"next_version\":" + serverVersion + ",\"exe_check\":\"" + UpdateExeChk +
"\",\"exe_address\":\"" + UpdateExe + "\",\"file_address\":\"" + UpdateFileNewUrl + "WxFindOrderUpdate" + serverVersion + ".zip\"}";
}
}
}
catch (Exception ex)
{
//return "{\"code\":500,\"msg\":\"升级文件查询失败\"}";
}
}
if (serverVersion.ParseToInt() > 1159)
serverVersion = 1159.ToString();
return "{\"code\":200,\"msg\":\"success\",\"next_version\":" + serverVersion + ",\"exe_check\":\"" + UpdateExeChk +
"\",\"exe_address\":\"" + UpdateExe + "\",\"file_address\":\"" + UpdateFileNewUrl + "WxFindOrderUpdate" + serverVersion + ".zip\"}";
}
else if (version > 0)
{
return "{\"code\":501,\"msg\":\"版本过低已无法直接升级,请联系管理员获取最新安装包\"}";
}
else
{
return "{\"code\":502,\"msg\":\"get update version failed\"}";
}
}
return "{\"code\":19999,\"msg\":\"未知错误\"}";
}
}
}
@@ -0,0 +1,555 @@
using StoreHub.KJDWebService.Models;
using StoreHub.Framework.Repositorys;
using Microsoft.Extensions.Configuration;
using StoreHub.KJDWebService.Commons;
using NaiBa.Util.Extension;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Net;
using System.Reflection;
namespace StoreHub.KJDWebService.Services
{
public class UserService : ServiceBase
{
public UserService(SqlRepository sqlRepository, IConfiguration configuration) : base(sqlRepository, configuration)
{
}
public string CheckUserLogin(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
var mobile = RegexUtils.GetStringQuery(ref inputData, "mobile")?.Replace("'", "\\'");
var password = RegexUtils.GetStringQuery(ref inputData, "password")?.Replace("'", "\\'");
int r2 = 0;
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "select * from kjd.user where user_name='"
+ mobile + "' and password='" + password + "'";
var dt = mySql.ExecuteDataTable(sql);
mySql.Close();
if (dt != null)
{
foreach (DataRow row in dt.Rows)
{
UserLoginResultParam user = new UserLoginResultParam
{
id = Convert.ToInt32(row["id"]),
user_name = row["user_name"].ToString(),
nick_name = row["nick_name"].ToString(),
mobile = row["user_name"].ToString(),
password = row["password"].ToString(),
group_id = row["group_id"].ToString(),
card_id = row["card_id"].ToString(),
company_name = row["company_name"].ToString(),
is_sa = row.Table.Columns.Contains("is_sa") ? row["is_sa"].ParseToInt() : 0,
sa_level = row.Table.Columns.Contains("sa_level") ? row["sa_level"].ParseToInt() : 0,
authorized_amount = row.Table.Columns.Contains("authorized_amount") ? row["authorized_amount"].ParseToInt() : 0,
authority = row.Table.Columns.Contains("authority") ? row["authority"].ParseToString() : "",
forbidden_page = row.Table.Columns.Contains("forbidden_page") ? row["forbidden_page"].ParseToString() : "",
};
if (string.IsNullOrEmpty(user.company_name))
{
user.company_name = "-";
}
var data = JsonUtils.SerializeObjectToString(user);
return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"c\":\"" + EncrypUtil.Encryption(r2) + "\"}";
}
return "{\"code\":1,\"msg\":\"用户名或密码错误\"}";
}
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string AddSubUser(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
var parent_user_name = RegexUtils.GetStringQuery(ref inputData, "user_name")?.Replace("'", "\\'");
var nick_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sub_nick_name"))?.Replace("'", "\\'");
var user_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sub_name"))?.Replace("'", "\\'");
var mobile = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sub_mobile"))?.Replace("'", "\\'");
var password = RegexUtils.GetStringQuery(ref inputData, "sub_password")?.Replace("'", "\\'");
var group_id = RegexUtils.GetStringQuery(ref inputData, "group_id")?.Replace("'", "\\'");
var card_id = RegexUtils.GetStringQuery(ref inputData, "card_id")?.Replace("'", "\\'");
var company_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "company"))?.Replace("'", "\\'");
var notes = RegexUtils.GetStringQuery(ref inputData, "notes")?.Replace("'", "\\'");
var authority = RegexUtils.GetStringQuery(ref inputData, "authority")?.Replace("'", "\\'");
var forbidden_page = RegexUtils.GetStringQuery(ref inputData, "forbidden_page")?.Replace("'", "\\'");
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "";
sql = "select exists (select 1 from kjd.user where user_name='" + user_name + "')";
var exist = mySql.ExecuteFirstInt(sql);
if (exist > 0)
{
mySql.Close();
return "{\"code\":500,\"msg\":\"用户名已存在\"}";
}
sql = "insert into kjd.user (nick_name,user_name,mobile,password,card_id,group_id,company_name,notes,parent_user_name,authority,forbidden_page,add_time,mdy_time) " +
"values ('" + nick_name + "','" + user_name + "','" + mobile + "','" + password + "','" + card_id + "','" +
group_id + "','" + company_name + "','" + notes + "','" + parent_user_name + "','" + authority + "','" + forbidden_page + "','" +
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','" +
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "');";
var rst = mySql.ExecuteNonQuery(sql);
mySql.Close();
if (!rst)
return "{\"code\":501,\"msg\":\""+ mySql.Message + "\"}";
else
return "{\"code\":200,\"msg\":\"子账户创建成功!\"}";
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string GetSubUser(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
var password = RegexUtils.GetStringQuery(ref inputData, "password");
var group = RegexUtils.GetStringQuery(ref inputData, "group");
int r2 = 0;
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "select * from kjd.user where parent_user_name='"
+ user_name + "'";
var dt = mySql.ExecuteDataTable(sql);
mySql.Close();
if (dt != null)
{
List<UserLoginResultParam> userList = new List<UserLoginResultParam>();
foreach (DataRow row in dt.Rows)
{
UserLoginResultParam user = new UserLoginResultParam
{
id = Convert.ToInt32(row["id"]),
user_name = row["user_name"].ToString(),
nick_name = row["nick_name"].ToString(),
mobile = row["mobile"].ToString(),
password = row["password"].ToString(),
group_id = row["group_id"].ToString(),
card_id = row["card_id"].ToString(),
parent_user_name = row["parent_user_name"].ToString(),
company_name = row["company_name"].ToString(),
notes = row["notes"].ToString(),
authority = row.Table.Columns.Contains("authority") ? row["authority"].ParseToString() : "",
forbidden_page = row.Table.Columns.Contains("forbidden_page") ? row["forbidden_page"].ParseToString() : "",
};
if (string.IsNullOrEmpty(user.mobile))
{
user.mobile = row["user_name"].ToString();
}
userList.Add(user);
}
var data = JsonUtils.SerializeObjectToString(userList);
return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"c\":\"" + EncrypUtil.Encryption(r2) + "\"}";
}
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string UpdateSubUser(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
var id = RegexUtils.GetStringQuery(ref inputData, "id")?.Replace("'", "\\'");
var parent_user_name = RegexUtils.GetStringQuery(ref inputData, "user_name")?.Replace("'", "\\'");
var nick_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sub_nick_name"))?.Replace("'", "\\'");
var user_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sub_name"))?.Replace("'", "\\'");
var mobile = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sub_mobile"))?.Replace("'", "\\'");
var password = RegexUtils.GetStringQuery(ref inputData, "sub_password")?.Replace("'", "\\'");
var group_id = RegexUtils.GetStringQuery(ref inputData, "group_id")?.Replace("'", "\\'");
var card_id = RegexUtils.GetStringQuery(ref inputData, "card_id")?.Replace("'", "\\'");
var notes = RegexUtils.GetStringQuery(ref inputData, "notes")?.Replace("'", "\\'");
var authority = RegexUtils.GetStringQuery(ref inputData, "authority")?.Replace("'", "\\'");
var forbidden_page = RegexUtils.GetStringQuery(ref inputData, "forbidden_page")?.Replace("'", "\\'");
int r2 = 0;
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "";
//sql = "select * from kjd.user where parent_user_name='"
// + user_name + "'";
sql = "update kjd.user set";
if (!string.IsNullOrEmpty(nick_name))
sql += " nick_name='" + nick_name + "',";
if (!string.IsNullOrEmpty(user_name))
sql += " user_name='" + user_name + "',";
if (!string.IsNullOrEmpty(mobile))
sql += " mobile='" + mobile + "',";
if (!string.IsNullOrEmpty(password))
sql += " password='" + password + "',";
if (!string.IsNullOrEmpty(group_id))
sql += " group_id=" + group_id + ",";
if (!string.IsNullOrEmpty(card_id))
sql += " card_id='" + card_id + "',";
if (!string.IsNullOrEmpty(notes))
sql += " notes='" + notes + "',";
if (!string.IsNullOrEmpty(authority))
sql += " authority='" + authority + "',";
if (!string.IsNullOrEmpty(forbidden_page))
sql += " forbidden_page='" + forbidden_page + "',";
sql = sql.TrimEnd(',');
sql += " where id=" + id + "";
var rst = mySql.ExecuteNonQuery(sql);
mySql.Close();
if (rst)
{
return "{\"code\":200,\"msg\":\"success\"}";
}
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string DelUser(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
var id = RegexUtils.GetStringQuery(ref inputData, "id");
int r2 = 0;
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "delete from kjd.user where id='"
+ id + "'";
var rst = mySql.ExecuteNonQuery(sql);
mySql.Close();
if (rst)
{
return "{\"code\":200,\"msg\":\"success\"}";
}
else
return "{\"code\":500,\"msg\":\"删除失败,请稍后重试\"}";
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string GetAllUser(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name")?.Replace("'", "\\'");
var password = RegexUtils.GetStringQuery(ref inputData, "password")?.Replace("'", "\\'");
var group_id = RegexUtils.GetStringQuery(ref inputData, "group_id")?.Replace("'", "\\'");
var search = RegexUtils.GetStringQuery(ref inputData, "search")?.Replace("'", "\\'");
var sa_level = RegexUtils.GetStringQuery(ref inputData, "sa_level")?.Replace("'", "\\'");
var user_name_in = RegexUtils.GetStringQuery(ref inputData, "user_name_in")?.Replace("'", "\\'");
int r2 = 0;
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
//string sql = "select * from kjd.user where group_id=3";
string sql = "select * from kjd.user where 1=1";
if (!string.IsNullOrEmpty(group_id))
sql += " and group_id=" + group_id;
if (!string.IsNullOrEmpty(sa_level))
sql += " and sa_level=" + sa_level;
if (!string.IsNullOrEmpty(user_name_in))
sql += " AND user_name IN(" + user_name_in + ")";
if (!string.IsNullOrEmpty(search))
sql += " and (user_name like '%" + search +
"%' or nick_name like '%" + search +
"%' or company_name like '%" + search + "%')";
sql += " order by id desc";
var dt = mySql.ExecuteDataTable(sql);
mySql.Close();
if (dt != null)
{
List<UserLoginResultParam> userList = new List<UserLoginResultParam>();
foreach (DataRow row in dt.Rows)
{
UserLoginResultParam user = new UserLoginResultParam
{
id = Convert.ToInt32(row["id"]),
user_name = row["user_name"].ToString(),
nick_name = row["nick_name"].ToString(),
mobile = row["mobile"].ToString(),
password = row["password"].ToString(),
group_id = row["group_id"].ToString(),
card_id = row["card_id"].ToString(),
parent_user_name = row["parent_user_name"].ToString(),
company_name = row["company_name"].ToString(),
notes = row["notes"].ToString(),
is_sa = row.Table.Columns.Contains("is_sa") ? row["is_sa"].ParseToInt() : 0,
sa_level = row.Table.Columns.Contains("sa_level") ? row["sa_level"].ParseToInt() : 0,
authorized_amount = row.Table.Columns.Contains("authorized_amount") ? row["authorized_amount"].ParseToInt() : 0,
authority = row.Table.Columns.Contains("authority") ? row["authority"].ParseToString() : "",
forbidden_page = row.Table.Columns.Contains("forbidden_page") ? row["forbidden_page"].ParseToString() : "",
};
if (string.IsNullOrEmpty(user.mobile))
{
user.mobile = row["user_name"].ToString();
}
userList.Add(user);
}
var data = JsonUtils.SerializeObjectToString(userList);
return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"c\":\"" + EncrypUtil.Encryption(r2) + "\"}";
}
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string AddUser(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
var nick_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "add_nick_name"))?.Replace("'", "\\'");
var user_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "add_user_name"))?.Replace("'", "\\'");
var mobile = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "add_mobile"))?.Replace("'", "\\'");
var password = RegexUtils.GetStringQuery(ref inputData, "add_password")?.Replace("'", "\\'");
var company_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "add_company"))?.Replace("'", "\\'");
var group_id = RegexUtils.GetStringQuery(ref inputData, "group_id")?.Replace("'", "\\'"); ;
var card_id = RegexUtils.GetStringQuery(ref inputData, "card_id")?.Replace("'", "\\'");
var notes = RegexUtils.GetStringQuery(ref inputData, "notes")?.Replace("'", "\\'");
var sa_level = RegexUtils.GetStringQuery(ref inputData, "sa_level")?.Replace("'", "\\'");
var authorized_amount = RegexUtils.GetStringQuery(ref inputData, "authorized_amount")?.Replace("'", "\\'");
var authority = RegexUtils.GetStringQuery(ref inputData, "authority")?.Replace("'", "\\'");
var forbidden_page = RegexUtils.GetStringQuery(ref inputData, "forbidden_page")?.Replace("'", "\\'");
int r2 = 0;
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "";
sql = "select exists (select 1 from kjd.user where user_name='" + user_name + "')";
var exist = mySql.ExecuteFirstInt(sql);
if (exist > 0)
{
mySql.Close();
return "{\"code\":500,\"msg\":\"用户名已存在\"}";
}
sql = "insert into kjd.user (nick_name,user_name,mobile,password,card_id,group_id,company_name,notes,sa_level," +
"authorized_amount,authority,forbidden_page,add_time,mdy_time) " +
"values ('" + nick_name + "','" + user_name + "','" + mobile + "','" + password + "','" + card_id + "','" +
group_id + "','" + company_name + "','" + notes + "'," + sa_level + "," + authorized_amount + ",'" + authority + "','" + forbidden_page + "','" +
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','" +
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "');";
var rst = mySql.ExecuteNonQuery(sql);
mySql.Close();
if (!rst)
return "{\"code\":501,\"msg\":\"" + mySql.Message + "\"}";
else
return "{\"code\":200,\"msg\":\"success\"}";
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string UpdateUser(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
var id = RegexUtils.GetStringQuery(ref inputData, "id")?.Replace("'", "\\'");
var nick_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "add_nick_name"))?.Replace("'", "\\'");
var user_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "add_user_name"))?.Replace("'", "\\'");
var mobile = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "add_mobile"))?.Replace("'", "\\'");
var company_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "add_company"))?.Replace("'", "\\'");
var password = RegexUtils.GetStringQuery(ref inputData, "add_password")?.Replace("'", "\\'");
var group_id = RegexUtils.GetStringQuery(ref inputData, "group_id")?.Replace("'", "\\'");
var card_id = RegexUtils.GetStringQuery(ref inputData, "card_id")?.Replace("'", "\\'");
var notes = RegexUtils.GetStringQuery(ref inputData, "notes")?.Replace("'", "\\'");
var sa_level = RegexUtils.GetStringQuery(ref inputData, "sa_level")?.Replace("'", "\\'");
var authorized_amount = RegexUtils.GetStringQuery(ref inputData, "authorized_amount")?.Replace("'", "\\'");
var authority = RegexUtils.GetStringQuery(ref inputData, "authority")?.Replace("'", "\\'");
var forbidden_page = RegexUtils.GetStringQuery(ref inputData, "forbidden_page")?.Replace("'", "\\'");
int r2 = 0;
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "";
//sql = "select * from kjd.user where parent_user_name='"
// + user_name + "'";
sql = "update kjd.user set";
if (!string.IsNullOrEmpty(nick_name))
sql += " nick_name='" + nick_name + "',";
if (!string.IsNullOrEmpty(user_name))
sql += " user_name='" + user_name + "',";
if (!string.IsNullOrEmpty(mobile))
sql += " mobile='" + mobile + "',";
if (!string.IsNullOrEmpty(company_name))
sql += " company_name='" + company_name + "',";
if (!string.IsNullOrEmpty(password))
sql += " password='" + password + "',";
if (!string.IsNullOrEmpty(group_id))
sql += " group_id=" + group_id + ",";
if (!string.IsNullOrEmpty(card_id))
sql += " card_id='" + card_id + "',";
if (!string.IsNullOrEmpty(notes))
sql += " notes='" + notes + "',";
if (!string.IsNullOrEmpty(sa_level))
sql += " sa_level=" + sa_level + ",";
if (!string.IsNullOrEmpty(authorized_amount))
sql += " authorized_amount=" + authorized_amount + ",";
if (authority != null)
sql += " authority='" + authority + "',";
if (forbidden_page != null)
sql += " forbidden_page='" + forbidden_page + "',";
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 ChangePassword(string inputData)
{
var userName = RegexUtils.GetStringJson(ref inputData, "user_name")?.Replace("'", "\\'");
var password = RegexUtils.GetStringJson(ref inputData, "password")?.Replace("'", "\\'");
var newPassword = RegexUtils.GetStringJson(ref inputData, "new_password")?.Replace("'", "\\'");
string conn = "Conn";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "select user_id,password from pepdtp.user where user_id='"
+ userName + "' and password='" + password + "'";
var dw = mySql.ExecuteDataTableRow(sql);
if (dw != null)
{
UserLoginResultParam user = new UserLoginResultParam
{
user_name = dw["user_id"].ToString(),
password = dw["password"].ToString(),
};
sql = "update pepdtp.user set password = '" + newPassword + "' where user_id='" + userName + "'";
var result = mySql.ExecuteNonQuery(sql);
mySql.Close();
if (result)
{
return "{\"code\":0,\"msg\":\"密码修改成功!\"}";
}
else
return "{\"code\":19999,\"msg\":\"密码修改失败!请稍后再试。\"}";
}
else
{
mySql.Close();
return "{\"code\":1,\"msg\":\"原密码错误。\"}";
}
}
public string GetUserAmount(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\":\"校验失败\"}";
var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name")?.Replace("'", "\\'");
if (string.IsNullOrEmpty(user_name))
{
return "{\"code\":500,\"msg\":\"请输入用户\"}";
}
var password = RegexUtils.GetStringQuery(ref inputData, "password")?.Replace("'", "\\'");
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "select authorized_amount from kjd.user where user_name=" + user_name;
var rst = mySql.ExecuteFirst(sql);
mySql.Close();
if (!string.IsNullOrEmpty(rst))
{
return "{\"code\":200,\"msg\":\"success\",\"data\":" + rst + "}";
}
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string return_package_secret_key { get; set; } = "aaMETt2bPe6YHzZ1ojbC+6wOvgtwehqc6A+/Rz+pCUU=";
public string GetPackageSign(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
var mobile = RegexUtils.GetStringQuery(ref inputData, "mobile")?.Replace("'", "\\'");
var password = RegexUtils.GetStringQuery(ref inputData, "password")?.Replace("'", "\\'");
var timestamp = RegexUtils.GetStringQuery(ref inputData, "timestamp")?.Replace("'", "\\'");
var mallId = RegexUtils.GetStringQuery(ref inputData, "mallId")?.Replace("'", "\\'");
var returnPackageNo = RegexUtils.GetStringQuery(ref inputData, "returnPackageNo")?.Replace("'", "\\'");
int r2 = RegexUtils.GetStringQuery(ref inputData, "r2").ParseToInt();
string c2 = RegexUtils.GetStringQuery(ref inputData, "c2");
if (EncrypUtil.Encryption(r2) != c2)
return "{\"code\":2,\"msg\":\"不合法的输入内容\"}";
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "select * from kjd.user where user_name='"
+ mobile + "' and password='" + password + "'";
sql = "select * from kjd.user where user_name='" + mobile + "'";
var dt = mySql.ExecuteDataTable(sql);
mySql.Close();
if (dt == null || dt.Rows.Count <=0)
{
return "{\"code\":1,\"msg\":\"用户不存在\"}";
}
string sign = EncrypUtil.GetMd5(timestamp + return_package_secret_key + mallId + returnPackageNo).ToLower();
return "{\"code\":200, \"sign\":\"" + sign + "\", \"msg\":\"\"}";
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string IsGetReturnPackage(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name")?.Replace("'", "\\'");
var password = RegexUtils.GetStringQuery(ref inputData, "password")?.Replace("'", "\\'");
int r2 = RegexUtils.GetStringQuery(ref inputData, "r2").ParseToInt();
string c2 = RegexUtils.GetStringQuery(ref inputData, "c2");
if (EncrypUtil.Encryption(r2) != c2)
return "{\"code\":2,\"msg\":\"不合法的输入内容\"}";
var isGetReturn = System.Configuration.ConfigurationManager.ConnectionStrings["GetReturnPackage"]?.ConnectionString;
return "{\"code\":200, \"is_get\":\"" + isGetReturn + "\"}";
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
}
}
@@ -0,0 +1,883 @@
using StoreHub.KJDWebService.Models.WxModel;
using StoreHub.KJDWebService.Commons;
using StoreHub.KJDWebService.Models;
using StoreHub.Framework.Repositorys;
using Microsoft.Extensions.Configuration;
using MySql.Data.MySqlClient;
using NaiBa.Util.Extension;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
namespace StoreHub.KJDWebService.Services
{
public class WXExpressOptimizeService : ServiceBase
{
public WXExpressOptimizeService(SqlRepository sqlRepository, IConfiguration configuration) : base(sqlRepository, configuration)
{
}
public string GetWayBill(string inputData, bool isNoUserName = false)
{
if (!string.IsNullOrEmpty(inputData))
{
var timeCalc = DateTime.Now;
if (!WXUserService.GetSign(inputData))
return "{\"code\":999,\"msg\":\"校验失败\"}";
//var delivery_id = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "delivery_id"))?.Replace("'", "\\'");
//var delivery_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "delivery_name"))?.Replace("'", "\\'");
//var waybill_id = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "waybill_id"))?.Replace("'", "\\'");
//if (string.IsNullOrEmpty(delivery_id) || string.IsNullOrEmpty(delivery_name) || string.IsNullOrEmpty(waybill_id))
//{
// return "{\"code\":500,\"msg\":\"运单号信息不完整\"}";
//}
var status = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "status"))?.Replace("'", "\'");
var order_ids = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "order_ids"))?.Replace("'", "\'");
var user_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "user_name"))?.Replace("'", "\'");
if (!isNoUserName && user_name.IsNullOrEmpty())
{
return "{\"code\":500,\"msg\":\"用户名不能为空\"}";
}
if (isNoUserName && order_ids.IsNullOrEmpty())
{
return "{\"code\":500,\"msg\":\"订单号不能为空\"}";
}
int page = RegexUtils.GetStringQuery(ref inputData, "page").ParseToInt();
int page_size = RegexUtils.GetStringQuery(ref inputData, "page_size").ParseToInt(50);
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "";
//string tableName = "wxxd.express_optimize";
//sql = "select exists (SELECT table_name FROM information_schema.tables WHERE table_schema = 'wxxd' AND table_name = 'express_optimize')";
//var existTable = mySql.ExecuteFirstInt(sql);
//if (existTable == 0)
// sql = "select count(*) from wxxd.express_optimize where 1=1";
//else
sql = "select count(*) from wxxd.express_optimize where 1=1";
string where = "";
if (!isNoUserName)
where += " AND user_name='" + user_name + "'";
if (status != null)
where += " AND status in (" + status + ")";
if (order_ids != null)
where += " AND order_id in ('" + order_ids.Replace(",", "','") + "')";
sql += where;
var count = 0;
count = mySql.ExecuteRowCount(sql);
DataTable dt;
if (count == 0)
{
dt = new DataTable();
}
else
{
sql = "select * from wxxd.express_optimize 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 (!string.IsNullOrEmpty(mySql.Message))
return "{\"code\":501,\"msg\":\"" + mySql.Message + "\"}";
if (dt != null)
{
try
{
List<WxOptimizeExpressInfo> WxOptimizeExpressInfoLst = new List<WxOptimizeExpressInfo>();
foreach (DataRow row in dt.Rows)
{
WxOptimizeExpressInfoLst.Add(new WxOptimizeExpressInfo()
{
id = row["id"].ParseToInt(),
delivery_id = row["delivery_id"].ParseToString(),
delivery_name = row["delivery_name"].ParseToString(),
order_id = row["order_id"].ParseToString(),
bind_order_id = row["bind_order_id"].ParseToString(),
shop_id = row["shop_id"].ParseToString(),
status = row["status"].ParseToInt(),
waybill_id = row["waybill_id"].ParseToString(),
add_time = Convert.ToDateTime(row["add_time"]),
use_time = row["use_time"].ParseToString().ParseToDateTimeNullable(),
waybill_pickup_time = row["waybill_pickup_time"].ParseToString().ParseToDateTimeNullable(),
});
}
JsonSerializerSettings jsonSetting = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore };
var data = JsonUtils.SerializeObjectToString(WxOptimizeExpressInfoLst, 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\":\"输入为空\"}";
}
/// <summary>
/// 添加运单
/// </summary>
/// <param name="inputData"></param>
/// <returns></returns>
public string AddWaybill(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
if (!WXUserService.GetSign(inputData))
return "{\"code\":999,\"msg\":\"校验失败\"}";
var delivery_id = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "delivery_id"))?.Replace("'", "\\'");
var delivery_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "delivery_name"))?.Replace("'", "\\'");
var waybill_id = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "waybill_id"))?.Replace("'", "\\'");
var bind_order_id = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "bind_order_id"))?.Replace("'", "\\'");
var waybill_pickup_time = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "waybill_pickup_time")).ParseToDateTimeNullable();
if (string.IsNullOrEmpty(delivery_id) || string.IsNullOrEmpty(delivery_name) || string.IsNullOrEmpty(waybill_id))
{
return "{\"code\":500,\"msg\":\"运单号信息不完整\"}";
}
if (waybill_pickup_time == null && bind_order_id.IsNullOrEmpty())
{
return "{\"code\":500,\"msg\":\"揽收时间和绑定订单编号不能同时为空\"}";
}
var user_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "user_name"))?.ParseToString();
if (user_name.IsNullOrEmpty())
{
return "{\"code\":500,\"msg\":\"请输入用户名\"}";
}
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "";
sql = "SELECT EXISTS (SELECT 1 FROM wxxd.express_optimize WHERE waybill_id='" + waybill_id + "')";
var exist = mySql.ExecuteFirstInt(sql);
if (!mySql.Message.IsNullOrEmpty())
{
mySql.Close();
return "{\"code\":501,\"msg\":\"" + mySql.Message + "\"}";
}
if (exist > 0)
{
mySql.Close();
return "{\"code\":500,\"msg\":\"运单号已存在\"}";
}
sql = "INSERT INTO wxxd.express_optimize (user_name,delivery_id,delivery_name,waybill_id,";
if (!bind_order_id.IsNullOrEmpty())
sql += "bind_order_id,";
if (waybill_pickup_time != null)
sql += "waybill_pickup_time,";
sql = sql.Trim(',');
sql += ") VALUES ('" + user_name + "','" + delivery_id + "','" + delivery_name + "','" + waybill_id + "',";
if (!bind_order_id.IsNullOrEmpty())
sql += "'" + bind_order_id + "',";
if (waybill_pickup_time != null)
sql += "'" + waybill_pickup_time.Value.ToString("yyyy-MM-dd HH:mm:ss") + "',";
sql = sql.Trim(',');
sql += ");";
var rst = mySql.ExecuteNonQuery(sql);
mySql.Close();
if (!rst)
return "{\"code\":501,\"msg\":\"" + mySql.Message + "\"}";
else
return "{\"code\":200,\"msg\":\"success\"}";
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string DelWaybill(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
if (!WXUserService.GetSign(inputData))
return "{\"code\":999,\"msg\":\"校验失败\"}";
var waybill_ids = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "waybill_ids"))?.Replace("'", "\\'");
if (string.IsNullOrEmpty(waybill_ids))
{
return "{\"code\":500,\"msg\":\"运单号信息不完整\"}";
}
var user_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "user_name"))?.ParseToString();
if (user_name.IsNullOrEmpty())
{
return "{\"code\":500,\"msg\":\"请输入用户名\"}";
}
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "";
sql = "DELETE FROM wxxd.express_optimize WHERE waybill_id in ('" + waybill_ids.Replace(",", "','") + "') and status=0";
var rst = mySql.ExecuteNonQuery(sql);
mySql.Close();
if (!rst || !mySql.Message.IsNullOrEmpty())
return "{\"code\":501,\"msg\":\"删除失败 " + mySql.Message + "\"}";
else
return "{\"code\":200,\"msg\":\"success\"}";
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
/// <summary>
/// 选择并使用运单
/// </summary>
/// <param name="inputData"></param>
/// <returns></returns>
public string SelectAndSetWaybill(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
if (!WXUserService.GetSign(inputData))
return "{\"code\":999,\"msg\":\"校验失败\"}";
var user_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "user_name"))?.ParseToString();
if (user_name.IsNullOrEmpty())
{
return "{\"code\":500,\"msg\":\"请输入用户名\"}";
}
var shop_id = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "shop_id"))?.Replace("'", "\\'");
var order_id = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "order_id"))?.Replace("'", "\\'");
if (string.IsNullOrEmpty(order_id) || string.IsNullOrEmpty(shop_id))
{
return "{\"code\":500,\"msg\":\"缺少订单信息\"}";
}
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn, true);
string sql = "";
sql = "select * from wxxd.express_optimize where order_id='" + order_id + "' and status = 1";
var dt = mySql.ExecuteDataTable(sql);
if (!mySql.Message.IsNullOrEmpty())
{
mySql.RollBack();
mySql.Close();
return "{\"code\":501,\"msg\":\"物流信息查询失败 " + mySql.Message + "\"}";
}
if (dt?.Rows?.Count == 0)
{
sql = "UPDATE wxxd.express_optimize SET order_id='" + order_id + "',status=1 WHERE user_name='" + user_name +
"' AND status=0 AND (order_id IS NULL OR order_id='') LIMIT 1";
var cnt = mySql.ExecuteAffectedRows(sql);
if (cnt == 0 || !mySql.Message.IsNullOrEmpty())
{
mySql.RollBack();
mySql.Close();
return "{\"code\":501,\"msg\":\"物流信息提取失败 " + mySql.Message + "\"}";
}
sql = "SELECT * FROM wxxd.express_optimize WHERE user_name='" + user_name + "' AND order_id='" + order_id + "' AND status = 1";
dt = mySql.ExecuteDataTable(sql);
if (!mySql.Message.IsNullOrEmpty())
{
mySql.RollBack();
mySql.Close();
return "{\"code\":501,\"msg\":\"物流信息提取失败 " + mySql.Message + "\"}";
}
if (dt?.Rows?.Count == 0)
{
mySql.RollBack();
mySql.Close();
return "{\"code\":501,\"msg\":\"物流信息提取失败 " + mySql.Message + "\"}";
}
}
var waybill_id = dt.Rows[0]["waybill_id"].ToString();
// todo E57调用接口处理
mySql.Close();
mySql = new MysqlUtils(conn, true);
sql = " UPDATE wxxd.express_optimize SET shop_id='" + shop_id + "',status=2,use_time='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' " +
" WHERE user_name='" + user_name + "' AND status=1 AND order_id='" + order_id + "' AND waybill_id='" + waybill_id + "'";
var rst = mySql.ExecuteAffectedRows(sql);
if (rst == 0 || !mySql.Message.IsNullOrEmpty())
{
mySql.RollBack();
mySql.Close();
return "{\"code\":501,\"msg\":\"修改物流信息失败 " + mySql.Message + "\"}";
}
else
{
mySql.Commit();
mySql.Close();
return "{\"code\":200,\"msg\":\"success\"}";
}
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string SelectWaybill(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
if (!WXUserService.GetSign(inputData))
return "{\"code\":999,\"msg\":\"校验失败\"}";
var user_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "user_name"))?.ParseToString();
if (user_name.IsNullOrEmpty())
{
return "{\"code\":500,\"msg\":\"请输入用户名\"}";
}
var shop_id = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "shop_id"))?.Replace("'", "\\'");
var order_id = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "order_id"))?.Replace("'", "\\'");
var order_time = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "order_time")).ParseToDateTimeNullable();
if (string.IsNullOrEmpty(order_id) || string.IsNullOrEmpty(shop_id))
{
return "{\"code\":500,\"msg\":\"缺少订单信息\"}";
}
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn, true);
try
{
string sql = "";
sql = "select * from wxxd.express_optimize WHERE user_name='" + user_name + "' AND order_id='" + order_id + "' and status = 1 LIMIT 1";
var dt = mySql.ExecuteDataTable(sql);
if (!mySql.Message.IsNullOrEmpty())
{
mySql.RollBack();
mySql.Close();
return "{\"code\":501,\"msg\":\"物流查询失败 " + mySql.Message + "\"}";
}
if (dt?.Rows?.Count == 0)
{
// 获取事先绑定的订单运单
sql = " UPDATE wxxd.express_optimize SET order_id='" + order_id + "',status=1" +
" WHERE user_name='" + user_name + "' AND status=0 AND bind_order_id='" + order_id + "'" +
" ORDER BY RAND() LIMIT 1";
var cnt = mySql.ExecuteAffectedRows(sql);
if (!mySql.Message.IsNullOrEmpty())
{
mySql.RollBack();
mySql.Close();
return "{\"code\":501,\"msg\":\"物流提取失败 " + mySql.Message + "\"}";
}
// 根据订单时间提取指定时间段内的运单号
if (cnt == 0 && order_time != null)
{
// 第一天的订单用第二天的物流发货
var start_time = order_time.Value.Date.AddHours(24).ToString("yyyy-MM-dd HH:mm:ss");
var end_time = order_time.Value.Date.AddHours(48).AddSeconds(-1).ToString("yyyy-MM-dd HH:mm:ss");
sql = " UPDATE wxxd.express_optimize SET order_id='" + order_id + "',status=1" +
" WHERE user_name='" + user_name + "' AND status=0 AND (order_id IS NULL OR order_id='') AND (bind_order_id IS NULL OR bind_order_id='')" +
" AND waybill_pickup_time between '" + start_time + "' and '" + end_time + "'" +
" ORDER BY RAND() LIMIT 1";
cnt = mySql.ExecuteAffectedRows(sql);
if (!mySql.Message.IsNullOrEmpty())
{
mySql.RollBack();
mySql.Close();
return "{\"code\":501,\"msg\":\"物流提取失败 " + mySql.Message + "\"}";
}
}
// 挑选最早入库的运单号
//if (cnt == 0 && order_time == null)
//{
// sql = " UPDATE wxxd.express_optimize SET order_id='" + order_id + "',status=1" +
// " WHERE user_name='" + user_name + "' AND status=0 AND (order_id IS NULL OR order_id='') AND (bind_order_id IS NULL OR bind_order_id='')" +
// " LIMIT 1";
// cnt = mySql.ExecuteAffectedRows(sql);
// if (!mySql.Message.IsNullOrEmpty())
// {
// mySql.RollBack();
// mySql.Close();
// return "{\"code\":501,\"msg\":\"物流提取失败 " + mySql.Message + "\"}";
// }
//}
if (cnt == 0)
{
mySql.RollBack();
mySql.Close();
return "{\"code\":501,\"msg\":\"没有可用的运单号\"}";
}
sql = "SELECT * FROM wxxd.express_optimize WHERE user_name='" + user_name + "' AND order_id='" + order_id + "' AND status = 1";
dt = mySql.ExecuteDataTable(sql);
if (!mySql.Message.IsNullOrEmpty())
{
mySql.RollBack();
mySql.Close();
return "{\"code\":501,\"msg\":\"物流提取失败 " + mySql.Message + "\"}";
}
if (dt?.Rows?.Count == 0)
{
mySql.RollBack();
mySql.Close();
return "{\"code\":501,\"msg\":\"物流提取失败 " + mySql.Message + "\"}";
}
}
var waybill_id = dt.Rows[0]["waybill_id"].ToString();
var delivery_id = dt.Rows[0]["delivery_id"].ParseToString();
var delivery_name = dt.Rows[0]["delivery_name"].ParseToString();
mySql.Commit();
mySql.Close();
return "{\"code\":200,\"msg\":\"success\",\"data\":{\"waybill_id\":\"" + waybill_id +
"\",\"delivery_id\":\"" + delivery_id + "\",\"delivery_name\":\"" + delivery_name + "\"}}";
}
catch (Exception ex)
{
mySql.RollBack();
mySql.Close();
return "{\"code\":501,\"msg\":\"物流提取失败 " + ex.Message + "\"}";
}
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string UpdateUsedWaybill(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
if (!WXUserService.GetSign(inputData))
return "{\"code\":999,\"msg\":\"校验失败\"}";
var user_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "user_name"))?.ParseToString();
if (user_name.IsNullOrEmpty())
{
return "{\"code\":500,\"msg\":\"请输入用户名\"}";
}
var shop_id = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "shop_id"))?.Replace("'", "\\'");
var order_id = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "order_id"))?.Replace("'", "\\'");
var waybill_id = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "waybill_id"))?.Replace("'", "\\'");
var is_rollback = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "is_rollback"))?.Replace("'", "\\'");
if (string.IsNullOrEmpty(order_id) || string.IsNullOrEmpty(shop_id) || string.IsNullOrEmpty(waybill_id))
{
return "{\"code\":500,\"msg\":\"缺少订单信息\"}";
}
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn, true);
var sql = " UPDATE wxxd.express_optimize SET shop_id='" + shop_id + "',status=2,use_time='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' " +
" WHERE user_name='" + user_name + "' AND status=1 AND order_id='" + order_id + "' AND waybill_id='" + waybill_id + "'";
if (is_rollback == "true")
sql = " UPDATE wxxd.express_optimize SET shop_id='',order_id='',status=0,use_time=NULL" +
" WHERE user_name='" + user_name + "' AND status=1 AND order_id='" + order_id + "' AND waybill_id='" + waybill_id + "'";
var rst = mySql.ExecuteAffectedRows(sql);
if (rst == 0 || !mySql.Message.IsNullOrEmpty())
{
mySql.RollBack();
mySql.Close();
return "{\"code\":501,\"msg\":\"修改物流信息失败 " + mySql.Message + "\"}";
}
// 记录修改结果,暂时注释
if (is_rollback != "true")
{
//var relation_id = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "relation_id"))?.Replace("'", "\\'");
//var optimize_rst = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "optimize_rst"))?.Replace("'", "\\'");
//var delivery_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "delivery_name"))?.Replace("'", "\\'");
//if (optimize_rst != null)
//{
// sql = "select exists (select 1 from wxxd.express_optimize where order_id='" + order_id + "')";
// var exist = mySql.ExecuteFirstInt(sql);
// if (exist > 0)
// {
// sql = " UPDATE wxxd.express_optimize_rst SET ";
// if (shop_id != null)
// sql += " shop_id=@shop_id,";
// if (relation_id != null)
// sql += " relation_id=@relation_id,";
// if (optimize_rst != null)
// sql += " optimize_rst=@optimize_rst,";
// if (waybill_id != null)
// sql += " waybill_id=@waybill_id,";
// if (delivery_name != null)
// sql += " delivery_name=@delivery_name,";
// sql = sql.TrimEnd(',');
// sql += " WHERE order_id=@order_id";
// }
// else
// {
// sql = " insert into wxxd.express_optimize_rst (shop_id,order_id,";
// if (relation_id != null)
// sql += "relation_id,";
// if (optimize_rst != null)
// sql += "optimize_rst,";
// if (waybill_id != null)
// sql += "waybill_id,";
// if (delivery_name != null)
// sql += "delivery_name,";
// sql = sql.TrimEnd(',');
// sql += ") ";
// sql += " values (@shop_id,@order_id,";
// if (relation_id != null)
// sql += "@relation_id,";
// if (optimize_rst != null)
// sql += "@optimize_rst,";
// if (waybill_id != null)
// sql += "@waybill_id,";
// if (delivery_name != null)
// sql += "@delivery_name,";
// sql = sql.TrimEnd(',');
// sql += ");";
// }
// List<MySqlParameter> paramLst = new List<MySqlParameter>();
// paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@shop_id", Value = shop_id, });
// paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@relation_id", Value = relation_id, });
// paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@optimize_rst", Value = optimize_rst, });
// paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@waybill_id", Value = waybill_id, });
// paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@delivery_name", Value = delivery_name, });
// paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@order_id", Value = order_id, });
// var rows = mySql.ExecuteAffectedRows(sql, paramLst.ToArray());
//}
}
mySql.Commit();
mySql.Close();
return "{\"code\":200,\"msg\":\"success\"}";
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string AddMdyExpressOptimizeRst(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
if (!WXUserService.GetSign(inputData))
return "{\"code\":999,\"msg\":\"校验失败\"}";
var shop_id = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "shop_id"))?.Replace("'", "\\'");
var order_id = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "order_id"))?.Replace("'", "\\'");
var optimize_rst = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "optimize_rst"))?.Replace("'", "\\'");
var waybill_id = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "waybill_id"))?.Replace("'", "\\'");
var delivery_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "delivery_name"))?.Replace("'", "\\'");
if (string.IsNullOrEmpty(order_id))
{
return "{\"code\":500,\"msg\":\"请输入订单编号\"}";
}
if (string.IsNullOrEmpty(optimize_rst))
{
return "{\"code\":500,\"msg\":\"请输入补发结果\"}";
}
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "";
sql = "select exists (select 1 from wxxd.express_optimize_rst where order_id='" + order_id + "')";
var exist = mySql.ExecuteFirstInt(sql);
if (!mySql.Message.IsNullOrEmpty())
{
mySql.Close();
return "{\"code\":501,\"msg\":\"" + mySql.Message + "\"}";
}
if (exist > 0)
{
sql = " UPDATE wxxd.express_optimize_rst SET ";
if (shop_id != null)
sql += " shop_id=@shop_id,";
if (optimize_rst != null)
sql += " optimize_rst=@optimize_rst,";
if (waybill_id != null)
sql += " waybill_id=@waybill_id,";
if (delivery_name != null)
sql += " delivery_name=@delivery_name,";
sql = sql.TrimEnd(',');
sql += " WHERE order_id=@order_id";
}
else
{
sql = " insert into wxxd.express_optimize_rst (shop_id,order_id,";
if (optimize_rst != null)
sql += "optimize_rst,";
if (waybill_id != null)
sql += "waybill_id,";
if (delivery_name != null)
sql += "delivery_name,";
sql = sql.TrimEnd(',');
sql += ") ";
sql += " values (@shop_id,@order_id,";
if (optimize_rst != null)
sql += "@optimize_rst,";
if (waybill_id != null)
sql += "@waybill_id,";
if (delivery_name != null)
sql += "@delivery_name,";
sql = sql.TrimEnd(',');
sql += ");";
}
List<MySqlParameter> paramLst = new List<MySqlParameter>();
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@shop_id", Value = shop_id, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@optimize_rst", Value = optimize_rst, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@waybill_id", Value = waybill_id, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@delivery_name", Value = delivery_name, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@order_id", Value = order_id, });
var rows = mySql.ExecuteAffectedRows(sql, paramLst.ToArray());
mySql.Close();
if (!mySql.Message.IsNullOrEmpty())
return "{\"code\":501,\"msg\":\"" + mySql.Message + "\"}";
else
return "{\"code\":200,\"msg\":\"success\",\"affected_rows\":" + rows + "}";
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string GetExpressOptimizeRst(string inputData, bool isNoUserName = false)
{
if (!string.IsNullOrEmpty(inputData))
{
var timeCalc = DateTime.Now;
if (!WXUserService.GetSign(inputData))
return "{\"code\":999,\"msg\":\"校验失败\"}";
var order_ids = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "order_ids"))?.Replace("'", "\'");
if (isNoUserName && order_ids.IsNullOrEmpty())
{
return "{\"code\":500,\"msg\":\"订单号不能为空\"}";
}
int page = RegexUtils.GetStringQuery(ref inputData, "page").ParseToInt();
int page_size = RegexUtils.GetStringQuery(ref inputData, "page_size").ParseToInt(200);
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "";
sql = "select count(*) from wxxd.express_optimize_rst where 1=1";
string where = "";
if (order_ids != null)
where += " AND order_id in ('" + order_ids.Replace(",", "','") + "')";
sql += where;
var count = 0;
count = mySql.ExecuteRowCount(sql);
DataTable dt;
if (count == 0)
{
dt = new DataTable();
}
else
{
sql = "select * from wxxd.express_optimize_rst 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 (!string.IsNullOrEmpty(mySql.Message))
return "{\"code\":501,\"msg\":\"" + mySql.Message + "\"}";
if (dt != null)
{
try
{
List<WxOptimizeRstInfo> WxOptimizeRstInfoLst = new List<WxOptimizeRstInfo>();
foreach (DataRow row in dt.Rows)
{
WxOptimizeRstInfoLst.Add(new WxOptimizeRstInfo()
{
id = row["id"].ParseToInt(),
waybill_id = row["waybill_id"].ParseToString(),
delivery_name = row["delivery_name"].ParseToString(),
order_id = row["order_id"].ParseToString(),
optimize_rst = row["optimize_rst"].ParseToString(),
shop_id = row["shop_id"].ParseToString(),
add_time = Convert.ToDateTime(row["add_time"]),
mdy_time = Convert.ToDateTime(row["mdy_time"]),
});
}
JsonSerializerSettings jsonSetting = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore };
var data = JsonUtils.SerializeObjectToString(WxOptimizeRstInfoLst, 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 AddMdyExpressOptimizeRemark(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
if (!WXUserService.GetSign(inputData))
return "{\"code\":999,\"msg\":\"校验失败\"}";
var shop_id = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "shop_id"))?.Replace("'", "\\'");
var order_id = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "order_id"))?.Replace("'", "\\'");
var remark = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "remark"))?.Replace("'", "\\'");
if (string.IsNullOrEmpty(order_id))
{
return "{\"code\":500,\"msg\":\"请输入订单编号\"}";
}
if (remark == null)
{
return "{\"code\":500,\"msg\":\"请输入备注内容\"}";
}
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "";
sql = "select exists (select 1 from wxxd.express_optimize_remark where order_id='" + order_id + "')";
var exist = mySql.ExecuteFirstInt(sql);
if (!mySql.Message.IsNullOrEmpty())
{
mySql.Close();
return "{\"code\":501,\"msg\":\"" + mySql.Message + "\"}";
}
if (exist > 0)
{
sql = " UPDATE wxxd.express_optimize_remark SET ";
if (shop_id != null)
sql += " shop_id=@shop_id,";
if (remark != null)
sql += " remark=@remark,";
sql = sql.TrimEnd(',');
sql += " WHERE order_id=@order_id";
}
else
{
sql = " insert into wxxd.express_optimize_remark (shop_id,order_id,";
if (remark != null)
sql += "remark,";
sql = sql.TrimEnd(',');
sql += ") ";
sql += " values (@shop_id,@order_id,";
if (remark != null)
sql += "@remark,";
sql = sql.TrimEnd(',');
sql += ");";
}
List<MySqlParameter> paramLst = new List<MySqlParameter>();
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@shop_id", Value = shop_id, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@remark", Value = remark, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@order_id", Value = order_id, });
var rows = mySql.ExecuteAffectedRows(sql, paramLst.ToArray());
mySql.Close();
if (!mySql.Message.IsNullOrEmpty())
return "{\"code\":501,\"msg\":\"" + mySql.Message + "\"}";
else
return "{\"code\":200,\"msg\":\"success\",\"affected_rows\":" + rows + "}";
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string GetExpressOptimizeRemark(string inputData, bool isNoUserName = false)
{
if (!string.IsNullOrEmpty(inputData))
{
var timeCalc = DateTime.Now;
if (!WXUserService.GetSign(inputData))
return "{\"code\":999,\"msg\":\"校验失败\"}";
var order_ids = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "order_ids"))?.Replace("'", "\'");
if (isNoUserName && order_ids.IsNullOrEmpty())
{
return "{\"code\":500,\"msg\":\"订单号不能为空\"}";
}
int page = RegexUtils.GetStringQuery(ref inputData, "page").ParseToInt();
int page_size = RegexUtils.GetStringQuery(ref inputData, "page_size").ParseToInt(200);
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "";
sql = "select count(*) from wxxd.express_optimize_remark where 1=1";
string where = "";
if (order_ids != null)
where += " AND order_id in ('" + order_ids.Replace(",", "','") + "')";
sql += where;
var count = 0;
count = mySql.ExecuteRowCount(sql);
DataTable dt;
if (count == 0)
{
dt = new DataTable();
}
else
{
sql = "select * from wxxd.express_optimize_remark 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 (!string.IsNullOrEmpty(mySql.Message))
return "{\"code\":501,\"msg\":\"" + mySql.Message + "\"}";
if (dt != null)
{
try
{
List<WxOptimizeRemarkInfo> WxOptimizeRemarkInfoLst = new List<WxOptimizeRemarkInfo>();
foreach (DataRow row in dt.Rows)
{
WxOptimizeRemarkInfoLst.Add(new WxOptimizeRemarkInfo()
{
id = row["id"].ParseToInt(),
order_id = row["order_id"].ParseToString(),
remark = row["remark"].ParseToString(),
shop_id = row["shop_id"].ParseToString(),
add_time = Convert.ToDateTime(row["add_time"]),
mdy_time = Convert.ToDateTime(row["mdy_time"]),
});
}
JsonSerializerSettings jsonSetting = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore };
var data = JsonUtils.SerializeObjectToString(WxOptimizeRemarkInfoLst, 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\":\"输入为空\"}";
}
}
}
@@ -0,0 +1,147 @@
using StoreHub.KJDWebService.Models.WxModel;
using StoreHub.KJDWebService.Commons;
using StoreHub.Framework.Repositorys;
using Microsoft.Extensions.Configuration;
using NaiBa.Util.Extension;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
namespace StoreHub.KJDWebService.Services
{
public class WXOemService : ServiceBase
{
public WXOemService(SqlRepository sqlRepository, IConfiguration configuration) : base(sqlRepository, configuration)
{
}
public string AddMdyOem(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
if (!WXUserService.GetSign(inputData))
return "{\"code\":999,\"msg\":\"校验失败\"}";
var oem_id = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "oem_id")?.Replace("'", "\\'"));
var oem_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "oem_name")?.Replace("'", "\\'"));
var oem_owner = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "oem_owner")?.Replace("'", "\\'"));
if (oem_id.IsNullOrEmpty() || oem_name.IsNullOrEmpty())
return "{\"code\":500,\"msg\":\"oem信息不能为空\"}";
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "INSERT INTO wxxd.oem (oem_id,oem_name,oem_owner) VALUES('" + oem_id + "','" + oem_name + "','" + oem_owner + "')" +
"ON DUPLICATE KEY UPDATE oem_name=VALUES(oem_name),oem_owner=VALUES(oem_owner);";
var rst = mySql.ExecuteAffectedRows(sql);
mySql.Close();
if (!string.IsNullOrEmpty(mySql.Message))
{
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}";
}
return "{\"code\":200,\"msg\":\"success\",\"affected_rows\":" + rst + "}";
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string DelOem(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
if (!WXUserService.GetSign(inputData))
return "{\"code\":999,\"msg\":\"校验失败\"}";
var id = (RegexUtils.GetStringQuery(ref inputData, "db_id")?.Replace("'", "\\'"));
var oem_id = (RegexUtils.GetStringQuery(ref inputData, "oem_id")?.Replace("'", "\\'"));
if (oem_id.IsNullOrEmpty() && id.IsNullOrEmpty())
return "{\"code\":500,\"msg\":\"oem信息不能为空\"}";
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "UPDATE wxxd.oem SET is_del=1 WHERE id=" + id + " or oem_id='" + oem_id + "'";
var rst = mySql.ExecuteAffectedRows(sql);
mySql.Close();
if (!string.IsNullOrEmpty(mySql.Message))
{
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}";
}
return "{\"code\":200,\"msg\":\"success\"}";
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
public string GetOem(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
if (!WXUserService.GetSign(inputData))
return "{\"code\":999,\"msg\":\"校验失败\"}";
var timeCalc = DateTime.Now;
var oem_id = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "oem_id")?.Replace("'", "\\'"));
var oem_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "oem_name")?.Replace("'", "\\'"));
var oem_owner = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "oem_owner")?.Replace("'", "\\'"));
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "SELECT * FROM wxxd.oem WHERE is_del=0";
string where = "";
if (!string.IsNullOrEmpty(oem_id))
where += " and oem_id in ('" + oem_id.Replace(",", "','") + "')";
if (!string.IsNullOrEmpty(oem_name))
where += " and oem_name in ('" + oem_name.Replace(",", "','") + "')";
if (!string.IsNullOrEmpty(oem_owner))
where += " and oem_owner in ('" + oem_owner.Replace(",", "','") + "')";
sql += where;
sql += " ORDER BY add_time DESC;";
var dt = mySql.ExecuteDataTable(sql);
mySql.Close();
if (!string.IsNullOrEmpty(mySql.Message) || dt == null)
{
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}";
}
try
{
List<oem> productLst = new List<oem>();
foreach (DataRow row in dt.Rows)
{
oem prod = new oem
{
id = row["id"].ParseToInt(),
oem_icon = null,
oem_id = row["oem_id"].ParseToString(),
add_time = row["add_time"].ParseToString().ParseToDateTime(),
mdy_time = row["mdy_time"].ParseToString().ParseToDateTime(),
oem_img = null,
oem_name = row["oem_name"].ParseToString(),
oem_owner = row["oem_owner"].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\":" + -1 + ",\"seconds\":" + seconds + "}";
}
catch (Exception ex)
{
return "{\"code\":500,\"msg\":\"" + ex.Message + "\",\"data\":[],\"count\":" + 0 + "}";
}
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
}
}
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,306 @@
using StoreHub.KJDWebService.Models;
using StoreHub.Framework.Repositorys;
using Microsoft.Extensions.Configuration;
using StoreHub.KJDWebService.Models.WxModel;
using StoreHub.KJDWebService.Commons;
using StoreHub.KJDWebService.Commons;
using MySql.Data.MySqlClient;
using NaiBa.Util.Extension;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Serialization;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Net;
using System.Reflection;
using System.Text;
using System.Threading;
namespace StoreHub.KJDWebService.Services
{
public class WXShopRevenueStatisticsService : ServiceBase
{
private readonly WXOrderService _wxOrderService;
public WXShopRevenueStatisticsService(SqlRepository sqlRepository, IConfiguration configuration, WXOrderService wxOrderService) : base(sqlRepository, configuration)
{
_wxOrderService = wxOrderService;
}
public string GetShopOrderAmountRange(string inputData)
{
Result ret = Result.ArgumentNull();
if (!string.IsNullOrEmpty(inputData))
{
try
{
// todo 获取当前用户微信店铺,或指定某一个店铺,某一段时间
// 获取店铺下时间范围内的所有订单涉及到的金额
// 直接返回
if (!WXUserService.GetSign(inputData))
throw new ArgumentException("校验失败");
var timeCalc = DateTime.Now;
string shop_ids = RegexUtils.GetStringQuery(ref inputData, "shop_ids")?.Replace("'", "");//所有店铺信息
if (string.IsNullOrEmpty(shop_ids))
throw new ArgumentException("请选择店铺");
List<string> shopIdLst = shop_ids.Split(',').ToList();
if (shopIdLst.Count > 0)
shop_ids = "'" + string.Join("','", shopIdLst) + "'";
string start_Time = RegexUtils.GetStringQuery(ref inputData, "start_time")?.Replace("'", "");
string end_Time = RegexUtils.GetStringQuery(ref inputData, "end_time")?.Replace("'", "");
DateTime startTime = DateTime.Now.AddDays(-7);
DateTime endTime = DateTime.Now;
if (!string.IsNullOrEmpty(start_Time))
startTime = TimeUtils.StampMillisecondsToDateTime(start_Time.ParseToLong());
if (!string.IsNullOrEmpty(end_Time))
endTime = TimeUtils.StampMillisecondsToDateTime(end_Time.ParseToLong());
if (endTime <= startTime)
throw new ArgumentException("结束时间必须大于开始时间");
if (endTime > startTime.AddMonths(3))
throw new ArgumentException("时间范围不能超过3个月");
int startTimestamp = TimeUtils.DateTimeToTimestampSeconds(startTime);
int endTimestamp = TimeUtils.DateTimeToTimestampSeconds(endTime);
StringBuilder sb = new StringBuilder();
sb.Append("SELECT ");
sb.Append("A.shop_name, ");
sb.Append("A.create_time, ");
sb.Append("A.order_id, ");
sb.Append("A.`status`, ");
sb.Append("A.product_price, ");
sb.Append("A.order_price, ");
sb.Append("A.purchase_price, ");
sb.Append("A.freight, ");
sb.Append("A.predict_commission_fee, ");
sb.Append("A.commission_amount, ");
sb.Append("A.discounted_price, ");
sb.Append("A.profit, ");
sb.Append("A.purchase_status, ");
sb.Append("A.out_amount, ");
sb.Append("B.refund_status, ");
sb.Append("c.`status` as refund_status_string, ");
sb.Append("IFNULL(C.refund_amount, 0) AS refund_amount ");
sb.Append("FROM erp.oms_wei_order AS A ");
sb.Append("INNER JOIN erp.`oms_wei_order_item` AS B ON A.`order_id` = B.`order_id` ");
sb.Append("LEFT JOIN ( SELECT order_id,`status`,refund_amount,id FROM erp.`oms_wei_refund` WHERE id IN ( SELECT MAX(id) FROM erp.`oms_wei_refund` GROUP BY order_id)) AS C ON A.order_id = C.order_id ");
sb.Append("WHERE A.create_time BETWEEN " + startTimestamp + " AND " + endTimestamp + " ");
sb.Append("AND A.`status` > 10 ");
sb.Append("AND A.shop_id IN (" + shop_ids + ") ");
sb.Append("ORDER BY A.create_time asc");
string conn = "ConnKJD";
MysqlUtils mySql = new MysqlUtils(conn);
DataTable dt = mySql.ExecuteDataTable(sb.ToString());
mySql.Close();
if (!string.IsNullOrEmpty(mySql.Message))
throw new Exception(mySql.Message);
// out_amount 为空或为0的订单,从中转仓订单表(GetTransitOrderTable)补全外采金额
// external_procurement:0=未查到,1=从 GetTransitOrderTable 查询到
Dictionary<string, int> transitOutAmountMap = new Dictionary<string, int>();
if (dt != null && dt.Rows.Count > 0)
{
HashSet<string> needLookupOrderIds = new HashSet<string>();
foreach (DataRow row in dt.Rows)
{
int? rowOutAmount = row["out_amount"].ParseToInt();
if (rowOutAmount == null || rowOutAmount.Value == 0)
{
string orderId = row["order_id"].ParseToString();
if (!string.IsNullOrEmpty(orderId))
needLookupOrderIds.Add(orderId);
}
}
if (needLookupOrderIds.Count > 0)
{
const int chunkSize = 100;
const int transitPageSize = 500;
List<string> needLookupList = needLookupOrderIds.ToList();
for (int i = 0; i < needLookupList.Count; i += chunkSize)
{
int takeCount = Math.Min(chunkSize, needLookupList.Count - i);
string chunkOrderIds = string.Join(",", needLookupList.GetRange(i, takeCount));
int pageIndex = 1;
while (true)
{
int count = -1;
var transitList = _wxOrderService.GetTransitOrderTable(pageIndex, transitPageSize, chunkOrderIds, null, null, null, null, "true", out count);
if (transitList == null || transitList.Count == 0)
break;
foreach (var transit in transitList)
{
if (transit != null && !string.IsNullOrEmpty(transit.order_no) && needLookupOrderIds.Contains(transit.order_no))
{
if (!transitOutAmountMap.ContainsKey(transit.order_no))
transitOutAmountMap[transit.order_no] = transit.out_amount ?? 0;
}
}
if (transitList.Count < transitPageSize)
break;
pageIndex++;
}
}
}
}
List<WXOrderAmountInfo> orderList = new List<WXOrderAmountInfo>();
if (dt != null)
{
foreach (DataRow row in dt.Rows)
orderList.Add(BuildOrderAmountInfo(row, transitOutAmountMap));
}
// 买手号退款金额:退款订单(refund_status>1)且非外采时,从买手售后表补全退款金额
FillBuyerRefundAmount(orderList, conn);
ret.Code = 200;
ret.Msg = "success";
ret.Data = orderList;
}
catch (Exception ex)
{
ret.Code = 500;
ret.Msg = ex.Message;
}
}
return JsonUtils.SerializeObjectToString(ret, new JsonSerializerSettings
{
ContractResolver = new CamelCasePropertyNamesContractResolver(),
NullValueHandling = NullValueHandling.Ignore
});
}
/// <summary>
/// 将订单行转换为金额详情:out_amount 为空或0时从中转仓订单表补全,并计算利润
/// </summary>
private WXOrderAmountInfo BuildOrderAmountInfo(DataRow row, Dictionary<string, int> transitOutAmountMap)
{
string orderId = row["order_id"].ParseToString();
int outAmount = row["out_amount"].ParseToInt();
int externalProcurement = 0;
if (outAmount == 0)
{
int transitAmount;
if (transitOutAmountMap.TryGetValue(orderId, out transitAmount))
{
externalProcurement = 1;
outAmount = transitAmount;
}
}
int orderPrice = row["order_price"].ParseToInt();
int predictCommissionFee = row["predict_commission_fee"].ParseToInt();
int commissionAmount = row["commission_amount"].ParseToInt();
int refund_amount = row["refund_amount"].ParseToInt();
// 利润 = 订单金额 - 外采金额 - 平台服务费 - 达人佣金(为空按0处理)
int profit = orderPrice - outAmount - predictCommissionFee - commissionAmount;
if (refund_amount > 0) //退款利润计算
{
profit = orderPrice - refund_amount;
}
return new WXOrderAmountInfo
{
shop_name = row["shop_name"].ParseToString(),
create_time = row["create_time"].ParseToInt(),
order_id = orderId,
status = row["status"].ParseToInt(),
product_price = row["product_price"].ParseToInt(),
order_price = orderPrice,
purchase_price = row["purchase_price"].ParseToInt(),
freight = row["freight"].ParseToInt(),
predict_commission_fee = predictCommissionFee,
commission_amount = commissionAmount,
discounted_price = row["discounted_price"].ParseToInt(),
profit = profit,
purchase_status = row["purchase_status"].ParseToInt(),
out_amount = outAmount,
refund_status = row["refund_status"].ParseToInt(),
refund_status_string = row["refund_status_string"].ParseToString(),
refund_amount = row["refund_amount"].ParseToInt(),
external_procurement = externalProcurement
};
}
/// <summary>
/// 买手号退款金额:退款订单(refund_status>1)且非外采时,从买手售后表(wxxd.order_pdd_buyer_after_sale)查询退款金额(refundAmount)填入
/// </summary>
private void FillBuyerRefundAmount(List<WXOrderAmountInfo> orderList, string conn)
{
if (orderList == null || orderList.Count == 0)
return;
// 退款订单(refund_status>1)且非外采(out_amount、external_procurement都为0)的订单才查询买手号退款金额
HashSet<string> needLookupOrderIds = new HashSet<string>();
foreach (WXOrderAmountInfo order in orderList)
{
if (order.refund_status > 1 && order.external_procurement == 1 && order.out_amount > 0)
{
if (!string.IsNullOrEmpty(order.order_id))
needLookupOrderIds.Add(order.order_id);
}
}
if (needLookupOrderIds.Count == 0)
return;
Dictionary<string, Tuple<int, string>> buyerRefundAmountMap = new Dictionary<string, Tuple<int, string>>();
MysqlUtils mySql = new MysqlUtils(conn);
try
{
const int chunkSize = 100;
List<string> needLookupList = needLookupOrderIds.ToList();
for (int i = 0; i < needLookupList.Count; i += chunkSize)
{
int takeCount = Math.Min(chunkSize, needLookupList.Count - i);
string chunkOrderIds = string.Join("','", needLookupList.GetRange(i, takeCount));
string sql = "SELECT WX_ORDER_ID,refundAmount,statusText FROM wxxd.order_pdd_buyer_after_sale a " +
"WHERE a.WX_ORDER_ID IN ('" + chunkOrderIds + "') AND a.id = ( SELECT MAX(b.id) FROM wxxd.order_pdd_buyer_after_sale b WHERE b.WX_ORDER_ID = a.WX_ORDER_ID) ORDER BY a.WX_ORDER_ID;";
DataTable buyerDt = mySql.ExecuteDataTable(sql);
if (buyerDt != null)
{
foreach (DataRow row in buyerDt.Rows)
{
string wxOrderId = row["WX_ORDER_ID"].ParseToString();
int refundAmount = row["refundAmount"].ParseToInt();
string statusText = row["statusText"].ParseToString();
if (!string.IsNullOrEmpty(wxOrderId) && !buyerRefundAmountMap.ContainsKey(wxOrderId))
buyerRefundAmountMap[wxOrderId] = new Tuple<int, string>(refundAmount, statusText);
}
}
}
}
finally
{
mySql.Close();
}
if (!string.IsNullOrEmpty(mySql.Message))
throw new Exception(mySql.Message);
foreach (WXOrderAmountInfo order in orderList)
{
Tuple<int, string> buyerRefundAmount;
if (buyerRefundAmountMap.TryGetValue(order.order_id, out buyerRefundAmount))
{
order.buyer_refund_amount = buyerRefundAmount.Item1;
order.buyer_refund_status = buyerRefundAmount.Item2;
}
}
}
}
}
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff