类目识别功能 多选功能优化 微信上货优化 微信客服信息识别优化等
This commit is contained in:
1 parent
c27063d704
commit
a2a6719a99
31 files changed
+2223
-750
No files matched your search
@@ -8,6 +8,8 @@ using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Security;
|
||||
@@ -246,6 +248,10 @@ namespace KJD_Web.BLL.BXX
|
||||
if (time1 != EncrypUtil.Encryption(time))
|
||||
return "{\"code\":50000,\"msg\":\"校验失败\"}";
|
||||
|
||||
var version = RegexUtils.GetStringQuery(ref inputData, "version").ParseToInt();
|
||||
if (version < 823)
|
||||
return "{\"code\":1,\"msg\":\"当前版本过于陈旧,请立即升级新版\"}";
|
||||
|
||||
var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name")?.Replace("'","\\'");
|
||||
var password = RegexUtils.GetStringQuery(ref inputData, "password")?.Replace("'", "\\'");
|
||||
var search_spu = RegexUtils.GetStringQuery(ref inputData, "search_spu")?.Replace("'", "\\'");
|
||||
@@ -276,7 +282,7 @@ namespace KJD_Web.BLL.BXX
|
||||
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
||||
MysqlUtils mySql = new MysqlUtils(conn);
|
||||
|
||||
string sql = "select count(id) from bxx.product p where p.is_del=0";
|
||||
string sql = "select count(*) from bxx.product p where p.is_del=0";
|
||||
|
||||
string where = "";
|
||||
if (!string.IsNullOrEmpty(from_shop_id))
|
||||
@@ -600,7 +606,7 @@ namespace KJD_Web.BLL.BXX
|
||||
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
||||
MysqlUtils mySql = new MysqlUtils(conn);
|
||||
|
||||
string sql = "select count(id) from bxx.sku_img_replace s where 1=1";
|
||||
string sql = "select count(*) from bxx.sku_img_replace s where 1=1";
|
||||
|
||||
string where = "";
|
||||
if (!string.IsNullOrWhiteSpace(sku_img_replace_ids))
|
||||
@@ -703,7 +709,7 @@ namespace KJD_Web.BLL.BXX
|
||||
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
||||
MysqlUtils mySql = new MysqlUtils(conn);
|
||||
|
||||
string sql = "select count(id) from bxx.product p where p.is_del=0";
|
||||
string sql = "select count(*) from bxx.product p where p.is_del=0";
|
||||
|
||||
string where = "";
|
||||
if (!string.IsNullOrEmpty(in_ext_codes))
|
||||
@@ -828,6 +834,8 @@ namespace KJD_Web.BLL.BXX
|
||||
}
|
||||
var data = JsonUtils.SerializerObjectToString(productLst);
|
||||
var seconds = (DateTime.Now - timeCalc).TotalSeconds.ToString("0.000");
|
||||
if (product_get_type == "厂商直采" && count > 500)
|
||||
count *= 3;
|
||||
return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"count\":" + count + ",\"seconds\":" + seconds + "}";
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -844,7 +852,7 @@ namespace KJD_Web.BLL.BXX
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 随机获取商品(无详情) 随机添加到上传列表所以不需要获取详情
|
||||
/// 获取拼多多商品随机sku替换图
|
||||
/// </summary>
|
||||
/// <param name="inputData"></param>
|
||||
/// <returns></returns>
|
||||
@@ -868,7 +876,7 @@ namespace KJD_Web.BLL.BXX
|
||||
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
||||
MysqlUtils mySql = new MysqlUtils(conn);
|
||||
|
||||
string sql = "select count(id) from bxx.sku_img_replace s where 1=1";
|
||||
string sql = "select count(*) from bxx.sku_img_replace s where 1=1";
|
||||
|
||||
string where = "";
|
||||
if (!string.IsNullOrWhiteSpace(in_img_type) && !string.IsNullOrWhiteSpace(in_img_group))
|
||||
@@ -1868,6 +1876,18 @@ namespace KJD_Web.BLL.BXX
|
||||
if (time1 != EncrypUtil.Encryption(time))
|
||||
return "{\"code\":50000,\"msg\":\"校验失败\"}";
|
||||
|
||||
string img_base64 = RegexUtils.GetStringQuery(ref inputData, "img_base64")?.Replace("'", "\\'");
|
||||
if (!string.IsNullOrEmpty(img_base64))
|
||||
{
|
||||
return WxApiUploadImageBase64(inputData, img_base64);
|
||||
}
|
||||
bool is_file = RegexUtils.GetStringQuery(ref inputData, "is_file")?.Replace("'", "\\'").ToLower() == "true";
|
||||
if (is_file)
|
||||
{
|
||||
return WxApiUploadImageFile(inputData);
|
||||
}
|
||||
|
||||
|
||||
string post_data = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "post_data"));
|
||||
string token = RegexUtils.GetStringQuery(ref inputData, "token");
|
||||
|
||||
@@ -1877,6 +1897,133 @@ namespace KJD_Web.BLL.BXX
|
||||
}
|
||||
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
||||
}
|
||||
|
||||
public string WxApiUploadImageFile(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 token = RegexUtils.GetStringQuery(ref inputData, "token")?.Replace("'", "\\'");
|
||||
string img_url = RegexUtils.GetStringQuery(ref inputData, "img_url")?.Replace("'", "\\'");
|
||||
string random_code = RegexUtils.GetStringQuery(ref inputData, "random_code")?.Replace("'", "\\'");
|
||||
int img_width = RegexUtils.GetStringQuery(ref inputData, "width").ParseToInt();
|
||||
int img_height = RegexUtils.GetStringQuery(ref inputData, "height").ParseToInt();
|
||||
bool is_keep_file = RegexUtils.GetStringQuery(ref inputData, "is_keep_file").ParseToBool();
|
||||
|
||||
string getImgError;
|
||||
var image = HttpUtils.GetUrlImg(img_url.Replace("https://", "http://"), out getImgError);
|
||||
if (!string.IsNullOrEmpty(getImgError) || image == null)
|
||||
{
|
||||
return "{\"code\":50001,\"msg\":\"获取图片失败:" + getImgError + "\"}";
|
||||
}
|
||||
try
|
||||
{
|
||||
if (img_width.IsNullOrZero() || img_height.IsNullOrZero())
|
||||
{
|
||||
img_width = image.Width;
|
||||
img_height = image.Height;
|
||||
}
|
||||
var imageBg = new Bitmap(img_width, img_height);
|
||||
using (Graphics g = Graphics.FromImage(imageBg))
|
||||
{
|
||||
g.DrawImage(image, new Rectangle(0, 0, imageBg.Width, imageBg.Height), 0, 0, image.Width, image.Height, GraphicsUnit.Pixel);
|
||||
if (!string.IsNullOrEmpty(random_code) && random_code.ToLower() == "true")
|
||||
{
|
||||
g.FillRectangle(new SolidBrush(Color.FromArgb(RandomUtils.GetId(256), RandomUtils.GetId(256), RandomUtils.GetId(256))),
|
||||
new Rectangle(RandomUtils.GetId(imageBg.Width - 30), RandomUtils.GetId(imageBg.Height - 30), 30, 30));
|
||||
}
|
||||
}
|
||||
|
||||
//string tempImgPath = Path.GetTempPath() + "\\" + RandomUtils.GetWordNumber(8).ToLower();
|
||||
string tempImgPath = "C:\\tempImg\\" + RandomUtils.GetWordNumber(8).ToLower();
|
||||
if (!Directory.Exists(tempImgPath))
|
||||
Directory.CreateDirectory(tempImgPath);
|
||||
string imgFullPath = tempImgPath + "\\" + EncrypUtil.GetMd5(img_url) + ".jpg";
|
||||
imageBg.Save(imgFullPath, System.Drawing.Imaging.ImageFormat.Jpeg);
|
||||
|
||||
var apiUpImgFileRst = HttpUtils.WxApiUploadImgFile(imgFullPath, imageBg.Width, imageBg.Height, token);
|
||||
if (string.IsNullOrEmpty(apiUpImgFileRst))
|
||||
apiUpImgFileRst = "{\"code\":50002,\"msg\":\"图片传输超时\"}";
|
||||
|
||||
if (!is_keep_file)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 删除文件夹及其所有内容
|
||||
Directory.Delete(tempImgPath, true); // 第二个参数为true表示递归删除所有子文件夹和文件
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
return apiUpImgFileRst;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return "{\"code\":50001,\"msg\":\"上传图片失败:" + ex.Message + "\"}";
|
||||
}
|
||||
|
||||
}
|
||||
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
||||
}
|
||||
|
||||
public string WxApiUploadImageBase64(string inputData, string imgBase64)
|
||||
{
|
||||
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 token = RegexUtils.GetStringQuery(ref inputData, "token")?.Replace("'", "\\'");
|
||||
string img_url = RegexUtils.GetStringQuery(ref inputData, "img_url")?.Replace("'", "\\'");
|
||||
bool is_keep_file = RegexUtils.GetStringQuery(ref inputData, "is_keep_file").ParseToBool();
|
||||
|
||||
try
|
||||
{
|
||||
byte[] imageBytes = Convert.FromBase64String(imgBase64);
|
||||
using (MemoryStream ms = new MemoryStream(imageBytes, 0, imageBytes.Length))
|
||||
{
|
||||
// 创建Image对象
|
||||
Image imageBg = Image.FromStream(ms, true);
|
||||
|
||||
string tempImgPath = "C:\\tempImg\\" + RandomUtils.GetWordNumber(16).ToLower();
|
||||
if (!Directory.Exists(tempImgPath))
|
||||
Directory.CreateDirectory(tempImgPath);
|
||||
string imgFullPath = tempImgPath + "\\" + EncrypUtil.GetMd5(img_url) + ".jpg";
|
||||
imageBg.Save(imgFullPath, System.Drawing.Imaging.ImageFormat.Jpeg);
|
||||
|
||||
var apiUpImgFileRst = HttpUtils.WxApiUploadImgFile(imgFullPath, imageBg.Width, imageBg.Height, token);
|
||||
if (string.IsNullOrEmpty(apiUpImgFileRst))
|
||||
apiUpImgFileRst = "{\"code\":50002,\"msg\":\"图片传输超时\"}";
|
||||
|
||||
if (!is_keep_file)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 删除文件夹及其所有内容
|
||||
Directory.Delete(tempImgPath, true); // 第二个参数为true表示递归删除所有子文件夹和文件
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
return apiUpImgFileRst;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return "{\"code\":50001,\"msg\":\"上传图片失败:" + ex.Message + "\"}";
|
||||
}
|
||||
|
||||
}
|
||||
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user