From b42155ae6cb2d917a3c0df385d5b892f2e6a3d86 Mon Sep 17 00:00:00 2001 From: wule Date: Fri, 6 Feb 2026 15:13:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BA=97=E9=93=BA=E5=8D=95=E5=BA=97token?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=B9=B6=E4=BD=BF=E7=94=A8=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Model/Result/WXResult/WXShopTokenInfo.cs | 3 +- .../BLL/BXX/BXXProductManage.cs | 79 +----------- .../KJD_WebService/BLL/DYXD/DYShopManage.cs | 34 ----- .../BLL/WXXD/WXProductManage.cs | 55 ++++++++ .../KJD_WebService/BLL/WXXD/WXShopManage.cs | 119 +++++++++++++----- .../KJD_WebService/BXXProductService.asmx.cs | 5 +- .../KJD_WebService/DYShopService.asmx.cs | 12 -- .../KJD_WebService/WXProductService.asmx.cs | 60 +++++++++ .../KJD_WebService/WXShopService.asmx.cs | 37 ++++-- TEMUKJD/BLL/WxApiBLL.cs | 37 +++--- .../ProductSelectForms/PDDDBProdListForm.cs | 2 +- .../ProductForms/WXDBProdUploadForm.cs | 49 ++++++-- 12 files changed, 289 insertions(+), 203 deletions(-) diff --git a/AllBase/Model/Result/WXResult/WXShopTokenInfo.cs b/AllBase/Model/Result/WXResult/WXShopTokenInfo.cs index f07d8e7..00a86a8 100644 --- a/AllBase/Model/Result/WXResult/WXShopTokenInfo.cs +++ b/AllBase/Model/Result/WXResult/WXShopTokenInfo.cs @@ -13,8 +13,7 @@ namespace AllBase.Model.Result.WXResult public int? type { get; set; } // 500, public int? markupRate { get; set; } // 10, public string accessToken { get; set; } // "100_cw6r7-hhGaLKG7ndv558eO_3z3-5PokAG8d0Y1vc3Rczd3FuIqkefdaqVj5CNtkCYtMbTYvhnwJ7-JkBVQVe9nE0KK5SBI8AlfA7E0_sTtqcwMqKAXoCj1X4h3sjZIMX84dboC-PfzlI0wh0ADHeAHDSVZ" - public DateTime mdyTime { get; set; } + public DateTime mdyTime { get; set; } = DateTime.MinValue; public bool isExpire { get { return mdyTime.AddMinutes(60) < DateTime.Now; } } - } } diff --git a/KJDService/KJD_WebService/BLL/BXX/BXXProductManage.cs b/KJDService/KJD_WebService/BLL/BXX/BXXProductManage.cs index 4cb45de..3b7637f 100644 --- a/KJDService/KJD_WebService/BLL/BXX/BXXProductManage.cs +++ b/KJDService/KJD_WebService/BLL/BXX/BXXProductManage.cs @@ -1756,85 +1756,8 @@ namespace KJD_Web.BLL.BXX return "{\"code\":19999,\"msg\":\"输入为空\"}"; } - public string GetAfterSale(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 url = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "get_url")); - string rst = HttpUtils.e57GetResponse(url, ""); - return rst; - } - return "{\"code\":19999,\"msg\":\"输入为空\"}"; - } - - public string GetWxTokens(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 id = (RegexUtils.GetStringQuery(ref inputData, "db_id")?.Replace("'", "\\'")).ParseToInt(); - if (id == 0) - id = 1; - - string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString; - MysqlUtils mySql = new MysqlUtils(conn); - string sql = "select tokens,mdy_time from wxxd.wx_token WHERE id=" + id + ";"; - var rst = mySql.ExecuteDataTableRow(sql); - mySql.Close(); - - if (!string.IsNullOrEmpty(mySql.Message)) - { - return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}"; - } - - try - { - string tokens = rst["tokens"].ParseToString(); - var mdyTime = Convert.ToDateTime(rst["mdy_time"]); - if (mdyTime.AddMinutes(60) < DateTime.Now) - { - var tokenRst = HttpUtils.e57GetResponse("https://po.e57.cn/prod-api/api/sys-api/system/open/api/shop/list?userName=阿杰账户", ""); - if (!tokenRst.Contains("\"code\":0")) - tokenRst = HttpUtils.e57GetResponse("https://po.e57.cn/prod-api/api/sys-api/system/open/api/shop/list?userName=阿杰账户", ""); - if (!tokenRst.Contains("\"code\":0")) - { - var errMsg = RegexUtils.GetStringJson(ref tokenRst, "msg"); - if (string.IsNullOrEmpty(errMsg)) - errMsg = tokenRst; - return "{\"code\":500,\"msg\":\"" + errMsg + "\"}"; - } - mdyTime = DateTime.Now; - tokens = JsonUtils.SerializerObjectToString(JObject.Parse(tokenRst)["list"]); - - conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString; - mySql = new MysqlUtils(conn); - sql = "update wxxd.wx_token set tokens='" + tokens + "' where id=1;"; - bool su = mySql.ExecuteNonQuery(sql); - mySql.Close(); - - if (!string.IsNullOrEmpty(mySql.Message)) - { - return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}"; - } - } - return "{\"code\":200,\"tokens\":" + tokens + ",\"mdy_time\":\"" + mdyTime.ToString("yyyy-MM-dd HH:mm:ss") + "\"}"; - } - catch (Exception ex) - { - return "{\"code\":500,\"msg\":\"" + ex.Message + "\"}"; - } - } - return "{\"code\":19999,\"msg\":\"输入为空\"}"; - } + public string WxApiGetWxAllCate(string inputData) { diff --git a/KJDService/KJD_WebService/BLL/DYXD/DYShopManage.cs b/KJDService/KJD_WebService/BLL/DYXD/DYShopManage.cs index 435240b..be63276 100644 --- a/KJDService/KJD_WebService/BLL/DYXD/DYShopManage.cs +++ b/KJDService/KJD_WebService/BLL/DYXD/DYShopManage.cs @@ -640,40 +640,6 @@ namespace KJD_Web.BLL.DYXD return "{\"code\":19999,\"msg\":\"未知错误\"}"; } - public string MdyAntiContent(string inputData) - { - if (!string.IsNullOrEmpty(inputData)) - { - string login_name = RegexUtils.GetStringQuery(ref inputData, "login_name"); - string shop_id = RegexUtils.GetStringQuery(ref inputData, "shop_id"); - string anti_contents = RegexUtils.GetStringQuery(ref inputData, "anti_contents"); - - int r2 = 0; - int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2); - - if (string.IsNullOrEmpty(login_name)) - { - return "{\"code\":500,\"msg\":\"店铺没有登录名\"}"; - } - - string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString; - MysqlUtils mySql = new MysqlUtils(conn); - string sql = "update dyxd.shop set"; - if (anti_contents != null) - sql += " anti_contents='" + anti_contents + "',"; - sql = sql.TrimEnd(','); - sql += " where login_name='" + login_name + "' and shop_id='" + 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)) diff --git a/KJDService/KJD_WebService/BLL/WXXD/WXProductManage.cs b/KJDService/KJD_WebService/BLL/WXXD/WXProductManage.cs index df92df7..81890f0 100644 --- a/KJDService/KJD_WebService/BLL/WXXD/WXProductManage.cs +++ b/KJDService/KJD_WebService/BLL/WXXD/WXProductManage.cs @@ -676,5 +676,60 @@ namespace KJD_Web.BLL.WXXD } return "{\"code\":19999,\"msg\":\"输入为空\"}"; } + + + public string E57GetFreightTemplate(string inputData) + { + if (string.IsNullOrEmpty(inputData)) + return "{\"code\":19999,\"msg\":\"输入为空\"}"; + + var time = RegexUtils.GetStringQuery(ref inputData, "time").ParseToInt(); + string time1 = RegexUtils.GetStringQuery(ref inputData, "code"); + if (time1 != EncrypUtil.Encryption(time)) + return "{\"code\":50000,\"msg\":\"校验失败\"}"; + + // 供应商id + string coid = RegexUtils.GetStringQuery(ref inputData, "coid")?.Replace("'", "\\'"); + + try + { + // 获取运费模板 + //"https://po.e57.cn/prod-api/api/sys-api/system/open/api/freightTemplate/list?warehouseNum=10361546"; + var urlShip = "https://po.e57.cn/prod-api/api/sys-api/system/open/api/freightTemplate/list?warehouseNum=" + coid; + var shipRst = HttpUtils.e57GetResponse(urlShip, ""); + return shipRst; + } + catch (Exception ex) + { + return "{\"code\":50001,\"msg\":\"" + ex.Message + "\"}"; + } + } + + public string E57AfterSale(string inputData) + { + if (string.IsNullOrEmpty(inputData)) + return "{\"code\":19999,\"msg\":\"输入为空\"}"; + + var time = RegexUtils.GetStringQuery(ref inputData, "time").ParseToInt(); + string time1 = RegexUtils.GetStringQuery(ref inputData, "code"); + if (time1 != EncrypUtil.Encryption(time)) + return "{\"code\":50000,\"msg\":\"校验失败\"}"; + + // 供应商id + string coid = RegexUtils.GetStringQuery(ref inputData, "coid")?.Replace("'", "\\'"); + + try + { + // 获取推单售后地址 + //https://po.e57.cn/prod-api/api/sys-api/system/open/api/afterSale/info?warehouseNum=10361546&shopId=46568955 + var urlAfter = "https://po.e57.cn/prod-api/api/sys-api/system/open/api/afterSale/info?warehouseNum=" + coid; + var shipRst = HttpUtils.e57GetResponse(urlAfter, ""); + return shipRst; + } + catch (Exception ex) + { + return "{\"code\":50001,\"msg\":\"" + ex.Message + "\"}"; + } + } } } \ No newline at end of file diff --git a/KJDService/KJD_WebService/BLL/WXXD/WXShopManage.cs b/KJDService/KJD_WebService/BLL/WXXD/WXShopManage.cs index d4f512c..c1682f5 100644 --- a/KJDService/KJD_WebService/BLL/WXXD/WXShopManage.cs +++ b/KJDService/KJD_WebService/BLL/WXXD/WXShopManage.cs @@ -3,6 +3,7 @@ using KJD_Web.Model.ShopModel; using KJD_Web.Utils; using MySqlX.XDevAPI; using NaiBa.Util.Extension; +using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.Data; @@ -644,40 +645,6 @@ namespace KJD_Web.BLL.WXXD return "{\"code\":19999,\"msg\":\"未知错误\"}"; } - public string MdyAntiContent(string inputData) - { - if (!string.IsNullOrEmpty(inputData)) - { - string login_name = RegexUtils.GetStringQuery(ref inputData, "login_name"); - string shop_id = RegexUtils.GetStringQuery(ref inputData, "shop_id"); - string anti_contents = RegexUtils.GetStringQuery(ref inputData, "anti_contents"); - - int r2 = 0; - int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2); - - if (string.IsNullOrEmpty(login_name)) - { - return "{\"code\":500,\"msg\":\"店铺没有登录名\"}"; - } - - string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString; - MysqlUtils mySql = new MysqlUtils(conn); - string sql = "update wxxd.shop set"; - if (anti_contents != null) - sql += " anti_contents='" + anti_contents + "',"; - sql = sql.TrimEnd(','); - sql += " where login_name='" + login_name + "' and shop_id='" + 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)) @@ -816,5 +783,89 @@ namespace KJD_Web.BLL.WXXD } return "{\"code\":19999,\"msg\":\"输入为空\"}"; } + + public string E57GetWxTokens(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 id = (RegexUtils.GetStringQuery(ref inputData, "db_id")?.Replace("'", "\\'")).ParseToInt(); + if (id == 0) + id = 1; + + string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString; + MysqlUtils mySql = new MysqlUtils(conn); + string sql = "select tokens,mdy_time from wxxd.wx_token WHERE id=" + id + ";"; + var rst = mySql.ExecuteDataTableRow(sql); + mySql.Close(); + + if (!string.IsNullOrEmpty(mySql.Message)) + { + return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}"; + } + + try + { + string tokens = rst["tokens"].ParseToString(); + var mdyTime = Convert.ToDateTime(rst["mdy_time"]); + if (mdyTime.AddMinutes(60) < DateTime.Now) + { + var tokenRst = HttpUtils.e57GetResponse("https://po.e57.cn/prod-api/api/sys-api/system/open/api/shop/list?userName=阿杰账户", ""); + if (!tokenRst.Contains("\"code\":0")) + tokenRst = HttpUtils.e57GetResponse("https://po.e57.cn/prod-api/api/sys-api/system/open/api/shop/list?userName=阿杰账户", ""); + if (!tokenRst.Contains("\"code\":0")) + { + var errMsg = RegexUtils.GetStringJson(ref tokenRst, "msg"); + if (string.IsNullOrEmpty(errMsg)) + errMsg = tokenRst; + return "{\"code\":500,\"msg\":\"" + errMsg + "\"}"; + } + mdyTime = DateTime.Now; + tokens = JsonUtils.SerializerObjectToString(JObject.Parse(tokenRst)["list"]); + + conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString; + mySql = new MysqlUtils(conn); + sql = "update wxxd.wx_token set tokens='" + tokens + "' where id=1;"; + bool su = mySql.ExecuteNonQuery(sql); + mySql.Close(); + + if (!string.IsNullOrEmpty(mySql.Message)) + { + return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}"; + } + } + return "{\"code\":200,\"tokens\":" + tokens + ",\"mdy_time\":\"" + mdyTime.ToString("yyyy-MM-dd HH:mm:ss") + "\"}"; + } + catch (Exception ex) + { + return "{\"code\":500,\"msg\":\"" + ex.Message + "\"}"; + } + } + return "{\"code\":19999,\"msg\":\"输入为空\"}"; + } + + public string E57GetWxShopToken(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 shop_id = RegexUtils.GetStringQuery(ref inputData, "shop_id")?.Replace("'", "\\'"); + var url = "https://po.e57.cn/prod-api/api/sys-api/system/open/api/shop/info?appId=" + shop_id; + + var tokenRst = HttpUtils.e57GetResponse(url, ""); + if (!tokenRst.Contains("\"code\":0")) + tokenRst = HttpUtils.e57GetResponse(url, ""); + return tokenRst; + } + return "{\"code\":19999,\"msg\":\"输入为空\"}"; + } } } \ No newline at end of file diff --git a/KJDService/KJD_WebService/BXXProductService.asmx.cs b/KJDService/KJD_WebService/BXXProductService.asmx.cs index 69e3890..0212d4d 100644 --- a/KJDService/KJD_WebService/BXXProductService.asmx.cs +++ b/KJDService/KJD_WebService/BXXProductService.asmx.cs @@ -1,4 +1,5 @@ using KJD_Web.BLL.BXX; +using KJD_Web.BLL.WXXD; using KJD_Web.Utils; using System; using System.Collections.Generic; @@ -355,14 +356,14 @@ namespace KJD_Web string jsontext = GetRequestJsonString(); var result = jsontext; - result = new BXXProductManage().GetWxTokens(jsontext); + result = new WXShopManage().E57GetWxTokens(jsontext); Context.Response.Write(result); Context.Response.End(); } [WebMethod] - public void get_wx_all_cate() + public void wx_api_get_all_cate() { string jsontext = GetRequestJsonString(); diff --git a/KJDService/KJD_WebService/DYShopService.asmx.cs b/KJDService/KJD_WebService/DYShopService.asmx.cs index 2a9c94d..a604f33 100644 --- a/KJDService/KJD_WebService/DYShopService.asmx.cs +++ b/KJDService/KJD_WebService/DYShopService.asmx.cs @@ -109,18 +109,6 @@ namespace KJD_Web Context.Response.End(); } - [WebMethod] - public void mdy_anti_content() - { - string jsontext = GetRequestJsonString(); - - var result = jsontext; - result = new DYShopManage().MdyAntiContent(jsontext); - - Context.Response.Write(result); - Context.Response.End(); - } - [WebMethod] public void mdy_shop_cookie_and_login_status() { diff --git a/KJDService/KJD_WebService/WXProductService.asmx.cs b/KJDService/KJD_WebService/WXProductService.asmx.cs index af5b1eb..c9e5761 100644 --- a/KJDService/KJD_WebService/WXProductService.asmx.cs +++ b/KJDService/KJD_WebService/WXProductService.asmx.cs @@ -169,5 +169,65 @@ namespace KJD_Web Context.Response.Write(result); Context.Response.End(); } + + [WebMethod] + public void e57_get_freight_template() + { + string jsontext = GetRequestJsonString(); + + var result = jsontext; + result = new WXProductManage().E57GetFreightTemplate(jsontext); + + Context.Response.Write(result); + Context.Response.End(); + } + + [WebMethod] + public void e57_after_sale() + { + string jsontext = GetRequestJsonString(); + + var result = jsontext; + result = new WXProductManage().E57AfterSale(jsontext); + + Context.Response.Write(result); + Context.Response.End(); + } + + [WebMethod] + public void wx_api_get_all_cate() + { + string jsontext = GetRequestJsonString(); + + var result = jsontext; + result = new BXXProductManage().WxApiGetWxAllCate(jsontext); + + Context.Response.Write(result); + Context.Response.End(); + } + + [WebMethod] + public void wx_api_category_classify() + { + string jsontext = GetRequestJsonString(); + + var result = jsontext; + result = new BXXProductManage().WxApiCategoryClassify(jsontext); + + Context.Response.Write(result); + Context.Response.End(); + } + + [WebMethod] + public void wx_api_upload_image() + { + string jsontext = GetRequestJsonString(); + + var result = jsontext; + result = new BXXProductManage().WxApiUploadImage(jsontext); + + Context.Response.Write(result); + Context.Response.End(); + } } } diff --git a/KJDService/KJD_WebService/WXShopService.asmx.cs b/KJDService/KJD_WebService/WXShopService.asmx.cs index f77cd38..4d5332a 100644 --- a/KJDService/KJD_WebService/WXShopService.asmx.cs +++ b/KJDService/KJD_WebService/WXShopService.asmx.cs @@ -109,18 +109,6 @@ namespace KJD_Web Context.Response.End(); } - [WebMethod] - public void mdy_anti_content() - { - string jsontext = GetRequestJsonString(); - - var result = jsontext; - result = new WXShopManage().MdyAntiContent(jsontext); - - Context.Response.Write(result); - Context.Response.End(); - } - [WebMethod] public void mdy_shop_cookie_and_login_status() { @@ -216,5 +204,30 @@ namespace KJD_Web Context.Response.Write(result); Context.Response.End(); } + + [WebMethod] + public void e57_get_wx_tokens() + { + string jsontext = GetRequestJsonString(); + + var result = jsontext; + result = new WXShopManage().E57GetWxTokens(jsontext); + + Context.Response.Write(result); + Context.Response.End(); + } + + + [WebMethod] + public void e57_get_wx_shop_token() + { + string jsontext = GetRequestJsonString(); + + var result = jsontext; + result = new WXShopManage().E57GetWxShopToken(jsontext); + + Context.Response.Write(result); + Context.Response.End(); + } } } diff --git a/TEMUKJD/BLL/WxApiBLL.cs b/TEMUKJD/BLL/WxApiBLL.cs index caf6cf0..3825361 100644 --- a/TEMUKJD/BLL/WxApiBLL.cs +++ b/TEMUKJD/BLL/WxApiBLL.cs @@ -19,7 +19,7 @@ namespace TemuKJD.BLL { if (GlobalConfig.WxTokenList.Count == 0 || GlobalConfig.WxTokenList.All(t => t.isExpire == true)) { - var url = BaseClass.BuildPDDObjString("product/get_wx_tokens"); + var url = BaseClass.BuildObjString("shop/e57_get_wx_tokens"); var data = UserLogin.GetSignaturex(); var html = GetHtml.PostUtf8(url, data); if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200")) @@ -41,25 +41,28 @@ namespace TemuKJD.BLL return GlobalConfig.WxTokenList.Where(t => t.isExpire != true).OrderBy(x => Guid.NewGuid()).FirstOrDefault(); } - public string GetShopWxToken(ShopLoginInfo shop) + public WXShopTokenInfo GetShopWxToken(ShopLoginInfo shop) { - if (string.IsNullOrEmpty(shop.WxToken) || DateTime.Now.AddMinutes(115) > shop.WxTokenExpire) + var url = BaseClass.BuildObjString("shop/e57_get_wx_shop_token"); + var data = UserLogin.GetSignaturex(); + data += "&shop_id=" + shop.ShopId; + var html = GetHtml.PostUtf8(url, data); + if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":0")) { - var url = BaseClass.BuildPDDObjString("product/get_shop_wx_token"); - var data = UserLogin.GetSignaturex(); - data += "&shop_id=" + shop.ShopId; - var html = GetHtml.PostUtf8(url, data); - if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200")) - { - BaseMsgForm.ShowError("获取授权失败,请重试!" + BaseRegex.GetStringJson(ref html, "msg")); - return ""; - } - var tokenStr = BaseRegex.GetStringJson(ref html, "token"); - var ExpireStr = BaseRegex.GetStringJson(ref html, "expire"); - shop.WxToken = tokenStr; - shop.WxTokenExpire = Convert.ToDateTime(ExpireStr); } - return shop.WxToken; + else + { + var token = new WXShopTokenInfo() + { + shopId = shop.ShopId, + accessToken = BaseRegex.GetStringJson(ref html, "accessToken"), + mdyTime = DateTime.Now, + }; + //shop.WxToken = BaseRegex.GetStringJson(ref html, "accessToken"); + //shop.WxTokenExpire = DateTime.Now.AddMinutes(60); + return token; + } + return new WXShopTokenInfo() { shopId = shop.ShopId, accessToken = "", mdyTime = DateTime.Now }; } } } diff --git a/TEMUKJD/PDDForms/ProductSelectForms/PDDDBProdListForm.cs b/TEMUKJD/PDDForms/ProductSelectForms/PDDDBProdListForm.cs index 14008fb..2f1081b 100644 --- a/TEMUKJD/PDDForms/ProductSelectForms/PDDDBProdListForm.cs +++ b/TEMUKJD/PDDForms/ProductSelectForms/PDDDBProdListForm.cs @@ -985,7 +985,7 @@ namespace TemuKJD.PDDForms.ProductSelectForms { new WxApiBLL().GetRandomWxToken(); - var url1 = BaseClass.BuildPDDObjString("product/get_wx_all_cate"); + var url1 = BaseClass.BuildPDDObjString("product/wx_api_get_all_cate"); var data1 = UserLogin.GetSignaturex(); data1 += "&token=" + GlobalConfig.WxTokenList.OrderBy(x => Guid.NewGuid()).FirstOrDefault()?.accessToken; var html1 = GetHtml.PostUtf8(url1, data1); diff --git a/TEMUKJD/WXForms/ProductForms/WXDBProdUploadForm.cs b/TEMUKJD/WXForms/ProductForms/WXDBProdUploadForm.cs index d8f526f..6ae6c2b 100644 --- a/TEMUKJD/WXForms/ProductForms/WXDBProdUploadForm.cs +++ b/TEMUKJD/WXForms/ProductForms/WXDBProdUploadForm.cs @@ -39,9 +39,8 @@ namespace TemuKJD.WXForms.ProductForms bool isInit = false; CheckBox chkSelectAll = null; - //Dictionary dicShopGetCount = new Dictionary(); - //Dictionary> dicNotSupportCate = new Dictionary>(); ConcurrentList lstShopAuthInfo = new ConcurrentList(); + ConcurrentList lstWXShopTokenInfo = new ConcurrentList(); public NaiBa.Util.ConcurrentList lstTemuDBProductSelect = new NaiBa.Util.ConcurrentList(); NaiBa.Util.ConcurrentList lstAddPriceRule = new NaiBa.Util.ConcurrentList(); AddPriceRule defaultAddPriceRule = null; @@ -72,6 +71,10 @@ namespace TemuKJD.WXForms.ProductForms if (lstShopAuthInfo == null) lstShopAuthInfo = new ConcurrentList(); + lstWXShopTokenInfo = NaiBa.Util.Helper.ConfigHelper.LoadConfig>("wx_shop_token_list"); + if (lstWXShopTokenInfo == null) + lstWXShopTokenInfo = new ConcurrentList(); + lstTemuDBProductSelect = NaiBa.Util.Helper.ConfigHelper.LoadConfig>("wx_db_prod_upload_list"); if (lstTemuDBProductSelect == null) lstTemuDBProductSelect = new NaiBa.Util.ConcurrentList(); @@ -1520,8 +1523,29 @@ namespace TemuKJD.WXForms.ProductForms var upProdInitParam = new WXUploadProductInitParam(); // 生成上传商品对象 var upProdParam = new WXUploadProductParam(); - // 随机获取一个上传图片的accessToken - var token = new WxApiBLL().GetRandomWxToken(); + + // 获取店铺的accessToken + WXShopTokenInfo token = lstWXShopTokenInfo.FirstOrDefault(t => t.shopId == shop.ShopId); + if (token == null) + token = new WXShopTokenInfo(); + if (token.isExpire || string.IsNullOrEmpty(token.accessToken)) + { + AuthInfo auth = lstShopAuthInfo.FirstOrDefault(sa => sa.ShopId == shop.ShopId); + if (auth != null && auth.ExpiresTime > DateTime.Now.AddMinutes(5)) + { + token = new WxApiBLL().GetShopWxToken(shop); + + if (!string.IsNullOrEmpty(token.accessToken)) + { + lstWXShopTokenInfo.RemoveAll(t => t.shopId == shop.ShopId); + lstWXShopTokenInfo.Add(token); + NaiBa.Util.Helper.ConfigHelper.SaveConfig("wx_shop_token_list", lstWXShopTokenInfo); + } + } + } + // 如果店铺token不可用,随机获取一个上传图片的accessToken + if (token == null || token.isExpire || string.IsNullOrEmpty(token.accessToken)) + token = new WxApiBLL().GetRandomWxToken(); #region 设置标题 upProdInitParam.product.info.title = dbProd.product_name.IsNullOrEmpty() ? prodInfo.detail.goods_name : dbProd.product_name; @@ -1979,12 +2003,14 @@ namespace TemuKJD.WXForms.ProductForms } } + //{"address_id":null,"user_name":"退货","postal_code":null,"province_name":"广东省","city_name":"揭阳市","county_name":"榕城区","street_name":"东兴街道","detail_info":"建阳路万泰华庭二期对面眼镜","tel_number":"13024622251","number":"10431013","name":"麦多多供应链"} + //{"address_id":null,"user_name":"退货","postal_code":null,"province_name":"广东省","city_name":"揭阳市","county_name":"榕城区","street_name":"东兴街道","detail_info":"建阳路万泰华庭二期对面眼镜","tel_number":"13024622251","number":"10431013","name":"麦多多供应链"} if (string.IsNullOrEmpty(afterSaleAddress)) { // 获取推单售后地址 - //https://po.e57.cn/prod-api/api/sys-api/system/open/api/afterSale/info?warehouseNum=10361546&shopId=46568955 - var urlAfter = "https://po.e57.cn/prod-api/api/sys-api/system/open/api/afterSale/info?warehouseNum=" + dbProd.skc_id; //+ "&userName=阿杰账户"; - var afterRst = WXHttpResponseBLL.e57GetResponse(urlAfter, ""); + var urlAfter = BaseClass.BuildObjString("product/e57_after_sale"); + var dataAfter = Work.UserLogin.GetSignaturex() + "&coid=" + dbProd.skc_id; + var afterRst = GetHtml.PostUtf8(urlAfter, dataAfter); try { afterSaleAddress = JsonHelper.SerializeObject(JsonHelper.JObjectParse(afterRst)["data"]); @@ -2093,11 +2119,12 @@ namespace TemuKJD.WXForms.ProductForms if (string.IsNullOrEmpty(shippingTemplateJson)) { - // 获取运费模板 - //"https://po.e57.cn/prod-api/api/sys-api/system/open/api/freightTemplate/list?warehouseNum=10361546"; - var urlShip = "https://po.e57.cn/prod-api/api/sys-api/system/open/api/freightTemplate/list?warehouseNum=" + dbProd.skc_id; - var shipRst = WXHttpResponseBLL.e57GetResponse(urlShip, ""); + var urlShip = BaseClass.BuildObjString("product/e57_get_freight_template"); + var dataShip = Work.UserLogin.GetSignaturex() + "&coid=" + dbProd.skc_id; + var shipRst = GetHtml.PostUtf8(urlShip, dataShip); + if (string.IsNullOrEmpty(shipRst) || !shipRst.Contains("\"code\":0")) + shipRst = GetHtml.PostUtf8(urlShipping, dataShipping); try { //[{"id":"204","warehouseNum":"15016108","freightType":0,"provinces":"香港特别行政区,台湾省,澳门特别行政区","freightPrice":9999900,"createBy":"vmslin","createTime":"2026-01-30T16:45:03+08:00","updateBy":"vmslin","updateTime":"2026-01-30T16:45:03+08:00"},{"id":"205","warehouseNum":"15016108","freightType":3,"provinces":"海南省,新疆维吾尔自治区,西藏自治区,内蒙古自治区","freightPrice":1530,"createBy":"vmslin","createTime":"2026-01-30T16:45:51+08:00","updateBy":"vmslin","updateTime":"2026-01-30T16:45:51+08:00"},{"id":"206","warehouseNum":"15016108","freightType":1,"provinces":"北京市,上海市","freightPrice":410,"createBy":"vmslin","createTime":"2026-01-30T16:46:04+08:00","updateBy":"vmslin","updateTime":"2026-01-30T16:46:04+08:00"},{"id":"207","warehouseNum":"15016108","freightType":1,"provinces":"安徽省,重庆市,福建省,广东省,甘肃省,广西壮族自治区,贵州省,河北省,湖北省,黑龙江省,河南省,湖南省,吉林省,江苏省,江西省,辽宁省,宁夏回族自治区,青海省,四川省,山东省,山西省,陕西省,天津市,云南省,浙江省","freightPrice":310,"createBy":"vmslin","createTime":"2026-01-30T16:46:17+08:00","updateBy":"vmslin","updateTime":"2026-01-30T16:46:17+08:00"}]