买手商品所有sku关联功能
This commit is contained in:
1 parent
be894efae3
commit
e4a38ce1f7
3 files changed
+231
-2
No files matched your search
@@ -451,6 +451,194 @@ namespace KJD_Web.BLL.WXXD
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public string WXAddMdyBuyProdMapSkus(string inputData)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(inputData))
|
||||||
|
{
|
||||||
|
if (!WXUserManage.GetSign(inputData))
|
||||||
|
return "{\"code\":999,\"msg\":\"校验失败\"}";
|
||||||
|
|
||||||
|
// 软件用户名
|
||||||
|
string spu_code = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "spu_code"))?.Replace("'", "\\'");
|
||||||
|
string user_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "main_user_name"))?.Replace("'", "\\'");
|
||||||
|
string map_url = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "map_url"))?.Replace("'", "\\'");
|
||||||
|
string map_goods_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "map_goods_name"))?.Replace("'", "\\'");
|
||||||
|
string map_goods_id = RegexUtils.GetStringQuery(ref inputData, "map_goods_id")?.Replace("'", "\\'");
|
||||||
|
string map_skus = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "map_skus"))?.Replace("'", "\\'");
|
||||||
|
string map_send_address = RegexUtils.GetStringQuery(ref inputData, "map_send_address")?.Replace("'", "\\'");
|
||||||
|
string transit_warehouse_id = RegexUtils.GetStringQuery(ref inputData, "transit_warehouse_id")?.Replace("'", "\\'");
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(spu_code))
|
||||||
|
return "{\"code\":500,\"msg\":\"缺少系统商品编号\"}";
|
||||||
|
if (string.IsNullOrEmpty(user_name))
|
||||||
|
return "{\"code\":500,\"msg\":\"缺少用户名\"}";
|
||||||
|
if (string.IsNullOrEmpty(map_url) && string.IsNullOrEmpty(map_goods_id))
|
||||||
|
return "{\"code\":500,\"msg\":\"缺少采购商品信息\"}";
|
||||||
|
|
||||||
|
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
||||||
|
MysqlUtils mySql = new MysqlUtils(conn);
|
||||||
|
|
||||||
|
string sql = "SELECT 1 FROM `bxx`.`product_buy_map_skus` where user_name='" + user_name + "' AND spu_code='" + spu_code + "' AND map_goods_id='" + map_goods_id + "'";
|
||||||
|
string where = "";
|
||||||
|
sql += where;
|
||||||
|
var exist = mySql.ExecuteFirstInt(sql);
|
||||||
|
if (!mySql.Message.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
mySql.Close();
|
||||||
|
return "{\"code\":501,\"msg\":\"" + mySql.Message + "\"}";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (exist == 0)
|
||||||
|
{
|
||||||
|
sql = " INSERT INTO `bxx`.`product_buy_map_skus` (user_name,spu_code,map_url,map_goods_name,map_goods_id,map_skus,map_send_address,transit_warehouse_id)" +
|
||||||
|
" VALUES (@user_name,@spu_code,@map_url,@map_goods_name,@map_goods_id,@map_skus,@map_send_address,@transit_warehouse_id);";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sql = "UPDATE `bxx`.`product_buy_map_skus` SET ";
|
||||||
|
if (map_url != null)
|
||||||
|
sql += " map_url=@map_url,";
|
||||||
|
if (map_goods_name != null)
|
||||||
|
sql += " map_goods_name=@map_goods_name,";
|
||||||
|
if (map_skus != null)
|
||||||
|
sql += " map_skus=@map_skus,";
|
||||||
|
if (map_send_address != null)
|
||||||
|
sql += " map_send_address=@map_send_address,";
|
||||||
|
if (transit_warehouse_id != null)
|
||||||
|
sql += " transit_warehouse_id=@transit_warehouse_id,";
|
||||||
|
sql = sql.TrimEnd(',');
|
||||||
|
sql += " WHERE user_name=@user_name and spu_code=@spu_code;";
|
||||||
|
}
|
||||||
|
|
||||||
|
List<MySqlParameter> paramLst = new List<MySqlParameter>();
|
||||||
|
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "user_name", Value = user_name, });
|
||||||
|
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "spu_code", Value = spu_code, });
|
||||||
|
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "map_url", Value = map_url, });
|
||||||
|
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "map_goods_name", Value = map_goods_name, });
|
||||||
|
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "map_goods_id", Value = map_goods_id, });
|
||||||
|
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "map_skus", Value = map_skus, });
|
||||||
|
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "map_send_address", Value = map_send_address, });
|
||||||
|
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "transit_warehouse_id", Value = transit_warehouse_id, });
|
||||||
|
var rows = mySql.ExecuteAffectedRows(sql, paramLst.ToArray());
|
||||||
|
mySql.Close();
|
||||||
|
if (string.IsNullOrEmpty(mySql.Message))
|
||||||
|
{
|
||||||
|
if (rows > 0)
|
||||||
|
return "{\"code\":200,\"msg\":\"success\"}";
|
||||||
|
else
|
||||||
|
return "{\"code\":200,\"msg\":\"数据操作失败,请重试\"}";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return "{\"code\":50003,\"msg\":\"" + mySql.Message + "\"}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 微信获取采购映射商品
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="inputData"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public string WXGetBuyPordMapSkus(string inputData)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(inputData))
|
||||||
|
{
|
||||||
|
if (!WXUserManage.GetSign(inputData))
|
||||||
|
return "{\"code\":999,\"msg\":\"校验失败\"}";
|
||||||
|
var timeCalc = DateTime.Now;
|
||||||
|
|
||||||
|
int page = RegexUtils.GetStringQuery(ref inputData, "page").ParseToInt();
|
||||||
|
int page_size = RegexUtils.GetStringQuery(ref inputData, "page_size").ParseToInt(200);
|
||||||
|
string spu_codes = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "spu_codes"))?.Replace("'", "\\'");
|
||||||
|
string user_name = RegexUtils.GetStringQuery(ref inputData, "main_user_name")?.Replace("'", "\\'");
|
||||||
|
string not_count = RegexUtils.GetStringQuery(ref inputData, "not_count")?.Replace("'", "\\'");
|
||||||
|
if (string.IsNullOrEmpty(spu_codes))
|
||||||
|
return "{\"code\":500,\"msg\":\"商品编码不能为空\"}";
|
||||||
|
if (string.IsNullOrEmpty(user_name))
|
||||||
|
return "{\"code\":500,\"msg\":\"用户名不能为空\"}";
|
||||||
|
|
||||||
|
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
||||||
|
MysqlUtils mySql = new MysqlUtils(conn);
|
||||||
|
|
||||||
|
string sql = "";
|
||||||
|
var count = -1;
|
||||||
|
|
||||||
|
sql = "SELECT COUNT(*) FROM `bxx`.`product_buy_map_skus` WHERE 1=1";
|
||||||
|
string where = "";
|
||||||
|
if (spu_codes != null)
|
||||||
|
where += " and spu_code IN ('" + spu_codes.Replace(",", "','") + "')";
|
||||||
|
if (user_name != null)
|
||||||
|
where += " and user_name='" + user_name + "'";
|
||||||
|
sql += where;
|
||||||
|
sql += ";";
|
||||||
|
|
||||||
|
if (not_count == "false")
|
||||||
|
count = mySql.ExecuteRowCount(sql);
|
||||||
|
|
||||||
|
DataTable dt;
|
||||||
|
if (count == 0)
|
||||||
|
{
|
||||||
|
dt = new DataTable();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//sql = "SELECT * FROM `bxx`.`product_buy_map_skus` WHERE 1=1";
|
||||||
|
//sql += where;
|
||||||
|
//sql += " order by id desc limit " + Math.Max(0, page - 1) * page_size + "," + page_size + ";";
|
||||||
|
//dt = mySql.ExecuteDataTable(sql);
|
||||||
|
|
||||||
|
sql = @"
|
||||||
|
SELECT *
|
||||||
|
FROM(
|
||||||
|
SELECT t.*,ROW_NUMBER() OVER (PARTITION BY spu_code ORDER BY mdy_time DESC) AS rn
|
||||||
|
FROM `bxx`.`product_buy_map_skus` t
|
||||||
|
) AS ranked
|
||||||
|
WHERE rn <= 5" + where;
|
||||||
|
dt = mySql.ExecuteDataTable(sql);
|
||||||
|
}
|
||||||
|
mySql.Close();
|
||||||
|
|
||||||
|
if (dt != null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
List<WXBuyMapSkusInfo> WXBuyMapInfoLst = new List<WXBuyMapSkusInfo>();
|
||||||
|
foreach (DataRow row in dt.Rows)
|
||||||
|
{
|
||||||
|
WXBuyMapInfoLst.Add(new WXBuyMapSkusInfo()
|
||||||
|
{
|
||||||
|
id = row["id"].ParseToInt(),
|
||||||
|
user_name = row["user_name"].ParseToNullableString(),
|
||||||
|
spu_code = row["spu_code"].ParseToNullableString(),
|
||||||
|
map_url = row["map_url"].ParseToNullableString(),
|
||||||
|
map_goods_name = row["map_goods_name"].ParseToNullableString(),
|
||||||
|
map_goods_id = row["map_goods_id"].ParseToNullableString(),
|
||||||
|
map_skus = row["map_skus"].ParseToNullableString(),
|
||||||
|
map_send_address = row["map_send_address"].ParseToNullableString(),
|
||||||
|
transit_warehouse_id = row["transit_warehouse_id"].ParseToNullableString(),
|
||||||
|
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(WXBuyMapInfoLst, 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>
|
||||||
@@ -476,7 +664,6 @@ namespace KJD_Web.BLL.WXXD
|
|||||||
string map_sku_id = RegexUtils.GetStringQuery(ref inputData, "map_sku_id")?.Replace("'", "\\'");
|
string map_sku_id = RegexUtils.GetStringQuery(ref inputData, "map_sku_id")?.Replace("'", "\\'");
|
||||||
string map_send_address = RegexUtils.GetStringQuery(ref inputData, "map_send_address")?.Replace("'", "\\'");
|
string map_send_address = RegexUtils.GetStringQuery(ref inputData, "map_send_address")?.Replace("'", "\\'");
|
||||||
string transit_warehouse_id = RegexUtils.GetStringQuery(ref inputData, "transit_warehouse_id")?.Replace("'", "\\'");
|
string transit_warehouse_id = RegexUtils.GetStringQuery(ref inputData, "transit_warehouse_id")?.Replace("'", "\\'");
|
||||||
string map_skus = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "map_skus"))?.Replace("'", "\\'");
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(spu_code) || string.IsNullOrEmpty(sku_code))
|
if (string.IsNullOrEmpty(spu_code) || string.IsNullOrEmpty(sku_code))
|
||||||
return "{\"code\":500,\"msg\":\"缺少系统商品或SKU编号\"}";
|
return "{\"code\":500,\"msg\":\"缺少系统商品或SKU编号\"}";
|
||||||
|
|||||||
@@ -37,4 +37,23 @@ namespace KJD_Web.Model.WxModel
|
|||||||
public DateTime add_time { get; set; }
|
public DateTime add_time { get; set; }
|
||||||
public DateTime mdy_time { get; set; }
|
public DateTime mdy_time { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public class WXBuyMapSkusInfo
|
||||||
|
{
|
||||||
|
public long id { get; set; }
|
||||||
|
public string user_name { get; set; }
|
||||||
|
public string spu_code { get; set; }
|
||||||
|
public string map_url { get; set; }
|
||||||
|
public string map_goods_name { get; set; }
|
||||||
|
public string map_goods_id { get; set; }
|
||||||
|
public string map_skus { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 发货地(省,市)
|
||||||
|
/// </summary>
|
||||||
|
public string map_send_address { get; set; }
|
||||||
|
public string transit_warehouse_id { get; set; }
|
||||||
|
public DateTime add_time { get; set; }
|
||||||
|
public DateTime mdy_time { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -319,8 +319,30 @@ namespace KJD_Web
|
|||||||
Context.Response.End();
|
Context.Response.End();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[WebMethod]
|
[WebMethod]
|
||||||
|
public void wx_add_mdy_buy_prod_map_skus()
|
||||||
|
{
|
||||||
|
string jsontext = GetRequestJsonString();
|
||||||
|
|
||||||
|
var result = jsontext;
|
||||||
|
result = new WXOrderManage().WXAddMdyBuyProdMapSkus(jsontext);
|
||||||
|
|
||||||
|
Context.Response.Write(result);
|
||||||
|
Context.Response.End();
|
||||||
|
}
|
||||||
|
[WebMethod]
|
||||||
|
public void wx_get_buy_pord_map_skus()
|
||||||
|
{
|
||||||
|
string jsontext = GetRequestJsonString();
|
||||||
|
|
||||||
|
var result = jsontext;
|
||||||
|
result = new WXOrderManage().WXGetBuyPordMapSkus(jsontext);
|
||||||
|
|
||||||
|
Context.Response.Write(result);
|
||||||
|
Context.Response.End();
|
||||||
|
}
|
||||||
|
|
||||||
|
[WebMethod]
|
||||||
public void wx_add_mdy_buy_prod_map()
|
public void wx_add_mdy_buy_prod_map()
|
||||||
{
|
{
|
||||||
string jsontext = GetRequestJsonString();
|
string jsontext = GetRequestJsonString();
|
||||||
@@ -331,6 +353,7 @@ namespace KJD_Web
|
|||||||
Context.Response.Write(result);
|
Context.Response.Write(result);
|
||||||
Context.Response.End();
|
Context.Response.End();
|
||||||
}
|
}
|
||||||
|
|
||||||
[WebMethod]
|
[WebMethod]
|
||||||
public void wx_get_buy_prod_map()
|
public void wx_get_buy_prod_map()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user