Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mall.oytour.com
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
黄奎
mall.oytour.com
Commits
34790e63
Commit
34790e63
authored
Jun 03, 2020
by
liudong1993
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
d22cba26
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
275 additions
and
4 deletions
+275
-4
Mall.Common.csproj
Mall.Common/Mall.Common.csproj
+1
-0
HtmlToImgHelper.cs
Mall.Common/Plugin/HtmlToImgHelper.cs
+227
-0
StringHelper.cs
Mall.Common/Plugin/StringHelper.cs
+18
-0
OrderModule.cs
Mall.Module.Product/OrderModule.cs
+2
-2
UserModule.cs
Mall.Module.User/UserModule.cs
+1
-1
RB_Distributor_HPGradeInfoRepository.cs
Mall.Repository/User/RB_Distributor_HPGradeInfoRepository.cs
+3
-0
AppletGoodsController.cs
Mall.WebApi/Controllers/Product/AppletGoodsController.cs
+13
-0
AppletOrderController.cs
Mall.WebApi/Controllers/Product/AppletOrderController.cs
+10
-1
No files found.
Mall.Common/Mall.Common.csproj
View file @
34790e63
...
...
@@ -15,6 +15,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="CoreHtmlToImage" Version="1.0.6" />
<PackageReference Include="LumenWorks.Framework.IO.Core" Version="1.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" />
...
...
Mall.Common/Plugin/HtmlToImgHelper.cs
0 → 100644
View file @
34790e63
using
System
;
using
System.Collections.Generic
;
using
System.Drawing
;
using
System.IO
;
using
System.Linq
;
using
System.Net
;
using
System.Text
;
using
System.Text.RegularExpressions
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
CoreHtmlToImage
;
namespace
Mall.Common.Plugin
{
/// <summary>
/// htmlToimg工具类
/// </summary>
public
class
HtmlToImgHelper
{
//Bitmap m_Bitmap;
//string m_Url;
//int m_BrowserWidth, m_BrowserHeight, m_ThumbnailWidth, m_ThumbnailHeight;
//public HtmlToImgHelper(string Url, int BrowserWidth, int BrowserHeight, int ThumbnailWidth, int ThumbnailHeight)
//{
// m_Url = Url;
// m_BrowserHeight = BrowserHeight;
// m_BrowserWidth = BrowserWidth;
// m_ThumbnailWidth = ThumbnailWidth;
// m_ThumbnailHeight = ThumbnailHeight;
//}
//public static Bitmap GetWebSiteThumbnail(string Url, int BrowserWidth, int BrowserHeight, int ThumbnailWidth, int ThumbnailHeight)
//{
// HtmlToImgHelper thumbnailGenerator = new HtmlToImgHelper(Url, BrowserWidth, BrowserHeight, ThumbnailWidth, ThumbnailHeight);
// return thumbnailGenerator.GenerateWebSiteThumbnailImage();
//}
//public Bitmap GenerateWebSiteThumbnailImage()
//{
// Thread m_thread = new Thread(new ThreadStart(_GenerateWebSiteThumbnailImage));
// m_thread.SetApartmentState(ApartmentState.STA);
// m_thread.Start();
// m_thread.Join();
// return m_Bitmap;
//}
//private void _GenerateWebSiteThumbnailImage()
//{
// WebBrowser m_WebBrowser = new WebBrowser();
// m_WebBrowser.ScrollBarsEnabled = false;
// m_WebBrowser.Navigate(m_Url);
// m_WebBrowser.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(WebBrowser_DocumentCompleted);
// while (m_WebBrowser.ReadyState != WebBrowserReadyState.Complete)
// Application.DoEvents();
// m_WebBrowser.Dispose();
//}
//private void WebBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
//{
// WebBrowser m_WebBrowser = (WebBrowser)sender;
// m_WebBrowser.ClientSize = new Size(this.m_BrowserWidth, this.m_BrowserHeight);
// m_WebBrowser.ScrollBarsEnabled = false;
// m_Bitmap = new Bitmap(m_WebBrowser.Bounds.Width, m_WebBrowser.Bounds.Height);
// m_WebBrowser.BringToFront();
// m_WebBrowser.DrawToBitmap(m_Bitmap, m_WebBrowser.Bounds);
// m_Bitmap = (Bitmap)m_Bitmap.GetThumbnailImage(m_ThumbnailWidth, m_ThumbnailHeight, null, IntPtr.Zero);
//}
//public string GetHtmlToImgString() {
// Bitmap m_Bitmap = GetWebSiteThumbnail("这里是html的连接地址", 990, 2798, 990, 2798);
// MemoryStream ms = new MemoryStream();
// m_Bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Png);//JPG、GIF、PNG等均可
// byte[] buff = ms.ToArray();
// Response.BinaryWrite(buff);
// System.Drawing.Image img = byteArrayToImage(buff);
// string url = "图片保存路径.png";
// img.Save(url);
//}
public
string
GetHtmlToImage
()
{
var
converter
=
new
HtmlConverter
();
string
html
=
"<div>hello world</div>"
;
Encoding
.
RegisterProvider
(
CodePagesEncodingProvider
.
Instance
);
html
=
StringHelper
.
GetFileContent
(
"E:/LDWork/LiuDongWork/OnLineItem/MallNew/Mall.WebApi/upfile/temimg/新建文本文档.txt"
,
Encoding
.
GetEncoding
(
"gb2312"
));
byte
[]
byte1
=
converter
.
FromHtmlString
(
html
,
385
);
string
str
=
System
.
Text
.
Encoding
.
Default
.
GetString
(
byte1
);
//Bitmap bitmap = BytesToBitmap(byte1, 385, 675);
Bitmap
bitmap
=
BytesToBitmap2
(
byte1
);
string
url
=
"E:/LDWork/LiuDongWork/OnLineItem/MallNew/Mall.WebApi/upfile/temimg/图片保存路径.jpg"
;
bitmap
.
Save
(
url
,
System
.
Drawing
.
Imaging
.
ImageFormat
.
Jpeg
);
return
url
;
}
//public string GetHtmlToImg_V2(string fileName) {
// byte[] byte1 = StreamToBytes(FileToStream(fileName));
// Bitmap bitmap = BytesToBitmap(byte1, 385, 675);
// //MemoryStream ms = new MemoryStream();
// //bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);//JPG、GIF、PNG等均可
// string url = "图片保存路径.png";
// bitmap.Save(url, System.Drawing.Imaging.ImageFormat.Jpeg);
// return url;
//}
//byte[] 转图片
public
static
Bitmap
BytesToBitmap
(
byte
[]
Bytes
,
int
width
,
int
heiht
)
{
MemoryStream
stream
=
null
;
try
{
stream
=
new
MemoryStream
(
Bytes
);
return
new
Bitmap
((
Image
)
new
Bitmap
(
stream
),
width
,
heiht
);
}
catch
(
ArgumentNullException
ex
)
{
throw
ex
;
}
catch
(
ArgumentException
ex
)
{
throw
ex
;
}
finally
{
stream
.
Close
();
}
}
public
static
Bitmap
BytesToBitmap2
(
byte
[]
Bytes
)
{
MemoryStream
stream
=
null
;
try
{
stream
=
new
MemoryStream
(
Bytes
);
return
new
Bitmap
((
Image
)
new
Bitmap
(
stream
));
}
catch
(
ArgumentNullException
ex
)
{
throw
ex
;
}
catch
(
ArgumentException
ex
)
{
throw
ex
;
}
finally
{
stream
.
Close
();
}
}
//图片转byte[]
public
static
byte
[]
BitmapToBytes
(
Bitmap
Bitmap
)
{
MemoryStream
ms
=
null
;
try
{
ms
=
new
MemoryStream
();
Bitmap
.
Save
(
ms
,
Bitmap
.
RawFormat
);
byte
[]
byteImage
=
new
Byte
[
ms
.
Length
];
byteImage
=
ms
.
ToArray
();
return
byteImage
;
}
catch
(
ArgumentNullException
ex
)
{
throw
ex
;
}
finally
{
ms
.
Close
();
}
}
/// <summary>
/// 将 Stream 转成 byte[]
/// </summary>
public
byte
[]
StreamToBytes
(
Stream
stream
)
{
byte
[]
bytes
=
new
byte
[
stream
.
Length
];
stream
.
Read
(
bytes
,
0
,
bytes
.
Length
);
// 设置当前流的位置为流的开始
stream
.
Seek
(
0
,
SeekOrigin
.
Begin
);
return
bytes
;
}
/// <summary>
/// 将 byte[] 转成 Stream
/// </summary>
public
Stream
BytesToStream
(
byte
[]
bytes
)
{
Stream
stream
=
new
MemoryStream
(
bytes
);
return
stream
;
}
/// <summary>
/// 将 Stream 写入文件
/// </summary>
public
void
StreamToFile
(
Stream
stream
,
string
fileName
)
{
// 把 Stream 转换成 byte[]
byte
[]
bytes
=
new
byte
[
stream
.
Length
];
stream
.
Read
(
bytes
,
0
,
bytes
.
Length
);
// 设置当前流的位置为流的开始
stream
.
Seek
(
0
,
SeekOrigin
.
Begin
);
// 把 byte[] 写入文件
FileStream
fs
=
new
FileStream
(
fileName
,
FileMode
.
Create
);
BinaryWriter
bw
=
new
BinaryWriter
(
fs
);
bw
.
Write
(
bytes
);
bw
.
Close
();
fs
.
Close
();
}
/// <summary>
/// 从文件读取 Stream
/// </summary>
public
Stream
FileToStream
(
string
fileName
)
{
// 打开文件
FileStream
fileStream
=
new
FileStream
(
fileName
,
FileMode
.
Open
,
FileAccess
.
Read
,
FileShare
.
Read
);
// 读取文件的 byte[]
byte
[]
bytes
=
new
byte
[
fileStream
.
Length
];
fileStream
.
Read
(
bytes
,
0
,
bytes
.
Length
);
fileStream
.
Close
();
// 把 byte[] 转换成 Stream
Stream
stream
=
new
MemoryStream
(
bytes
);
return
stream
;
}
}
}
Mall.Common/Plugin/StringHelper.cs
View file @
34790e63
...
...
@@ -1443,6 +1443,24 @@ namespace Mall.Common.Plugin
}
}
/// <summary>
/// 获取文件内容
/// </summary>
/// <param name="filePath">文件路径</param>
/// <returns></returns>
public
static
string
GetFileContent
(
string
filePath
,
Encoding
encoding
)
{
if
(
File
.
Exists
(
filePath
))
{
string
content
=
File
.
ReadAllText
(
filePath
,
encoding
);
return
content
;
}
else
{
return
""
;
}
}
/// <summary>
/// 替换索引出为“*”
/// </summary>
...
...
Mall.Module.Product/OrderModule.cs
View file @
34790e63
...
...
@@ -216,9 +216,9 @@ namespace Mall.Module.Product
item
.
CoverImage
=
""
;
if
(!
string
.
IsNullOrEmpty
(
item
.
CarouselImage
)
&&
item
.
CarouselImage
!=
"[]"
)
{
List
<
int
>
CarouselIdList
=
JsonConvert
.
DeserializeObject
<
List
<
int
>>(
item
.
CarouselImage
);
List
<
string
>
CarouselIdList
=
JsonConvert
.
DeserializeObject
<
List
<
string
>>(
item
.
CarouselImage
);
//封面图
item
.
CoverImage
=
material_InfoRepository
.
GetEntity
(
CarouselIdList
[
0
])?.
Path
??
""
;
item
.
CoverImage
=
CarouselIdList
[
0
]
;
}
//验证规格是否已失效
if
(
item
.
IsCustomSpecification
==
1
)
...
...
Mall.Module.User/UserModule.cs
View file @
34790e63
...
...
@@ -1518,7 +1518,7 @@ namespace Mall.Module.User
{
return
"用户分销等级与上级用户分销等级不是上下级关系 ID:"
+
item
.
UserId
;
}
else
if
((
hpgmodel
.
Grade
??
0
)
-
(
gmodel
?.
Grade
??
0
)
!=
1
)
else
if
((
gmodel
?.
Grade
??
0
)
-
(
hpgmodel
.
Grade
??
0
)
!=
1
)
{
return
"用户分销等级与上级用户分销等级不是上下级关系 ID:"
+
item
.
UserId
;
}
...
...
Mall.Repository/User/RB_Distributor_HPGradeInfoRepository.cs
View file @
34790e63
...
...
@@ -79,6 +79,9 @@ namespace Mall.Repository.User
{
where
+=
$@" and
{
nameof
(
RB_Distributor_HPGradeInfo
.
GradeName
)}
like '%
{
dmodel
.
GradeName
}
%'"
;
}
if
(
dmodel
.
IsGuest
==
2
)
{
where
+=
$@" and
{
nameof
(
RB_Distributor_HPGradeInfo
.
IsGuest
)}
=
{
dmodel
.
IsGuest
}
"
;
}
string
sql
=
$@"select * from RB_Distributor_HPGradeInfo where
{
where
}
order by Grade asc"
;
return
Get
<
RB_Distributor_HPGradeInfo_Extend
>(
sql
).
ToList
();
...
...
Mall.WebApi/Controllers/Product/AppletGoodsController.cs
View file @
34790e63
...
...
@@ -1129,5 +1129,18 @@ namespace Mall.WebApi.Controllers.MallBase
}
#
endregion
#
region
生产海报
/// <summary>
/// 商品海报
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
GetGoodsPoster
()
{
string
address
=
new
HtmlToImgHelper
().
GetHtmlToImage
();
return
ApiResult
.
Success
(
""
,
address
);
}
#
endregion
}
}
\ No newline at end of file
Mall.WebApi/Controllers/Product/AppletOrderController.cs
View file @
34790e63
...
...
@@ -46,7 +46,8 @@ namespace Mall.WebApi.Controllers.MallBase
demodel
.
UserId
=
userInfo
.
UserId
;
var
list
=
orderModule
.
GetGoodsShoppingCartPageList
(
pagelist
.
pageIndex
,
pagelist
.
pageSize
,
out
long
count
,
demodel
);
pagelist
.
count
=
Convert
.
ToInt32
(
count
);
pagelist
.
pageData
=
list
.
Select
(
x
=>
new
var
MallModel
=
orderModule
.
GetMiniProgramExtend
(
userInfo
.
MallBaseId
);
var
listobj
=
list
.
Select
(
x
=>
new
{
x
.
Id
,
x
.
GoodsId
,
...
...
@@ -61,6 +62,14 @@ namespace Mall.WebApi.Controllers.MallBase
x
.
MallBaseId
,
CreateDate
=
x
.
CreateDate
.
HasValue
?
x
.
CreateDate
.
Value
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
)
:
""
});
List
<
object
>
robj
=
new
List
<
object
>()
{
new
{
MallId
=
MallModel
?.
MallBaseId
??
0
,
MallName
=
MallModel
?.
MallName
??
""
,
GoodsList
=
listobj
}
};
pagelist
.
pageData
=
robj
;
return
ApiResult
.
Success
(
""
,
pagelist
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment