diff --git a/KJD_WebService/BLL/BXX/BXXProductManage.cs b/KJD_WebService/BLL/BXX/BXXProductManage.cs index 35a3445..9211471 100644 --- a/KJD_WebService/BLL/BXX/BXXProductManage.cs +++ b/KJD_WebService/BLL/BXX/BXXProductManage.cs @@ -3159,6 +3159,27 @@ namespace KJD_Web.BLL.BXX return "{\"code\":19999,\"msg\":\"输入为空\"}"; } + public string WxApiGetWxCateBound(string inputData) + { + if (!string.IsNullOrEmpty(inputData)) + { + if (!WXUserManage.GetSign(inputData)) + return "{\"code\":999,\"msg\":\"校验失败\"}"; + + string token = RegexUtils.GetStringQuery(ref inputData, "token", true); + string cat_id = RegexUtils.GetStringQuery(ref inputData, "cat_id", true); + string body = "{\"category_id\": " + cat_id + "}"; + return HttpUtils.WxApiPostResponse("https://api.weixin.qq.com/shop/ec/category/getcategoryrule?access_token=" + token + "&rule_id=1", body, ""); + + { + //"errcode": 0, + //"errmsg": "ok", + //"deposit": 1000000 + } + } + return "{\"code\":19999,\"msg\":\"输入为空\"}"; + } + public string WxApiDropshipSearch(string inputData) { if (!string.IsNullOrEmpty(inputData)) diff --git a/KJD_WebService/BLL/WXXD/WXUserManage.cs b/KJD_WebService/BLL/WXXD/WXUserManage.cs index 24db4bb..a1fbec5 100644 --- a/KJD_WebService/BLL/WXXD/WXUserManage.cs +++ b/KJD_WebService/BLL/WXXD/WXUserManage.cs @@ -1,4 +1,5 @@ using KJD_Web.Model; +using KJD_Web.Model.PddModel; using KJD_Web.Model.WxModel; using KJD_Web.Utils; using MySql.Data.MySqlClient; @@ -1825,5 +1826,305 @@ namespace KJD_Web.BLL.WXXD } return "{\"code\":19999,\"msg\":\"输入为空\"}"; } + + public string AddTaobaoBuyer(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 = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString; + 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 tb.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 MdyTaobaoBuyer(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 = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString; + MysqlUtils mySql = new MysqlUtils(conn); + string sql = "update tb.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 MdyTaobaoBuyerCookie(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 = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString; + MysqlUtils mySql = new MysqlUtils(conn); + string sql = "update tb.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 GetTaobaoBuyer(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 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 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 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 = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString; + MysqlUtils mySql = new MysqlUtils(conn); + + string sql = "SELECT COUNT(s.id) FROM tb.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 tb.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 buyerList = new List(); + 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 DelTaobaoBuyer(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 = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString; + MysqlUtils mySql = new MysqlUtils(conn); + + string sql = "DELETE FROM tb.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\":\"未知错误\"}"; + } } } \ No newline at end of file diff --git a/KJD_WebService/Controllers/WX/WXProductController.cs b/KJD_WebService/Controllers/WX/WXProductController.cs index 11dc05e..e6c6449 100644 --- a/KJD_WebService/Controllers/WX/WXProductController.cs +++ b/KJD_WebService/Controllers/WX/WXProductController.cs @@ -331,6 +331,16 @@ namespace KJD_Web.Controllers.WX return JsonString(result); } + public IHttpActionResult Wx_api_get_wx_cate_bound() + { + string jsontext = GetRequestJsonString(); + + var result = jsontext; + result = new BXXProductManage().WxApiGetWxCateBound(jsontext); + + return JsonString(result); + } + /// /// 搜索代发 /// diff --git a/KJD_WebService/Controllers/WX/WXUserController.cs b/KJD_WebService/Controllers/WX/WXUserController.cs index 37211e1..8f28534 100644 --- a/KJD_WebService/Controllers/WX/WXUserController.cs +++ b/KJD_WebService/Controllers/WX/WXUserController.cs @@ -1,4 +1,5 @@ -using KJD_Web.BLL.WXXD; +using KJD_Web.BLL.BXX; +using KJD_Web.BLL.WXXD; using KJD_Web.Requests.Users; using KJD_Web.Utils; using NaiBa.Util.Extension; @@ -295,6 +296,56 @@ namespace KJD_Web.Controllers } + public IHttpActionResult add_taobao_buyer() + { + string jsontext = GetRequestJsonString(); + + var result = jsontext; + result = new WXUserManage().AddTaobaoBuyer(jsontext); + + return JsonString(result); + } + + public IHttpActionResult mdy_taobao_buyer() + { + string jsontext = GetRequestJsonString(); + + var result = jsontext; + result = new WXUserManage().MdyTaobaoBuyer(jsontext); + + return JsonString(result); + } + + public IHttpActionResult mdy_taobao_buyer_cookie() + { + string jsontext = GetRequestJsonString(); + + var result = jsontext; + result = new WXUserManage().MdyTaobaoBuyerCookie(jsontext); + + return JsonString(result); + } + + public IHttpActionResult get_taobao_buyer() + { + string jsontext = GetRequestJsonString(); + + var result = jsontext; + result = new WXUserManage().GetTaobaoBuyer(jsontext); + + return JsonString(result); + } + + public IHttpActionResult del_taobao_buyer() + { + string jsontext = GetRequestJsonString(); + + var result = jsontext; + result = new WXUserManage().DelTaobaoBuyer(jsontext); + + return JsonString(result); + } + public IHttpActionResult add_mdy_oem()