用户消费统计 标题筛选逻辑优化

This commit is contained in:
wule committed 2026-08-10 19:30:27 +08:00
1 parent fe39437968
commit 35240505e3
10 files changed
+712 -239

No files matched your search

@@ -1,6 +1,7 @@
using AllBase;
using AllBase.Model.Param.TemuProductManage;
using AllBase.Model.Result;
using NaiBa.Util;
using NaiBa.Util.Extension;
using Newtonsoft.Json.Linq;
using System;
@@ -11,16 +12,16 @@ using System.Drawing;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Security.Policy;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using TemuKJD.BaseForms;
using TemuKJD.BLL;
using TemuKJD.Extension;
using TemuKJD.BaseForms;
using Work;
using NaiBa.Util;
using TemuKJD.WXForms.ShopForms;
using Work;
namespace TemuKJD.WXForms.AdminForms
{
@@ -149,11 +150,7 @@ namespace TemuKJD.WXForms.AdminForms
private void pnlEmpty_Click(object sender, EventArgs e)
{
this.txtUserName.Text = "";
this.txtLoginName.Text = "";
this.txtNotes.Text = "";
this.txtShopId.Text = "";
this.txtShopName.Text = "";
this.txtCatName.Text = "";
}
bool IsOperate { get; set; } = false;
@@ -225,14 +222,10 @@ namespace TemuKJD.WXForms.AdminForms
seconds = 0;
var url = BaseClass.BuildObjString("shop/admin_get_server_qualification_image_list");
var data = UserLogin.GetSignaturex() +
"&page=" + page +
var data = UserLogin.GetSignaturex() +
"&page=" + page +
"&page_size=" + pageSize +
"&search_user_name=" + txtUserName.Text.Trim() +
"&search_login_name=" + txtLoginName.Text.Trim() +
"&search_notes=" + txtNotes.Text.Trim() +
"&search_id=" + txtShopId.Text.Trim() +
"&search_name=" + txtShopName.Text.Trim();
"&search_cat_name=" + txtCatName.Text.Trim();
if (BaseClass.SaLevel > 1)
data += "&operate_sub_sa_name=" + BaseClass.UserName;
var html = GetHtml.PostUtf8(url, data);
@@ -253,5 +246,210 @@ namespace TemuKJD.WXForms.AdminForms
private void dgvShop_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
{
}
public static Image EmptyImage = null;
private void btnUploadImg_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Multiselect = false;
// 设置过滤条件,只显示文本文件
openFileDialog.Filter = "图片文件 (*.jpeg;*.jpg;*.png)|*.jpeg;*.jpg;*.png|All files (*.*)|*.*";
// 显示对话框并获取结果
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
try
{
string filePath = openFileDialog.FileName;
Image imageSource = Image.FromFile(filePath);
EmptyImage = new Bitmap(900, 1200);
using (Graphics g = Graphics.FromImage(EmptyImage))
{
g.DrawImage(imageSource, new Rectangle(0, 0, EmptyImage.Width, EmptyImage.Height), 0, 0, imageSource.Width, imageSource.Height, GraphicsUnit.Pixel);
}
string imgBase64 = "";
using (MemoryStream memoryStream = new MemoryStream())
{
EmptyImage.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Jpeg);
byte[] imageBytes = memoryStream.ToArray();
imgBase64 = Convert.ToBase64String(imageBytes);
}
if (this.pictureBox1.Tag.ParseToString() != imgBase64)
{
this.pictureBox1.Tag = imgBase64;
this.pictureBox1.ImageLocation = "";
Image image = new Bitmap(900, 1200);
using (Graphics g = Graphics.FromImage(image))
{
g.DrawImage(EmptyImage, new Rectangle(0, 0, image.Width, image.Height), 0, 0, EmptyImage.Width, EmptyImage.Height, GraphicsUnit.Pixel);
}
DrawText(image, txtLeft.Text.ParseToInt(), txtTop.Text.ParseToInt(), txtRight.Text.ParseToInt(), txtBottom.Text.ParseToInt());
this.pictureBox1.Image = image;
}
}
catch (Exception ex)
{
BaseMsgForm.ShowError("打开自定义sku图片失败 " + ex.Message);
return;
}
}
}
public static void DrawText(Image img, int _txtLeft, int _txtTop, int _txtRight, int _txtBottom)
{
if (img == null)
return;
string bookName = "行走中国 : 人文风情和自然生态发现之旅";
string author = "雷东军";
string publisher = "中国工人出版社";
string isbn = "978-7-500-87761-5";
string binding = "装  帧:平装";
string edition = "版  次:1";
string publishTime = "2021-12-01";
string bookPrice = "37.39";
var bookImg = img;
var imgH = bookImg.Height;
var imgW = bookImg.Width;
using (Graphics g = Graphics.FromImage(bookImg))
{
Brush textBrush = Brushes.Black;
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
float txtTop = _txtTop;
float txtBottom = _txtBottom;
float txtLeft = _txtLeft;
float txtRight = _txtRight;
int txtWidth = (int)imgW - (int)txtLeft - (int)txtRight; // 370;
// 书名
Font font = new Font("宋体", 22, FontStyle.Bold);
RectangleF rectF = new RectangleF(txtLeft, txtTop, txtWidth, imgH - txtTop - 80);
g.DrawString(bookName.Replace("图书名称:", ""), font, textBrush, rectF);
// 测量文本的高度 决定接下来文字绘制位置
var textSize = g.MeasureString(bookName.Replace("图书名称:", ""), font, txtWidth);
txtTop += 20 + textSize.Height;
font = new Font("宋体", 15, FontStyle.Bold);
rectF = new RectangleF(txtLeft, txtTop, txtWidth, imgH - txtTop - 80);
g.DrawString(author.Replace("作  者:", "").TrimEnd('著', ' ') + " 著", font, textBrush, rectF);
// 测量文本的高度
textSize = g.MeasureString(author.Replace("作  者:", "").TrimEnd('著', ' ') + " 著", font, txtWidth);
txtTop += 20 + textSize.Height;
rectF = new RectangleF(txtLeft, txtTop, txtWidth, imgH - txtTop - 80);
g.DrawString(publisher.Replace("出版发行:", ""), font, textBrush, rectF);
// 测量文本的高度
textSize = g.MeasureString(publisher.Replace("出版发行:", ""), font, txtWidth);
txtTop += 20 + textSize.Height;
rectF = new RectangleF(txtLeft, txtTop, txtWidth, imgH - txtTop - 80);
g.DrawString(isbn.Replace("ISBN/CN刊号:", "ISBN "), font, textBrush, rectF);
// 测量文本的高度
textSize = g.MeasureString(isbn.Replace("ISBN/CN刊号:", "ISBN "), font, txtWidth);
txtTop += 20 + textSize.Height;
// 以下从下往上写
txtTop = imgH - txtBottom;
// 测量文本的高度
textSize = g.MeasureString(binding, font, txtWidth);
txtTop -= (10 + textSize.Height);
rectF = new RectangleF(txtLeft, txtTop, txtWidth, imgH - txtTop);
g.DrawString(binding, font, textBrush, rectF);
// 测量文本的高度
textSize = g.MeasureString(edition, font, txtWidth);
txtTop -= (10 + textSize.Height);
rectF = new RectangleF(txtLeft, txtTop, txtWidth, imgH - txtTop);
g.DrawString(edition, font, textBrush, rectF);
// 测量文本的高度
textSize = g.MeasureString(publishTime, font, txtWidth);
txtTop -= (10 + textSize.Height);
rectF = new RectangleF(txtLeft, txtTop, txtWidth, imgH - txtTop);
g.DrawString(publishTime, font, textBrush, rectF);
// 测量文本的高度
textSize = g.MeasureString(author, font, txtWidth);
txtTop -= (10 + textSize.Height);
rectF = new RectangleF(txtLeft, txtTop, txtWidth, imgH - txtTop);
g.DrawString(author, font, textBrush, rectF);
// 测量文本的高度
textSize = g.MeasureString(bookPrice + "元", font, txtWidth);
txtTop -= (10 + textSize.Height);
rectF = new RectangleF(txtLeft, txtTop, txtWidth, imgH - txtTop);
g.DrawString(bookPrice + "元", font, textBrush, rectF);
// 测量文本的高度
textSize = g.MeasureString(bookName, font, txtWidth);
txtTop -= (10 + textSize.Height);
rectF = new RectangleF(txtLeft, txtTop, txtWidth, imgH - txtTop);
g.DrawString(bookName, font, textBrush, rectF);
// 测量文本的高度
textSize = g.MeasureString(isbn.Replace("ISBN/CN刊号:", "书  号:ISBN "), font, txtWidth);
txtTop -= (10 + textSize.Height);
rectF = new RectangleF(txtLeft, txtTop, txtWidth, imgH - txtTop);
g.DrawString(isbn.Replace("ISBN/CN刊号:", "书  号:ISBN "), font, textBrush, rectF);
// 测量文本的高度
textSize = g.MeasureString(publisher, font, txtWidth);
txtTop -= (10 + textSize.Height);
rectF = new RectangleF(txtLeft, txtTop, txtWidth, imgH - txtTop);
g.DrawString(publisher, font, textBrush, rectF);
}
}
private void txt_TextChanged(object sender, EventArgs e)
{
Image image = new Bitmap(900, 1200);
using (Graphics g = Graphics.FromImage(image))
{
g.DrawImage(EmptyImage, new Rectangle(0, 0, image.Width, image.Height), 0, 0, EmptyImage.Width, EmptyImage.Height, GraphicsUnit.Pixel);
}
DrawText(image, txtLeft.Text.ParseToInt(), txtTop.Text.ParseToInt(), txtRight.Text.ParseToInt(), txtBottom.Text.ParseToInt());
this.pictureBox1.Image = image;
}
private void btnSave_Click(object sender, EventArgs e)
{
if (pictureBox1.Tag.ParseToString().IsNullOrEmpty())
return;
var thumbImage = new Bitmap(90, 120);
using (Graphics g = Graphics.FromImage(thumbImage))
{
g.DrawImage(EmptyImage, new Rectangle(0, 0, thumbImage.Width, thumbImage.Height), 0, 0, EmptyImage.Width, EmptyImage.Height, GraphicsUnit.Pixel);
}
string thumbBase64 = "";
using (MemoryStream memoryStream = new MemoryStream())
{
thumbImage.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Jpeg);
byte[] imageBytes = memoryStream.ToArray();
thumbBase64 = Convert.ToBase64String(imageBytes);
}
var url = BaseClass.BuildWXObjString("product/wx_add_mdy_qualification_image");
var data = "";
Invoke(new Action(() =>
{
data = UserLogin.GetSignaturex();
data += "&img_md5=" + BaseClass.GetMd5(pictureBox1.Tag.ParseToString());
data += "&img_base64=" + pictureBox1.Tag.ParseToString();
data += "&txt_margin=" + txtLeft.Text.ParseToInt() + "," + txtTop.Text.ParseToInt() + "," + txtRight.Text.ParseToInt() + "," + txtBottom.Text.ParseToInt();
data += "&img_thumb_base64=" + thumbBase64;
}));
var html = GetHtml.PostUtf8(url, data);
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
html = GetHtml.PostUtf8(url, data);
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
html = GetHtml.PostUtf8(url, data);
}
}
}