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
c873ac83
Commit
c873ac83
authored
Sep 23, 2021
by
黄奎
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
页面修改
parent
77d2c9fe
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
211 additions
and
750 deletions
+211
-750
ExcelTempLateHelper.cs
Mall.Common/Plugin/ExcelTempLateHelper.cs
+52
-138
NPOIHelper.cs
Mall.Common/Plugin/NPOIHelper.cs
+1
-396
ProductModule.cs
Mall.Module.Product/ProductModule.cs
+3
-91
CarrierModule.cs
Mall.Module.TradePavilion/CarrierModule.cs
+2
-3
FirstShopListModule.cs
Mall.Module.TradePavilion/FirstShopListModule.cs
+66
-94
UserModule.cs
Mall.Module.User/UserModule.cs
+8
-9
AppletGoodsController.cs
Mall.WebApi/Controllers/Product/AppletGoodsController.cs
+2
-6
ProductController.cs
Mall.WebApi/Controllers/Product/ProductController.cs
+1
-1
TradeController.cs
Mall.WebApi/Controllers/TradePavilion/TradeController.cs
+1
-1
UserController.cs
Mall.WebApi/Controllers/User/UserController.cs
+1
-1
ApiFilterAttribute.cs
Mall.WebApi/Filter/ApiFilterAttribute.cs
+1
-10
ApiTokenHelper.cs
Mall.WebApi/Helper/ApiTokenHelper.cs
+73
-0
No files found.
Mall.Common/Plugin/ExcelTempLateHelper.cs
View file @
c873ac83
...
@@ -27,7 +27,7 @@ namespace Mall.Common.Plugin
...
@@ -27,7 +27,7 @@ namespace Mall.Common.Plugin
public
static
byte
[]
ToExcel
(
List
<
ExcelDataSource
>
list
,
bool
isTempLate
=
false
,
string
tempLatePath
=
""
)
public
static
byte
[]
ToExcel
(
List
<
ExcelDataSource
>
list
,
bool
isTempLate
=
false
,
string
tempLatePath
=
""
)
{
{
HSSFWorkbook
workbook
=
null
;
HSSFWorkbook
workbook
=
null
;
HSSFSheet
sheet
=
null
;
HSSFSheet
sheet
;
if
(
isTempLate
&&
!
string
.
IsNullOrEmpty
(
tempLatePath
.
Trim
()))
if
(
isTempLate
&&
!
string
.
IsNullOrEmpty
(
tempLatePath
.
Trim
()))
{
{
using
(
FileStream
file
=
new
FileStream
(
tempLatePath
,
FileMode
.
Open
,
FileAccess
.
Read
))
using
(
FileStream
file
=
new
FileStream
(
tempLatePath
,
FileMode
.
Open
,
FileAccess
.
Read
))
...
@@ -42,8 +42,6 @@ namespace Mall.Common.Plugin
...
@@ -42,8 +42,6 @@ namespace Mall.Common.Plugin
workbook
=
new
HSSFWorkbook
();
workbook
=
new
HSSFWorkbook
();
sheet
=
workbook
.
CreateSheet
()
as
HSSFSheet
;
sheet
=
workbook
.
CreateSheet
()
as
HSSFSheet
;
}
}
HSSFPalette
palette
=
workbook
.
GetCustomPalette
();
int
rowIndex
=
0
;
int
rowIndex
=
0
;
//循环添加行
//循环添加行
foreach
(
var
item
in
list
)
foreach
(
var
item
in
list
)
...
@@ -125,6 +123,12 @@ namespace Mall.Common.Plugin
...
@@ -125,6 +123,12 @@ namespace Mall.Common.Plugin
case
ColorEnum
.
Yellow
:
case
ColorEnum
.
Yellow
:
ffont
.
Color
=
HSSFColor
.
Yellow
.
Index
;
ffont
.
Color
=
HSSFColor
.
Yellow
.
Index
;
break
;
break
;
case
ColorEnum
.
Default
:
break
;
case
ColorEnum
.
BrightGreen
:
break
;
case
ColorEnum
.
DarkBlue
:
break
;
default
:
default
:
ffont
.
Color
=
HSSFColor
.
Black
.
Index
;
ffont
.
Color
=
HSSFColor
.
Black
.
Index
;
break
;
break
;
...
@@ -133,45 +137,27 @@ namespace Mall.Common.Plugin
...
@@ -133,45 +137,27 @@ namespace Mall.Common.Plugin
//字体加粗
//字体加粗
if
(
subItem
.
IsBold
)
if
(
subItem
.
IsBold
)
{
{
ffont
.
Boldweight
=
(
short
)
NPOI
.
SS
.
UserModel
.
FontBoldWeight
.
Bold
;
ffont
.
IsBold
=
subItem
.
Is
Bold
;
}
}
fCellStyle
.
SetFont
(
ffont
);
fCellStyle
.
SetFont
(
ffont
);
//水平对齐方式
//水平对齐方式
switch
(
subItem
.
HAlignmentEnum
)
fCellStyle
.
Alignment
=
subItem
.
HAlignmentEnum
switch
{
{
case
HAlignmentEnum
.
CENTER
:
HAlignmentEnum
.
CENTER
=>
HorizontalAlignment
.
Center
,
fCellStyle
.
Alignment
=
NPOI
.
SS
.
UserModel
.
HorizontalAlignment
.
Center
;
HAlignmentEnum
.
LEFT
=>
HorizontalAlignment
.
Left
,
break
;
HAlignmentEnum
.
RIGHT
=>
HorizontalAlignment
.
Right
,
case
HAlignmentEnum
.
LEFT
:
_
=>
HorizontalAlignment
.
Center
,
fCellStyle
.
Alignment
=
NPOI
.
SS
.
UserModel
.
HorizontalAlignment
.
Left
;
};
break
;
case
HAlignmentEnum
.
RIGHT
:
fCellStyle
.
Alignment
=
NPOI
.
SS
.
UserModel
.
HorizontalAlignment
.
Right
;
break
;
default
:
fCellStyle
.
Alignment
=
NPOI
.
SS
.
UserModel
.
HorizontalAlignment
.
Center
;
break
;
}
//垂直对齐方式
//垂直对齐方式
switch
(
subItem
.
VAlignmentEnum
)
fCellStyle
.
VerticalAlignment
=
subItem
.
VAlignmentEnum
switch
{
{
case
VAlignmentEnum
.
CENTER
:
VAlignmentEnum
.
CENTER
=>
VerticalAlignment
.
Center
,
fCellStyle
.
VerticalAlignment
=
NPOI
.
SS
.
UserModel
.
VerticalAlignment
.
Center
;
VAlignmentEnum
.
TOP
=>
VerticalAlignment
.
Top
,
break
;
VAlignmentEnum
.
BOTTOM
=>
VerticalAlignment
.
Bottom
,
_
=>
VerticalAlignment
.
Center
,
case
VAlignmentEnum
.
TOP
:
};
fCellStyle
.
VerticalAlignment
=
NPOI
.
SS
.
UserModel
.
VerticalAlignment
.
Top
;
break
;
case
VAlignmentEnum
.
BOTTOM
:
fCellStyle
.
VerticalAlignment
=
NPOI
.
SS
.
UserModel
.
VerticalAlignment
.
Bottom
;
break
;
default
:
fCellStyle
.
VerticalAlignment
=
NPOI
.
SS
.
UserModel
.
VerticalAlignment
.
Center
;
break
;
}
if
(!
subItem
.
IsSetBorder
)
if
(!
subItem
.
IsSetBorder
)
{
{
fCellStyle
.
BorderBottom
=
BorderStyle
.
Thin
;
fCellStyle
.
BorderBottom
=
BorderStyle
.
Thin
;
...
@@ -191,40 +177,34 @@ namespace Mall.Common.Plugin
...
@@ -191,40 +177,34 @@ namespace Mall.Common.Plugin
{
{
var
region
=
new
CellRangeAddress
(
rowIndex
,
rowIndex
+
(
subItem
.
Rowspan
-
1
),
columnsIndex
,
columnsIndex
+
(
subItem
.
Colspan
-
1
));
var
region
=
new
CellRangeAddress
(
rowIndex
,
rowIndex
+
(
subItem
.
Rowspan
-
1
),
columnsIndex
,
columnsIndex
+
(
subItem
.
Colspan
-
1
));
sheet
.
AddMergedRegion
(
region
);
sheet
.
AddMergedRegion
(
region
);
for
(
int
i
=
region
.
FirstRow
;
i
<=
region
.
LastRow
;
i
++)
for
(
int
i
=
region
.
FirstRow
;
i
<=
region
.
LastRow
;
i
++)
{
{
IRow
row
=
HSSF
CellUtil
.
GetRow
(
i
,
sheet
);
IRow
row
=
CellUtil
.
GetRow
(
i
,
sheet
);
for
(
int
j
=
region
.
FirstColumn
;
j
<=
region
.
LastColumn
;
j
++)
for
(
int
j
=
region
.
FirstColumn
;
j
<=
region
.
LastColumn
;
j
++)
{
{
ICell
singleCell
=
HSSF
CellUtil
.
GetCell
(
row
,
(
short
)
j
);
ICell
singleCell
=
CellUtil
.
GetCell
(
row
,
(
short
)
j
);
singleCell
.
CellStyle
=
fCellStyle
;
singleCell
.
CellStyle
=
fCellStyle
;
}
}
}
}
columnsIndex
=
columnsIndex
+
subItem
.
Colspan
;
columnsIndex
+=
subItem
.
Colspan
;
}
}
else
else
{
{
cell
.
CellStyle
=
fCellStyle
;
cell
.
CellStyle
=
fCellStyle
;
columnsIndex
++;
columnsIndex
++;
}
}
cell
.
SetCellValue
(
subItem
.
Value
==
null
?
""
:
subItem
.
Value
);
cell
.
SetCellValue
(
subItem
.
Value
??
""
);
}
}
rowIndex
++;
rowIndex
++;
}
}
using
(
MemoryStream
ms
=
new
MemoryStream
())
using
MemoryStream
ms
=
new
MemoryStream
();
{
workbook
.
Write
(
ms
);
workbook
.
Write
(
ms
);
ms
.
Flush
();
ms
.
Flush
();
ms
.
Position
=
0
;
ms
.
Position
=
0
;
return
ms
.
ToArray
();
return
ms
.
ToArray
();
}
}
}
/// <summary>
/// <summary>
/// 模板导出
/// 模板导出
/// </summary>
/// </summary>
...
@@ -234,7 +214,7 @@ namespace Mall.Common.Plugin
...
@@ -234,7 +214,7 @@ namespace Mall.Common.Plugin
public
static
byte
[]
ToExcelExtend
(
List
<
ExcelDataSource
>
list
,
bool
isTempLate
=
false
,
string
tempLatePath
=
""
)
public
static
byte
[]
ToExcelExtend
(
List
<
ExcelDataSource
>
list
,
bool
isTempLate
=
false
,
string
tempLatePath
=
""
)
{
{
HSSFWorkbook
workbook
=
null
;
HSSFWorkbook
workbook
=
null
;
HSSFSheet
sheet
=
null
;
HSSFSheet
sheet
;
if
(
isTempLate
&&
!
string
.
IsNullOrEmpty
(
tempLatePath
.
Trim
()))
if
(
isTempLate
&&
!
string
.
IsNullOrEmpty
(
tempLatePath
.
Trim
()))
{
{
using
(
FileStream
file
=
new
FileStream
(
tempLatePath
,
FileMode
.
Open
,
FileAccess
.
Read
))
using
(
FileStream
file
=
new
FileStream
(
tempLatePath
,
FileMode
.
Open
,
FileAccess
.
Read
))
...
@@ -250,7 +230,7 @@ namespace Mall.Common.Plugin
...
@@ -250,7 +230,7 @@ namespace Mall.Common.Plugin
sheet
=
workbook
.
CreateSheet
()
as
HSSFSheet
;
sheet
=
workbook
.
CreateSheet
()
as
HSSFSheet
;
}
}
HSSFPalette
palette
=
workbook
.
GetCustomPalette
();
int
rowIndex
=
0
;
int
rowIndex
=
0
;
HSSFFont
ffont
=
(
HSSFFont
)
workbook
.
CreateFont
();
HSSFFont
ffont
=
(
HSSFFont
)
workbook
.
CreateFont
();
...
@@ -286,11 +266,9 @@ namespace Mall.Common.Plugin
...
@@ -286,11 +266,9 @@ namespace Mall.Common.Plugin
using
(
WebResponse
webResponse
=
webRequest
.
GetResponse
())
using
(
WebResponse
webResponse
=
webRequest
.
GetResponse
())
{
{
Bitmap
bitmap
=
new
Bitmap
(
webResponse
.
GetResponseStream
());
Bitmap
bitmap
=
new
Bitmap
(
webResponse
.
GetResponseStream
());
using
(
MemoryStream
ms
=
new
MemoryStream
())
using
MemoryStream
ms
=
new
MemoryStream
();
{
bitmap
.
Save
(
ms
,
ImageFormat
.
Jpeg
);
bitmap
.
Save
(
ms
,
System
.
Drawing
.
Imaging
.
ImageFormat
.
Jpeg
);
bytes
=
ms
.
ToArray
();
bytes
=
ms
.
ToArray
();
}
}
}
int
pictureIdx
=
workbook
.
AddPicture
(
bytes
,
PictureType
.
JPEG
);
int
pictureIdx
=
workbook
.
AddPicture
(
bytes
,
PictureType
.
JPEG
);
...
@@ -300,7 +278,7 @@ namespace Mall.Common.Plugin
...
@@ -300,7 +278,7 @@ namespace Mall.Common.Plugin
}
}
catch
(
Exception
ex
)
catch
{
{
}
}
...
@@ -367,45 +345,27 @@ namespace Mall.Common.Plugin
...
@@ -367,45 +345,27 @@ namespace Mall.Common.Plugin
//字体加粗
//字体加粗
if
(
subItem
.
IsBold
)
if
(
subItem
.
IsBold
)
{
{
ffont
.
Boldweight
=
(
short
)
NPOI
.
SS
.
UserModel
.
FontBoldWeight
.
Bold
;
ffont
.
IsBold
=
subItem
.
Is
Bold
;
}
}
fCellStyle
.
SetFont
(
ffont
);
fCellStyle
.
SetFont
(
ffont
);
//水平对齐方式
//水平对齐方式
switch
(
subItem
.
HAlignmentEnum
)
fCellStyle
.
Alignment
=
subItem
.
HAlignmentEnum
switch
{
{
case
HAlignmentEnum
.
CENTER
:
HAlignmentEnum
.
CENTER
=>
HorizontalAlignment
.
Center
,
fCellStyle
.
Alignment
=
NPOI
.
SS
.
UserModel
.
HorizontalAlignment
.
Center
;
HAlignmentEnum
.
LEFT
=>
HorizontalAlignment
.
Left
,
break
;
HAlignmentEnum
.
RIGHT
=>
HorizontalAlignment
.
Right
,
case
HAlignmentEnum
.
LEFT
:
_
=>
HorizontalAlignment
.
Center
,
fCellStyle
.
Alignment
=
NPOI
.
SS
.
UserModel
.
HorizontalAlignment
.
Left
;
};
break
;
case
HAlignmentEnum
.
RIGHT
:
fCellStyle
.
Alignment
=
NPOI
.
SS
.
UserModel
.
HorizontalAlignment
.
Right
;
break
;
default
:
fCellStyle
.
Alignment
=
NPOI
.
SS
.
UserModel
.
HorizontalAlignment
.
Center
;
break
;
}
//垂直对齐方式
//垂直对齐方式
switch
(
subItem
.
VAlignmentEnum
)
fCellStyle
.
VerticalAlignment
=
subItem
.
VAlignmentEnum
switch
{
{
case
VAlignmentEnum
.
CENTER
:
VAlignmentEnum
.
CENTER
=>
VerticalAlignment
.
Center
,
fCellStyle
.
VerticalAlignment
=
NPOI
.
SS
.
UserModel
.
VerticalAlignment
.
Center
;
VAlignmentEnum
.
TOP
=>
VerticalAlignment
.
Top
,
break
;
VAlignmentEnum
.
BOTTOM
=>
VerticalAlignment
.
Bottom
,
_
=>
VerticalAlignment
.
Center
,
case
VAlignmentEnum
.
TOP
:
};
fCellStyle
.
VerticalAlignment
=
NPOI
.
SS
.
UserModel
.
VerticalAlignment
.
Top
;
break
;
case
VAlignmentEnum
.
BOTTOM
:
fCellStyle
.
VerticalAlignment
=
NPOI
.
SS
.
UserModel
.
VerticalAlignment
.
Bottom
;
break
;
default
:
fCellStyle
.
VerticalAlignment
=
NPOI
.
SS
.
UserModel
.
VerticalAlignment
.
Center
;
break
;
}
if
(!
subItem
.
IsSetBorder
)
if
(!
subItem
.
IsSetBorder
)
{
{
fCellStyle
.
BorderBottom
=
BorderStyle
.
Thin
;
fCellStyle
.
BorderBottom
=
BorderStyle
.
Thin
;
...
@@ -428,21 +388,21 @@ namespace Mall.Common.Plugin
...
@@ -428,21 +388,21 @@ namespace Mall.Common.Plugin
for
(
int
i
=
region
.
FirstRow
;
i
<=
region
.
LastRow
;
i
++)
for
(
int
i
=
region
.
FirstRow
;
i
<=
region
.
LastRow
;
i
++)
{
{
IRow
row
=
HSSF
CellUtil
.
GetRow
(
i
,
sheet
);
IRow
row
=
CellUtil
.
GetRow
(
i
,
sheet
);
for
(
int
j
=
region
.
FirstColumn
;
j
<=
region
.
LastColumn
;
j
++)
for
(
int
j
=
region
.
FirstColumn
;
j
<=
region
.
LastColumn
;
j
++)
{
{
ICell
singleCell
=
HSSF
CellUtil
.
GetCell
(
row
,
(
short
)
j
);
ICell
singleCell
=
CellUtil
.
GetCell
(
row
,
(
short
)
j
);
singleCell
.
CellStyle
=
fCellStyle
;
singleCell
.
CellStyle
=
fCellStyle
;
}
}
}
}
columnsIndex
=
columnsIndex
+
subItem
.
Colspan
;
columnsIndex
+=
subItem
.
Colspan
;
}
}
else
else
{
{
cell
.
CellStyle
=
fCellStyle
;
cell
.
CellStyle
=
fCellStyle
;
columnsIndex
++;
columnsIndex
++;
}
}
cell
.
SetCellValue
(
subItem
.
Value
==
null
?
""
:
subItem
.
Value
);
cell
.
SetCellValue
(
subItem
.
Value
??
""
);
}
}
}
}
...
@@ -457,52 +417,6 @@ namespace Mall.Common.Plugin
...
@@ -457,52 +417,6 @@ namespace Mall.Common.Plugin
return
ms
.
ToArray
();
return
ms
.
ToArray
();
}
}
}
}
#
region
[
颜色:
16
进制转成
RGB
]
/// <summary>
/// [颜色:16进制转成RGB]
/// </summary>
/// <param name="strColor">设置16进制颜色 [返回RGB]</param>
/// <returns></returns>
public
static
System
.
Drawing
.
Color
RGBToColor
(
string
strColor
)
{
try
{
if
(
strColor
.
Length
==
0
)
{
//如果为空
return
System
.
Drawing
.
Color
.
FromArgb
(
0
,
0
,
0
);
//设为黑色
}
else
{
//转换颜色
return
System
.
Drawing
.
Color
.
FromArgb
(
System
.
Int32
.
Parse
(
strColor
.
Substring
(
1
,
2
),
System
.
Globalization
.
NumberStyles
.
AllowHexSpecifier
),
System
.
Int32
.
Parse
(
strColor
.
Substring
(
3
,
2
),
System
.
Globalization
.
NumberStyles
.
AllowHexSpecifier
),
System
.
Int32
.
Parse
(
strColor
.
Substring
(
5
,
2
),
System
.
Globalization
.
NumberStyles
.
AllowHexSpecifier
));
}
}
catch
{
//设为黑色
return
System
.
Drawing
.
Color
.
FromArgb
(
0
,
0
,
0
);
}
}
#
endregion
#
region
[
颜色:
RGB
转成
16
进制
]
/// <summary>
/// [颜色:RGB转成16进制]
/// </summary>
/// <param name="R">红 int</param>
/// <param name="G">绿 int</param>
/// <param name="B">蓝 int</param>
/// <returns></returns>
public
static
string
colorRGBtoHx16
(
int
R
,
int
G
,
int
B
)
{
return
System
.
Drawing
.
ColorTranslator
.
ToHtml
(
System
.
Drawing
.
Color
.
FromArgb
(
R
,
G
,
B
));
}
#
endregion
}
}
...
...
Mall.Common/Plugin/NPOIHelper.cs
View file @
c873ac83
...
@@ -26,399 +26,6 @@ namespace Mall.Common.Plugin
...
@@ -26,399 +26,6 @@ namespace Mall.Common.Plugin
/// </summary>
/// </summary>
public
class
NPOIHelper
public
class
NPOIHelper
{
{
#
region
从
datatable
中将数据导出到
excel
/// <summary>
/// DataTable导出到Excel的MemoryStream
/// </summary>
/// <param name="dtSource">源DataTable</param>
/// <param name="strHeaderText">表头文本</param>
static
MemoryStream
ExportDT
(
DataTable
dtSource
,
String
strHeaderText
)
{
HSSFWorkbook
workbook
=
new
HSSFWorkbook
();
HSSFSheet
sheet
=
workbook
.
CreateSheet
()
as
HSSFSheet
;
HSSFCellStyle
dateStyle
=
workbook
.
CreateCellStyle
()
as
HSSFCellStyle
;
HSSFDataFormat
format
=
workbook
.
CreateDataFormat
()
as
HSSFDataFormat
;
dateStyle
.
DataFormat
=
format
.
GetFormat
(
"yyyy-mm-dd"
);
//取得列宽
int
[]
arrColWidth
=
new
int
[
dtSource
.
Columns
.
Count
];
foreach
(
DataColumn
item
in
dtSource
.
Columns
)
{
arrColWidth
[
item
.
Ordinal
]
=
Encoding
.
GetEncoding
(
936
).
GetBytes
(
item
.
ColumnName
.
ToString
()).
Length
;
}
for
(
int
i
=
0
;
i
<
dtSource
.
Rows
.
Count
;
i
++)
{
for
(
int
j
=
0
;
j
<
dtSource
.
Columns
.
Count
;
j
++)
{
int
intTemp
=
Encoding
.
GetEncoding
(
936
).
GetBytes
(
dtSource
.
Rows
[
i
][
j
].
ToString
()).
Length
;
if
(
intTemp
>
arrColWidth
[
j
])
{
arrColWidth
[
j
]
=
intTemp
;
}
}
}
int
rowIndex
=
0
;
foreach
(
DataRow
row
in
dtSource
.
Rows
)
{
#
region
新建表,填充表头,填充列头,样式
if
(
rowIndex
==
65535
||
rowIndex
==
0
)
{
if
(
rowIndex
!=
0
)
{
sheet
=
workbook
.
CreateSheet
()
as
HSSFSheet
;
}
#
region
表头及样式
{
HSSFRow
headerRow
=
sheet
.
CreateRow
(
0
)
as
HSSFRow
;
headerRow
.
HeightInPoints
=
25
;
headerRow
.
CreateCell
(
0
).
SetCellValue
(
strHeaderText
);
HSSFCellStyle
headStyle
=
workbook
.
CreateCellStyle
()
as
HSSFCellStyle
;
headStyle
.
Alignment
=
NPOI
.
SS
.
UserModel
.
HorizontalAlignment
.
Center
;
HSSFFont
font
=
workbook
.
CreateFont
()
as
HSSFFont
;
font
.
FontHeightInPoints
=
20
;
font
.
Boldweight
=
700
;
headStyle
.
SetFont
(
font
);
headerRow
.
GetCell
(
0
).
CellStyle
=
headStyle
;
sheet
.
AddMergedRegion
(
new
CellRangeAddress
(
0
,
0
,
0
,
dtSource
.
Columns
.
Count
-
1
));
//headerRow.Dispose();
}
#
endregion
#
region
列头及样式
{
HSSFRow
headerRow
=
sheet
.
CreateRow
(
1
)
as
HSSFRow
;
HSSFCellStyle
headStyle
=
workbook
.
CreateCellStyle
()
as
HSSFCellStyle
;
headStyle
.
Alignment
=
NPOI
.
SS
.
UserModel
.
HorizontalAlignment
.
Center
;
HSSFFont
font
=
workbook
.
CreateFont
()
as
HSSFFont
;
font
.
FontHeightInPoints
=
10
;
font
.
Boldweight
=
700
;
headStyle
.
SetFont
(
font
);
foreach
(
DataColumn
column
in
dtSource
.
Columns
)
{
headerRow
.
CreateCell
(
column
.
Ordinal
).
SetCellValue
(
column
.
ColumnName
);
headerRow
.
GetCell
(
column
.
Ordinal
).
CellStyle
=
headStyle
;
//设置列宽
sheet
.
SetColumnWidth
(
column
.
Ordinal
,
(
arrColWidth
[
column
.
Ordinal
]
+
1
)
*
256
);
}
//headerRow.Dispose();
}
#
endregion
rowIndex
=
2
;
}
#
endregion
#
region
填充内容
HSSFRow
dataRow
=
sheet
.
CreateRow
(
rowIndex
)
as
HSSFRow
;
foreach
(
DataColumn
column
in
dtSource
.
Columns
)
{
HSSFCell
newCell
=
dataRow
.
CreateCell
(
column
.
Ordinal
)
as
HSSFCell
;
String
drValue
=
row
[
column
].
ToString
();
switch
(
column
.
DataType
.
ToString
())
{
case
"System.String"
:
//字符串类型
double
result
;
if
(
IsNumeric
(
drValue
,
out
result
))
{
double
.
TryParse
(
drValue
,
out
result
);
newCell
.
SetCellValue
(
result
);
break
;
}
else
{
newCell
.
SetCellValue
(
drValue
);
break
;
}
case
"System.DateTime"
:
//日期类型
DateTime
dateV
;
DateTime
.
TryParse
(
drValue
,
out
dateV
);
newCell
.
SetCellValue
(
dateV
);
newCell
.
CellStyle
=
dateStyle
;
//格式化显示
break
;
case
"System.Boolean"
:
//布尔型
bool
boolV
=
false
;
bool
.
TryParse
(
drValue
,
out
boolV
);
newCell
.
SetCellValue
(
boolV
);
break
;
case
"System.Int16"
:
//整型
case
"System.Int32"
:
case
"System.Int64"
:
case
"System.Byte"
:
int
intV
=
0
;
int
.
TryParse
(
drValue
,
out
intV
);
newCell
.
SetCellValue
(
intV
);
break
;
case
"System.Decimal"
:
//浮点型
case
"System.Double"
:
double
doubV
=
0
;
double
.
TryParse
(
drValue
,
out
doubV
);
newCell
.
SetCellValue
(
doubV
);
break
;
case
"System.DBNull"
:
//空值处理
newCell
.
SetCellValue
(
""
);
break
;
default
:
newCell
.
SetCellValue
(
""
);
break
;
}
}
#
endregion
rowIndex
++;
}
using
(
MemoryStream
ms
=
new
MemoryStream
())
{
workbook
.
Write
(
ms
);
ms
.
Flush
();
ms
.
Position
=
0
;
return
ms
;
}
}
/// <summary>
/// DataTable导出到Excel的MemoryStream
/// </summary>
/// <param name="dtSource">源DataTable</param>
/// <param name="strHeaderText">表头文本</param>
/// <param name="fs">文件流</param>
static
void
ExportDTI
(
DataTable
dtSource
,
String
strHeaderText
,
FileStream
fs
)
{
XSSFWorkbook
workbook
=
new
XSSFWorkbook
();
XSSFSheet
sheet
=
workbook
.
CreateSheet
()
as
XSSFSheet
;
#
region
右击文件
属性信息
//{
// DocumentSummaryInformation dsi = PropertySetFactory.CreateDocumentSummaryInformation();
// dsi.Company = "http://www.yongfa365.com/";
// workbook.DocumentSummaryInformation = dsi;
// SummaryInformation si = PropertySetFactory.CreateSummaryInformation();
// si.Author = "柳永法"; //填加xls文件作者信息
// si.ApplicationName = "NPOI测试程序"; //填加xls文件创建程序信息
// si.LastAuthor = "柳永法2"; //填加xls文件最后保存者信息
// si.Comments = "说明信息"; //填加xls文件作者信息
// si.Title = "NPOI测试"; //填加xls文件标题信息
// si.Subject = "NPOI测试Demo"; //填加文件主题信息
// si.CreateDateTime = DateTime.Now;
// workbook.SummaryInformation = si;
//}
#
endregion
XSSFCellStyle
dateStyle
=
workbook
.
CreateCellStyle
()
as
XSSFCellStyle
;
XSSFDataFormat
format
=
workbook
.
CreateDataFormat
()
as
XSSFDataFormat
;
dateStyle
.
DataFormat
=
format
.
GetFormat
(
"yyyy-mm-dd"
);
//取得列宽
int
[]
arrColWidth
=
new
int
[
dtSource
.
Columns
.
Count
];
foreach
(
DataColumn
item
in
dtSource
.
Columns
)
{
arrColWidth
[
item
.
Ordinal
]
=
Encoding
.
GetEncoding
(
936
).
GetBytes
(
item
.
ColumnName
.
ToString
()).
Length
;
}
for
(
int
i
=
0
;
i
<
dtSource
.
Rows
.
Count
;
i
++)
{
for
(
int
j
=
0
;
j
<
dtSource
.
Columns
.
Count
;
j
++)
{
int
intTemp
=
Encoding
.
GetEncoding
(
936
).
GetBytes
(
dtSource
.
Rows
[
i
][
j
].
ToString
()).
Length
;
if
(
intTemp
>
arrColWidth
[
j
])
{
arrColWidth
[
j
]
=
intTemp
;
}
}
}
int
rowIndex
=
0
;
foreach
(
DataRow
row
in
dtSource
.
Rows
)
{
#
region
新建表,填充表头,填充列头,样式
if
(
rowIndex
==
0
)
{
#
region
表头及样式
//{
// XSSFRow headerRow = sheet.CreateRow(0) as XSSFRow;
// headerRow.HeightInPoints = 25;
// headerRow.CreateCell(0).SetCellValue(strHeaderText);
// XSSFCellStyle headStyle = workbook.CreateCellStyle() as XSSFCellStyle;
// headStyle.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center;
// XSSFFont font = workbook.CreateFont() as XSSFFont;
// font.FontHeightInPoints = 20;
// font.Boldweight = 700;
// headStyle.SetFont(font);
// headerRow.GetCell(0).CellStyle = headStyle;
// //sheet.AddMergedRegion(new Region(0, 0, 0, dtSource.Columns.Count - 1));
// //headerRow.Dispose();
//}
#
endregion
#
region
列头及样式
{
XSSFRow
headerRow
=
sheet
.
CreateRow
(
0
)
as
XSSFRow
;
XSSFCellStyle
headStyle
=
workbook
.
CreateCellStyle
()
as
XSSFCellStyle
;
headStyle
.
Alignment
=
NPOI
.
SS
.
UserModel
.
HorizontalAlignment
.
Center
;
XSSFFont
font
=
workbook
.
CreateFont
()
as
XSSFFont
;
font
.
FontHeightInPoints
=
10
;
font
.
Boldweight
=
700
;
headStyle
.
SetFont
(
font
);
foreach
(
DataColumn
column
in
dtSource
.
Columns
)
{
headerRow
.
CreateCell
(
column
.
Ordinal
).
SetCellValue
(
column
.
ColumnName
);
headerRow
.
GetCell
(
column
.
Ordinal
).
CellStyle
=
headStyle
;
//设置列宽
sheet
.
SetColumnWidth
(
column
.
Ordinal
,
(
arrColWidth
[
column
.
Ordinal
]
+
1
)
*
256
);
}
//headerRow.Dispose();
}
#
endregion
rowIndex
=
1
;
}
#
endregion
#
region
填充内容
XSSFRow
dataRow
=
sheet
.
CreateRow
(
rowIndex
)
as
XSSFRow
;
foreach
(
DataColumn
column
in
dtSource
.
Columns
)
{
XSSFCell
newCell
=
dataRow
.
CreateCell
(
column
.
Ordinal
)
as
XSSFCell
;
String
drValue
=
row
[
column
].
ToString
();
switch
(
column
.
DataType
.
ToString
())
{
case
"System.String"
:
//字符串类型
double
result
;
if
(
IsNumeric
(
drValue
,
out
result
))
{
double
.
TryParse
(
drValue
,
out
result
);
newCell
.
SetCellValue
(
result
);
break
;
}
else
{
newCell
.
SetCellValue
(
drValue
);
break
;
}
case
"System.DateTime"
:
//日期类型
DateTime
dateV
;
DateTime
.
TryParse
(
drValue
,
out
dateV
);
newCell
.
SetCellValue
(
dateV
);
newCell
.
CellStyle
=
dateStyle
;
//格式化显示
break
;
case
"System.Boolean"
:
//布尔型
bool
boolV
=
false
;
bool
.
TryParse
(
drValue
,
out
boolV
);
newCell
.
SetCellValue
(
boolV
);
break
;
case
"System.Int16"
:
//整型
case
"System.Int32"
:
case
"System.Int64"
:
case
"System.Byte"
:
int
intV
=
0
;
int
.
TryParse
(
drValue
,
out
intV
);
newCell
.
SetCellValue
(
intV
);
break
;
case
"System.Decimal"
:
//浮点型
case
"System.Double"
:
double
doubV
=
0
;
double
.
TryParse
(
drValue
,
out
doubV
);
newCell
.
SetCellValue
(
doubV
);
break
;
case
"System.DBNull"
:
//空值处理
newCell
.
SetCellValue
(
""
);
break
;
default
:
newCell
.
SetCellValue
(
""
);
break
;
}
}
#
endregion
rowIndex
++;
}
workbook
.
Write
(
fs
);
fs
.
Close
();
}
/// <summary>
/// DataTable导出到Excel文件
/// </summary>
/// <param name="dtSource">源DataTable</param>
/// <param name="strHeaderText">表头文本</param>
/// <param name="strFileName">保存位置(路径+文件名)</param>
public
static
void
ExportDTtoExcel
(
DataTable
dtSource
,
String
strHeaderText
,
String
strFileName
)
{
String
[]
temp
=
strFileName
.
Split
(
'.'
);
if
(
temp
[
temp
.
Length
-
1
]
==
"xls"
&&
dtSource
.
Columns
.
Count
<
256
&&
dtSource
.
Rows
.
Count
<
65536
)
{
using
(
MemoryStream
ms
=
ExportDT
(
dtSource
,
strHeaderText
))
{
using
(
FileStream
fs
=
new
FileStream
(
strFileName
,
FileMode
.
Create
,
FileAccess
.
Write
))
{
byte
[]
data
=
ms
.
ToArray
();
fs
.
Write
(
data
,
0
,
data
.
Length
);
fs
.
Flush
();
}
}
}
else
{
if
(
temp
[
temp
.
Length
-
1
]
==
"xls"
)
strFileName
=
strFileName
+
"x"
;
using
(
FileStream
fs
=
new
FileStream
(
strFileName
,
FileMode
.
Create
,
FileAccess
.
Write
))
{
ExportDTI
(
dtSource
,
strHeaderText
,
fs
);
}
}
}
#
endregion
#
region
从
excel
中将数据导出到
datatable
#
region
从
excel
中将数据导出到
datatable
...
@@ -438,9 +45,7 @@ namespace Mall.Common.Plugin
...
@@ -438,9 +45,7 @@ namespace Mall.Common.Plugin
wb
=
WorkbookFactory
.
Create
(
file
);
wb
=
WorkbookFactory
.
Create
(
file
);
}
}
ISheet
sheet
=
wb
.
GetSheetAt
(
SheetIndex
);
ISheet
sheet
=
wb
.
GetSheetAt
(
SheetIndex
);
DataTable
table
=
new
DataTable
();
DataTable
table
=
ImportDt
(
sheet
,
HeaderRowIndex
,
needHeader
);
table
=
ImportDt
(
sheet
,
HeaderRowIndex
,
needHeader
);
sheet
=
null
;
return
table
;
return
table
;
}
}
...
...
Mall.Module.Product/ProductModule.cs
View file @
c873ac83
...
@@ -2709,7 +2709,7 @@ namespace Mall.Module.Product
...
@@ -2709,7 +2709,7 @@ namespace Mall.Module.Product
/// <param name="storeId">门店编号</param>
/// <param name="storeId">门店编号</param>
/// <param name="chooseDate">选择日期</param>
/// <param name="chooseDate">选择日期</param>
/// <returns></returns>
/// <returns></returns>
public
object
GetAppletOfflineGoodsInfoModule
(
int
goodsId
,
int
UserId
,
int
SmallShopsId
,
int
TenantId
,
int
MallBaseId
,
int
storeId
=
0
,
int
servicePersionId
=
0
,
string
chooseDate
=
""
)
public
object
GetAppletOfflineGoodsInfoModule
(
int
goodsId
,
int
UserId
,
int
SmallShopsId
,
int
TenantId
,
int
MallBaseId
,
int
storeId
=
0
)
{
{
var
model
=
goodsRepository
.
GetEntity
(
goodsId
).
RefMapperTo
<
RB_Goods_Extend
>();
var
model
=
goodsRepository
.
GetEntity
(
goodsId
).
RefMapperTo
<
RB_Goods_Extend
>();
if
(
model
==
null
||
model
.
TenantId
!=
TenantId
||
model
.
MallBaseId
!=
MallBaseId
)
if
(
model
==
null
||
model
.
TenantId
!=
TenantId
||
model
.
MallBaseId
!=
MallBaseId
)
...
@@ -3893,13 +3893,11 @@ namespace Mall.Module.Product
...
@@ -3893,13 +3893,11 @@ namespace Mall.Module.Product
/// 获取线下服务人员列表
/// 获取线下服务人员列表
/// </summary>
/// </summary>
/// <param name="goodsId"></param>
/// <param name="goodsId"></param>
/// <param name="UserId"></param>
/// <param name="SmallShopsId"></param>
/// <param name="TenantId"></param>
/// <param name="TenantId"></param>
/// <param name="MallBaseId"></param>
/// <param name="MallBaseId"></param>
/// <param name="storeId"></param>
/// <param name="storeId"></param>
/// <returns></returns>
/// <returns></returns>
public
object
GetAppletOfflineServicePersionModule
(
int
goodsId
,
int
UserId
,
int
SmallShopsId
,
int
TenantId
,
int
MallBaseId
,
int
storeId
=
0
)
public
object
GetAppletOfflineServicePersionModule
(
int
goodsId
,
int
TenantId
,
int
MallBaseId
,
int
storeId
=
0
)
{
{
var
model
=
goodsRepository
.
GetEntity
(
goodsId
).
RefMapperTo
<
RB_Goods_Extend
>();
var
model
=
goodsRepository
.
GetEntity
(
goodsId
).
RefMapperTo
<
RB_Goods_Extend
>();
//查询分类
//查询分类
...
@@ -6625,96 +6623,10 @@ namespace Mall.Module.Product
...
@@ -6625,96 +6623,10 @@ namespace Mall.Module.Product
/// <param name="pageSize"></param>
/// <param name="pageSize"></param>
/// <param name="count"></param>
/// <param name="count"></param>
/// <param name="demodel"></param>
/// <param name="demodel"></param>
/// <param name="IsGetSpec">是否获取规格</param>
/// <returns></returns>
/// <returns></returns>
public
List
<
RB_Goods_Extend
>
GetListByGoodsClassify
(
int
pageIndex
,
int
pageSize
,
out
long
count
,
RB_Goods_Extend
demodel
,
int
IsGetSpec
=
0
)
public
List
<
RB_Goods_Extend
>
GetListByGoodsClassify
(
int
pageIndex
,
int
pageSize
,
out
long
count
,
RB_Goods_Extend
demodel
)
{
{
var
list
=
goodsRepository
.
GetPageList_V2
(
pageIndex
,
pageSize
,
out
count
,
demodel
);
var
list
=
goodsRepository
.
GetPageList_V2
(
pageIndex
,
pageSize
,
out
count
,
demodel
);
//if (list.Any())
//{
// //查询分类
// string ids = string.Join(",", list.Select(x => x.Id));
// var clist = goods_CategoryRepository.GetList(new RB_Goods_Category_Extend() { GoodsIds = ids, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
// var olist = goods_OrderRepository.GetGoodsOrderNum(ids);
// //规格列表
// List<RB_Goods_Specification_Extend> SpecificationList = new List<RB_Goods_Specification_Extend>();
// //规格值
// List<RB_Goods_SpecificationValue_Extend> svlist = new List<RB_Goods_SpecificationValue_Extend>();
// //规格值列表
// List<RB_Goods_SpecificationPrice_Extend> SpecificationPriceList = new List<RB_Goods_SpecificationPrice_Extend>();
// if (IsGetSpec == 1)
// {
// SpecificationList = goods_SpecificationRepository.GetList(new RB_Goods_Specification_Extend() { GoodsIds = ids, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
// svlist = goods_SpecificationValueRepository.GetList(new RB_Goods_SpecificationValue_Extend() { GoodsIds = ids, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
// SpecificationPriceList = goods_SpecificationPriceRepository.GetList(new RB_Goods_SpecificationPrice_Extend() { GoodsIds = ids, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
// }
// foreach (var item in list)
// {
// item.CategoryList = clist.Where(x => x.GoodsId == item.Id).ToList();
// //轮播图
// item.CoverImage = "";
// item.CarouselImageList = new List<RB_ImageCommonModel>();
// if (!string.IsNullOrEmpty(item.CarouselImage) && item.CarouselImage != "[]")
// {
// List<string> CarouselIdList = JsonConvert.DeserializeObject<List<string>>(item.CarouselImage);
// //封面图
// item.CoverImage = CarouselIdList[0];
// //轮播图
// //轮播图
// foreach (var qitem in CarouselIdList)
// {
// item.CarouselImageList.Add(new RB_ImageCommonModel()
// {
// Id = 0,
// Name = "",
// Path = qitem
// });
// }
// }
// item.GoodsBuyNum = olist.Where(x => x.GoodsId == item.Id).FirstOrDefault()?.OrderNum ?? 0;
// if (IsGetSpec == 1)
// {
// item.SpecificationList = SpecificationList?.Where(qitem => qitem.GoodsId == item.Id)?.ToList() ?? new List<RB_Goods_Specification_Extend>();
// if (item.SpecificationList != null && item.SpecificationList.Count > 0)
// {
// foreach (var subItem in item.SpecificationList)
// {
// subItem.SpecificationValueList = svlist.Where(x => x.SpecificationId == subItem.Id).ToList();
// }
// }
// var tempPriceList = SpecificationPriceList?.Where(qitem => qitem.GoodsId == item.Id)?.ToList() ?? new List<RB_Goods_SpecificationPrice_Extend>();
// int SortNum = 1;
// foreach (var childItem in tempPriceList)
// {
// if (!string.IsNullOrEmpty(childItem.SpecificationSort))
// {
// var ssarr = childItem.SpecificationSort.Split(':');
// int Sort = Convert.ToInt32(ssarr[0]);
// string pic_url = item.SpecificationList[0].SpecificationValueList.Where(x => x.Sort == Sort).FirstOrDefault()?.ImagePath;
// List<object> AttrList = new List<object>();
// for (int i = 0; i < ssarr.Length; i++)
// {
// var smodel = item.SpecificationList[i];
// var svmodel = smodel.SpecificationValueList.Where(x => x.Sort == Convert.ToInt32(ssarr[i])).FirstOrDefault();
// AttrList.Add(new
// {
// SName = smodel.Name,
// SId = smodel.Id,
// SVId = svmodel.Sort,
// SVName = svmodel.Name
// });
// }
// childItem.AttrList = AttrList;
// }
// childItem.SortNum = SortNum;
// SortNum++;
// }
// item.SpecificationPriceList = tempPriceList.OrderByDescending(x => x.SortNum).ToList();
// }
// }
//}
return
list
;
return
list
;
}
}
...
...
Mall.Module.TradePavilion/CarrierModule.cs
View file @
c873ac83
...
@@ -964,12 +964,11 @@ namespace Mall.Module.TradePavilion
...
@@ -964,12 +964,11 @@ namespace Mall.Module.TradePavilion
}
}
}
}
}
}
catch
(
Exception
ex
)
catch
{
{
}
}
}
}
else
else
{
{
...
@@ -1176,7 +1175,7 @@ namespace Mall.Module.TradePavilion
...
@@ -1176,7 +1175,7 @@ namespace Mall.Module.TradePavilion
/// <returns></returns>
/// <returns></returns>
public
bool
AddOrUpdateCollect
(
RB_Collect_Extend
model
)
public
bool
AddOrUpdateCollect
(
RB_Collect_Extend
model
)
{
{
bool
flag
=
false
;
bool
flag
;
try
try
{
{
int
Id
=
0
;
int
Id
=
0
;
...
...
Mall.Module.TradePavilion/FirstShopListModule.cs
View file @
c873ac83
...
@@ -973,9 +973,8 @@ namespace Mall.Module.TradePavilion
...
@@ -973,9 +973,8 @@ namespace Mall.Module.TradePavilion
/// 榜单报名下载word 单次
/// 榜单报名下载word 单次
/// </summary>
/// </summary>
/// <param name="enrollId"></param>
/// <param name="enrollId"></param>
/// <param name="mallBaseId"></param>
/// <returns></returns>
/// <returns></returns>
public
string
GetFirstShopEnrollWordExport
(
int
enrollId
,
int
mallBaseId
,
out
string
errorMsg
)
public
string
GetFirstShopEnrollWordExport
(
int
enrollId
,
out
string
errorMsg
)
{
{
errorMsg
=
""
;
errorMsg
=
""
;
//存储的临时文件地址
//存储的临时文件地址
...
@@ -1107,18 +1106,13 @@ namespace Mall.Module.TradePavilion
...
@@ -1107,18 +1106,13 @@ namespace Mall.Module.TradePavilion
string
Name
=
obj
.
Name
;
string
Name
=
obj
.
Name
;
foreach
(
var
qitem
in
obj
.
FileList
)
foreach
(
var
qitem
in
obj
.
FileList
)
{
{
try
try
{
{
Uri
uri
=
new
Uri
(
qitem
);
//imgPath :网络图片地址
Uri
uri
=
new
Uri
(
qitem
);
//imgPath :网络图片地址
WebRequest
webRequest
=
WebRequest
.
Create
(
uri
);
WebRequest
webRequest
=
WebRequest
.
Create
(
uri
);
// byte[] bytes;
using
WebResponse
webResponse
=
webRequest
.
GetResponse
();
using
(
WebResponse
webResponse
=
webRequest
.
GetResponse
())
Bitmap
bitmap
=
new
Bitmap
(
webResponse
.
GetResponseStream
());
{
bitmap
.
Save
(
templistnowPath
+
Path
.
GetFileName
(
qitem
),
System
.
Drawing
.
Imaging
.
ImageFormat
.
Jpeg
);
Bitmap
bitmap
=
new
Bitmap
(
webResponse
.
GetResponseStream
());
bitmap
.
Save
(
templistnowPath
+
Path
.
GetFileName
(
qitem
),
System
.
Drawing
.
Imaging
.
ImageFormat
.
Jpeg
);
}
}
}
catch
catch
{
{
...
@@ -1136,28 +1130,26 @@ namespace Mall.Module.TradePavilion
...
@@ -1136,28 +1130,26 @@ namespace Mall.Module.TradePavilion
HttpWebRequest
request
=
(
HttpWebRequest
)
WebRequest
.
Create
(
qitem
);
HttpWebRequest
request
=
(
HttpWebRequest
)
WebRequest
.
Create
(
qitem
);
request
.
Method
=
"GET"
;
request
.
Method
=
"GET"
;
byte
[]
fileBytes
;
byte
[]
fileBytes
;
using
(
WebResponse
webRes
=
request
.
GetResponse
())
using
WebResponse
webRes
=
request
.
GetResponse
();
int
length
=
(
int
)
webRes
.
ContentLength
;
HttpWebResponse
response
=
webRes
as
HttpWebResponse
;
Stream
stream
=
response
.
GetResponseStream
();
var
contentdisposition
=
response
.
Headers
[
"Content-Disposition"
];
var
filename
=
Path
.
GetFileName
(
qitem
);
//读取到内存
MemoryStream
stmMemory
=
new
MemoryStream
();
byte
[]
buffer
=
new
byte
[
length
];
int
i
;
//将字节逐个放入到Byte中
while
((
i
=
stream
.
Read
(
buffer
,
0
,
buffer
.
Length
))
>
0
)
{
{
int
length
=
(
int
)
webRes
.
ContentLength
;
stmMemory
.
Write
(
buffer
,
0
,
i
);
HttpWebResponse
response
=
webRes
as
HttpWebResponse
;
Stream
stream
=
response
.
GetResponseStream
();
var
contentdisposition
=
response
.
Headers
[
"Content-Disposition"
];
var
filename
=
Path
.
GetFileName
(
qitem
);
//读取到内存
MemoryStream
stmMemory
=
new
MemoryStream
();
byte
[]
buffer
=
new
byte
[
length
];
int
i
;
//将字节逐个放入到Byte中
while
((
i
=
stream
.
Read
(
buffer
,
0
,
buffer
.
Length
))
>
0
)
{
stmMemory
.
Write
(
buffer
,
0
,
i
);
}
fileBytes
=
stmMemory
.
ToArray
();
//文件流Byte
FileStream
fs
=
new
FileStream
(
templistnowPath
+
Path
.
GetFileName
(
qitem
),
FileMode
.
OpenOrCreate
);
stmMemory
.
WriteTo
(
fs
);
stmMemory
.
Close
();
fs
.
Close
();
}
}
fileBytes
=
stmMemory
.
ToArray
();
//文件流Byte
FileStream
fs
=
new
FileStream
(
templistnowPath
+
Path
.
GetFileName
(
qitem
),
FileMode
.
OpenOrCreate
);
stmMemory
.
WriteTo
(
fs
);
stmMemory
.
Close
();
fs
.
Close
();
}
}
catch
catch
{
{
...
@@ -1527,20 +1519,16 @@ namespace Mall.Module.TradePavilion
...
@@ -1527,20 +1519,16 @@ namespace Mall.Module.TradePavilion
string
Name
=
obj
.
Name
;
string
Name
=
obj
.
Name
;
foreach
(
var
qitem
in
obj
.
FileList
)
foreach
(
var
qitem
in
obj
.
FileList
)
{
{
try
try
{
{
Uri
uri
=
new
Uri
(
qitem
);
//imgPath :网络图片地址
Uri
uri
=
new
Uri
(
qitem
);
//imgPath :网络图片地址
WebRequest
webRequest
=
WebRequest
.
Create
(
uri
);
WebRequest
webRequest
=
WebRequest
.
Create
(
uri
);
// byte[] bytes;
using
WebResponse
webResponse
=
webRequest
.
GetResponse
();
using
(
WebResponse
webResponse
=
webRequest
.
GetResponse
())
Bitmap
bitmap
=
new
Bitmap
(
webResponse
.
GetResponseStream
());
{
Bitmap
bitmap
=
new
Bitmap
(
webResponse
.
GetResponseStream
());
bitmap
.
Save
(
templistPath
+
Path
.
GetFileName
(
qitem
),
System
.
Drawing
.
Imaging
.
ImageFormat
.
Jpeg
);
bitmap
.
Save
(
templistPath
+
Path
.
GetFileName
(
qitem
),
System
.
Drawing
.
Imaging
.
ImageFormat
.
Jpeg
);
}
}
}
catch
(
Exception
ex
)
catch
{
{
}
}
...
@@ -1551,36 +1539,33 @@ namespace Mall.Module.TradePavilion
...
@@ -1551,36 +1539,33 @@ namespace Mall.Module.TradePavilion
//视频处理
//视频处理
foreach
(
var
qitem
in
obj
.
FileList
)
foreach
(
var
qitem
in
obj
.
FileList
)
{
{
try
try
{
{
HttpWebRequest
request
=
(
HttpWebRequest
)
WebRequest
.
Create
(
qitem
);
HttpWebRequest
request
=
(
HttpWebRequest
)
WebRequest
.
Create
(
qitem
);
request
.
Method
=
"GET"
;
request
.
Method
=
"GET"
;
byte
[]
fileBytes
;
byte
[]
fileBytes
;
using
(
WebResponse
webRes
=
request
.
GetResponse
())
using
WebResponse
webRes
=
request
.
GetResponse
();
int
length
=
(
int
)
webRes
.
ContentLength
;
HttpWebResponse
response
=
webRes
as
HttpWebResponse
;
Stream
stream
=
response
.
GetResponseStream
();
var
contentdisposition
=
response
.
Headers
[
"Content-Disposition"
];
var
filename
=
Path
.
GetFileName
(
qitem
);
//读取到内存
MemoryStream
stmMemory
=
new
MemoryStream
();
byte
[]
buffer
=
new
byte
[
length
];
int
i
;
//将字节逐个放入到Byte中
while
((
i
=
stream
.
Read
(
buffer
,
0
,
buffer
.
Length
))
>
0
)
{
{
int
length
=
(
int
)
webRes
.
ContentLength
;
stmMemory
.
Write
(
buffer
,
0
,
i
);
HttpWebResponse
response
=
webRes
as
HttpWebResponse
;
Stream
stream
=
response
.
GetResponseStream
();
var
contentdisposition
=
response
.
Headers
[
"Content-Disposition"
];
var
filename
=
Path
.
GetFileName
(
qitem
);
//读取到内存
MemoryStream
stmMemory
=
new
MemoryStream
();
byte
[]
buffer
=
new
byte
[
length
];
int
i
;
//将字节逐个放入到Byte中
while
((
i
=
stream
.
Read
(
buffer
,
0
,
buffer
.
Length
))
>
0
)
{
stmMemory
.
Write
(
buffer
,
0
,
i
);
}
fileBytes
=
stmMemory
.
ToArray
();
//文件流Byte
FileStream
fs
=
new
FileStream
(
templistPath
+
Path
.
GetFileName
(
qitem
),
FileMode
.
OpenOrCreate
);
stmMemory
.
WriteTo
(
fs
);
stmMemory
.
Close
();
fs
.
Close
();
}
}
fileBytes
=
stmMemory
.
ToArray
();
//文件流Byte
FileStream
fs
=
new
FileStream
(
templistPath
+
Path
.
GetFileName
(
qitem
),
FileMode
.
OpenOrCreate
);
stmMemory
.
WriteTo
(
fs
);
stmMemory
.
Close
();
fs
.
Close
();
}
}
catch
(
Exception
ex
)
catch
{
{
}
}
...
@@ -1589,7 +1574,6 @@ namespace Mall.Module.TradePavilion
...
@@ -1589,7 +1574,6 @@ namespace Mall.Module.TradePavilion
}
}
}
}
}
}
}
}
}
}
#
endregion
#
endregion
...
@@ -1622,23 +1606,17 @@ namespace Mall.Module.TradePavilion
...
@@ -1622,23 +1606,17 @@ namespace Mall.Module.TradePavilion
item
.
Delete
(
true
);
item
.
Delete
(
true
);
}
}
}
}
}
}
catch
catch
{
{
LogHelper
.
Write
(
"清理临时文件失败"
);
LogHelper
.
Write
(
"清理临时文件失败"
);
}
}
// return Path.Combine("/upfile/temporary/firstshopenrollzip/" + "zip/" + timeStr + "/榜单导出文件夹.zip");
}
}
else
else
{
{
// return "";
}
}
}
}
/// <summary>
/// <summary>
/// 生成文件信息
/// 生成文件信息
/// </summary>
/// </summary>
...
@@ -1695,18 +1673,14 @@ namespace Mall.Module.TradePavilion
...
@@ -1695,18 +1673,14 @@ namespace Mall.Module.TradePavilion
string
Name
=
obj
.
Name
;
string
Name
=
obj
.
Name
;
foreach
(
var
qitem
in
obj
.
FileList
)
foreach
(
var
qitem
in
obj
.
FileList
)
{
{
try
try
{
{
Uri
uri
=
new
Uri
(
qitem
);
//imgPath :网络图片地址
Uri
uri
=
new
Uri
(
qitem
);
//imgPath :网络图片地址
WebRequest
webRequest
=
WebRequest
.
Create
(
uri
);
WebRequest
webRequest
=
WebRequest
.
Create
(
uri
);
// byte[] bytes;
using
WebResponse
webResponse
=
webRequest
.
GetResponse
();
using
(
WebResponse
webResponse
=
webRequest
.
GetResponse
())
Bitmap
bitmap
=
new
Bitmap
(
webResponse
.
GetResponseStream
());
{
Bitmap
bitmap
=
new
Bitmap
(
webResponse
.
GetResponseStream
());
bitmap
.
Save
(
templistnowPath
+
Path
.
GetFileName
(
qitem
),
System
.
Drawing
.
Imaging
.
ImageFormat
.
Jpeg
);
bitmap
.
Save
(
templistnowPath
+
Path
.
GetFileName
(
qitem
),
System
.
Drawing
.
Imaging
.
ImageFormat
.
Jpeg
);
}
}
}
catch
catch
{
{
...
@@ -1724,28 +1698,26 @@ namespace Mall.Module.TradePavilion
...
@@ -1724,28 +1698,26 @@ namespace Mall.Module.TradePavilion
HttpWebRequest
request
=
(
HttpWebRequest
)
WebRequest
.
Create
(
qitem
);
HttpWebRequest
request
=
(
HttpWebRequest
)
WebRequest
.
Create
(
qitem
);
request
.
Method
=
"GET"
;
request
.
Method
=
"GET"
;
byte
[]
fileBytes
;
byte
[]
fileBytes
;
using
(
WebResponse
webRes
=
request
.
GetResponse
())
using
WebResponse
webRes
=
request
.
GetResponse
();
int
length
=
(
int
)
webRes
.
ContentLength
;
HttpWebResponse
response
=
webRes
as
HttpWebResponse
;
Stream
stream
=
response
.
GetResponseStream
();
var
contentdisposition
=
response
.
Headers
[
"Content-Disposition"
];
var
filename
=
Path
.
GetFileName
(
qitem
);
//读取到内存
MemoryStream
stmMemory
=
new
MemoryStream
();
byte
[]
buffer
=
new
byte
[
length
];
int
i
;
//将字节逐个放入到Byte中
while
((
i
=
stream
.
Read
(
buffer
,
0
,
buffer
.
Length
))
>
0
)
{
{
int
length
=
(
int
)
webRes
.
ContentLength
;
stmMemory
.
Write
(
buffer
,
0
,
i
);
HttpWebResponse
response
=
webRes
as
HttpWebResponse
;
Stream
stream
=
response
.
GetResponseStream
();
var
contentdisposition
=
response
.
Headers
[
"Content-Disposition"
];
var
filename
=
Path
.
GetFileName
(
qitem
);
//读取到内存
MemoryStream
stmMemory
=
new
MemoryStream
();
byte
[]
buffer
=
new
byte
[
length
];
int
i
;
//将字节逐个放入到Byte中
while
((
i
=
stream
.
Read
(
buffer
,
0
,
buffer
.
Length
))
>
0
)
{
stmMemory
.
Write
(
buffer
,
0
,
i
);
}
fileBytes
=
stmMemory
.
ToArray
();
//文件流Byte
FileStream
fs
=
new
FileStream
(
templistnowPath
+
Path
.
GetFileName
(
qitem
),
FileMode
.
OpenOrCreate
);
stmMemory
.
WriteTo
(
fs
);
stmMemory
.
Close
();
fs
.
Close
();
}
}
fileBytes
=
stmMemory
.
ToArray
();
//文件流Byte
FileStream
fs
=
new
FileStream
(
templistnowPath
+
Path
.
GetFileName
(
qitem
),
FileMode
.
OpenOrCreate
);
stmMemory
.
WriteTo
(
fs
);
stmMemory
.
Close
();
fs
.
Close
();
}
}
catch
catch
{
{
...
...
Mall.Module.User/UserModule.cs
View file @
c873ac83
...
@@ -6555,21 +6555,20 @@ namespace Mall.Module.User
...
@@ -6555,21 +6555,20 @@ namespace Mall.Module.User
/// </summary>
/// </summary>
/// <param name="billId"></param>
/// <param name="billId"></param>
/// <param name="remark"></param>
/// <param name="remark"></param>
/// <param name="tenantId"></param>
/// <param name="mallBaseId"></param>
/// <param name="empId"></param>
/// <returns></returns>
/// <returns></returns>
public
bool
SetRecommendOrdersBillRemark
(
int
billId
,
string
remark
,
int
tenantId
,
int
mallBaseId
,
int
empId
)
public
bool
SetRecommendOrdersBillRemark
(
int
billId
,
string
remark
)
{
{
Dictionary
<
string
,
object
>
keyValues
=
new
Dictionary
<
string
,
object
>()
{
Dictionary
<
string
,
object
>
keyValues
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_Distributor_Bill
.
Remark
),
remark
},
{
nameof
(
RB_Distributor_Bill
.
Remark
),
remark
},
{
nameof
(
RB_Distributor_Bill
.
UpdateDate
),
DateTime
.
Now
}
{
nameof
(
RB_Distributor_Bill
.
UpdateDate
),
DateTime
.
Now
}
};
};
List
<
WhereHelper
>
wheres
=
new
List
<
WhereHelper
>()
{
List
<
WhereHelper
>
wheres
=
new
List
<
WhereHelper
>()
new
WhereHelper
(){
{
FiledName
=
nameof
(
RB_Distributor_Bill
.
Id
),
new
WhereHelper
()
FiledValue
=
billId
,
{
OperatorEnum
=
OperatorEnum
.
Equal
FiledName
=
nameof
(
RB_Distributor_Bill
.
Id
),
FiledValue
=
billId
,
OperatorEnum
=
OperatorEnum
.
Equal
}
}
};
};
bool
flag
=
distributor_BillRepository
.
Update
(
keyValues
,
wheres
);
bool
flag
=
distributor_BillRepository
.
Update
(
keyValues
,
wheres
);
...
...
Mall.WebApi/Controllers/Product/AppletGoodsController.cs
View file @
c873ac83
...
@@ -472,15 +472,12 @@ namespace Mall.WebApi.Controllers.MallBase
...
@@ -472,15 +472,12 @@ namespace Mall.WebApi.Controllers.MallBase
JObject
prams
=
JObject
.
Parse
(
req
.
msg
.
ToString
());
JObject
prams
=
JObject
.
Parse
(
req
.
msg
.
ToString
());
int
GoodsId
=
prams
.
GetInt
(
"GoodsId"
,
0
);
int
GoodsId
=
prams
.
GetInt
(
"GoodsId"
,
0
);
int
StoreId
=
prams
.
GetInt
(
"StoreId"
,
0
);
int
StoreId
=
prams
.
GetInt
(
"StoreId"
,
0
);
int
servicePersionId
=
prams
.
GetInt
(
"servicePersionId"
,
0
);
//选择的日期
string
chooseDate
=
prams
.
GetStringValue
(
"chooseDate"
);
if
(
StoreId
<=
0
||
GoodsId
<=
0
)
if
(
StoreId
<=
0
||
GoodsId
<=
0
)
{
{
return
ApiResult
.
ParamIsNull
(
message
:
"请选择门店"
);
return
ApiResult
.
ParamIsNull
(
message
:
"请选择门店"
);
}
}
int
UserId
=
req
.
UserId
;
int
UserId
=
req
.
UserId
;
object
Robj
=
productModule
.
GetAppletOfflineGoodsInfoModule
(
GoodsId
,
UserId
,
req
.
SmallShopsId
,
req
.
TenantId
,
req
.
MallBaseId
,
storeId
:
StoreId
,
servicePersionId
:
servicePersionId
,
chooseDate
:
chooseDate
);
object
Robj
=
productModule
.
GetAppletOfflineGoodsInfoModule
(
GoodsId
,
UserId
,
req
.
SmallShopsId
,
req
.
TenantId
,
req
.
MallBaseId
,
storeId
:
StoreId
);
return
ApiResult
.
Success
(
""
,
Robj
);
return
ApiResult
.
Success
(
""
,
Robj
);
}
}
...
@@ -529,8 +526,7 @@ namespace Mall.WebApi.Controllers.MallBase
...
@@ -529,8 +526,7 @@ namespace Mall.WebApi.Controllers.MallBase
{
{
return
ApiResult
.
ParamIsNull
(
message
:
"请选择门店"
);
return
ApiResult
.
ParamIsNull
(
message
:
"请选择门店"
);
}
}
int
UserId
=
req
.
UserId
;
object
Robj
=
productModule
.
GetAppletOfflineServicePersionModule
(
GoodsId
,
req
.
TenantId
,
req
.
MallBaseId
,
storeId
:
StoreId
);
object
Robj
=
productModule
.
GetAppletOfflineServicePersionModule
(
GoodsId
,
UserId
,
req
.
SmallShopsId
,
req
.
TenantId
,
req
.
MallBaseId
,
storeId
:
StoreId
);
return
ApiResult
.
Success
(
""
,
Robj
);
return
ApiResult
.
Success
(
""
,
Robj
);
}
}
...
...
Mall.WebApi/Controllers/Product/ProductController.cs
View file @
c873ac83
...
@@ -2756,7 +2756,7 @@ namespace Mall.WebApi.Controllers.MallBase
...
@@ -2756,7 +2756,7 @@ namespace Mall.WebApi.Controllers.MallBase
{
{
return
ApiResult
.
ParamIsNull
(
"请选择商品分类"
);
return
ApiResult
.
ParamIsNull
(
"请选择商品分类"
);
}
}
List
<
int
>
CategoryIdList
=
new
List
<
int
>()
;
List
<
int
>
CategoryIdList
;
try
try
{
{
CategoryIdList
=
JsonConvert
.
DeserializeObject
<
List
<
int
>>(
CategoryList
);
CategoryIdList
=
JsonConvert
.
DeserializeObject
<
List
<
int
>>(
CategoryList
);
...
...
Mall.WebApi/Controllers/TradePavilion/TradeController.cs
View file @
c873ac83
...
@@ -2521,7 +2521,7 @@ namespace Mall.WebApi.Controllers.TradePavilion
...
@@ -2521,7 +2521,7 @@ namespace Mall.WebApi.Controllers.TradePavilion
return
ApiResult
.
ParamIsNull
(
"请传递报名id"
);
return
ApiResult
.
ParamIsNull
(
"请传递报名id"
);
}
}
string
path
=
firstShopListModule
.
GetFirstShopEnrollWordExport
(
EnrollId
,
req
.
MallBaseId
,
out
string
errmsg
);
string
path
=
firstShopListModule
.
GetFirstShopEnrollWordExport
(
EnrollId
,
out
string
errmsg
);
if
(
errmsg
==
""
)
if
(
errmsg
==
""
)
{
{
return
ApiResult
.
Success
(
""
,
path
);
return
ApiResult
.
Success
(
""
,
path
);
...
...
Mall.WebApi/Controllers/User/UserController.cs
View file @
c873ac83
...
@@ -3153,7 +3153,7 @@ namespace Mall.WebApi.Controllers.User
...
@@ -3153,7 +3153,7 @@ namespace Mall.WebApi.Controllers.User
{
{
return
ApiResult
.
ParamIsNull
();
return
ApiResult
.
ParamIsNull
();
}
}
bool
flag
=
userModule
.
SetRecommendOrdersBillRemark
(
BillId
,
Remark
,
req
.
TenantId
,
req
.
MallBaseId
,
req
.
EmpId
);
bool
flag
=
userModule
.
SetRecommendOrdersBillRemark
(
BillId
,
Remark
);
if
(
flag
)
if
(
flag
)
{
{
return
ApiResult
.
Success
();
return
ApiResult
.
Success
();
...
...
Mall.WebApi/Filter/ApiFilterAttribute.cs
View file @
c873ac83
...
@@ -37,13 +37,11 @@ namespace Mall.WebApi.Filter
...
@@ -37,13 +37,11 @@ namespace Mall.WebApi.Filter
/// <param name="actionContext"></param>
/// <param name="actionContext"></param>
public
override
void
OnActionExecuting
(
ActionExecutingContext
actionContext
)
public
override
void
OnActionExecuting
(
ActionExecutingContext
actionContext
)
{
{
string
ip
=
""
;
string
ip
=
actionContext
.
HttpContext
.
Request
.
Headers
[
"X-Forwarded-For"
].
FirstOrDefault
();
ip
=
actionContext
.
HttpContext
.
Request
.
Headers
[
"X-Forwarded-For"
].
FirstOrDefault
();
if
(
string
.
IsNullOrEmpty
(
ip
))
if
(
string
.
IsNullOrEmpty
(
ip
))
{
{
ip
=
actionContext
.
HttpContext
.
Connection
.
RemoteIpAddress
.
ToString
();
ip
=
actionContext
.
HttpContext
.
Connection
.
RemoteIpAddress
.
ToString
();
}
}
if
(!
string
.
IsNullOrEmpty
(
ip
)
&&
Common
.
BackListHelper
.
bankList
.
Contains
(
ip
))
if
(!
string
.
IsNullOrEmpty
(
ip
)
&&
Common
.
BackListHelper
.
bankList
.
Contains
(
ip
))
{
{
actionContext
.
Result
=
new
Microsoft
.
AspNetCore
.
Mvc
.
JsonResult
(
new
ApiResult
actionContext
.
Result
=
new
Microsoft
.
AspNetCore
.
Mvc
.
JsonResult
(
new
ApiResult
...
@@ -330,17 +328,10 @@ namespace Mall.WebApi.Filter
...
@@ -330,17 +328,10 @@ namespace Mall.WebApi.Filter
#
endregion
#
endregion
#
region
根据
uid
获取用户私钥值
#
region
根据
uid
获取用户私钥值
TokenUserInfo
tokenUserInfo
=
JsonConvert
.
DeserializeObject
<
TokenUserInfo
>(
actionContext
.
HttpContext
.
Items
[
GlobalKey
.
TokenUserInfo
].
ToString
());
//TODO查询用户秘钥
//TODO查询用户秘钥
string
privateKey
=
""
;
string
privateKey
=
""
;
//等封装了缓存再说
//等封装了缓存再说
// UserInfo userInfo = UserReidsCache.GetUserLoginInfo(tokenUserInfo.uid);
//if (userInfo != null)
//{
// privateKey = userInfo.SecretKey;
//}
#
endregion
#
endregion
#
region
校验签名是否合法
#
region
校验签名是否合法
...
...
Mall.WebApi/Helper/ApiTokenHelper.cs
0 → 100644
View file @
c873ac83
using
JWT
;
using
JWT.Algorithms
;
using
JWT.Serializers
;
using
Mall.Common.API
;
using
Mall.Common.Plugin
;
using
Newtonsoft.Json.Linq
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading.Tasks
;
namespace
Mall.WebApi.Helper
{
/// <summary>
/// Token帮助类
/// </summary>
public
class
ApiTokenHelper
{
/// <summary>
/// 生成Token
/// </summary>
/// <param name="tokenUser"></param>
/// <returns></returns>
public
static
string
CreateToken
(
TokenUserInfo
tokenUser
)
{
IDateTimeProvider
provider
=
new
UtcDateTimeProvider
();
var
now
=
provider
.
GetNow
().
AddMinutes
(-
1
);
var
unixEpoch
=
new
DateTime
(
1970
,
1
,
1
,
0
,
0
,
0
,
DateTimeKind
.
Utc
);
// or use JwtValidator.UnixEpoch
var
secondsSinceEpoch
=
Math
.
Round
((
now
-
unixEpoch
).
TotalSeconds
);
var
payload
=
new
Dictionary
<
string
,
object
>
{
{
"iat"
,
secondsSinceEpoch
},
{
"exp"
,
secondsSinceEpoch
+
Common
.
Config
.
JwtExpirTime
},
{
"mall_userInfo"
,
tokenUser
}
};
IJwtAlgorithm
algorithm
=
new
HMACSHA256Algorithm
();
IJsonSerializer
serializer
=
new
JsonNetSerializer
();
IBase64UrlEncoder
urlEncoder
=
new
JwtBase64UrlEncoder
();
IJwtEncoder
encoder
=
new
JwtEncoder
(
algorithm
,
serializer
,
urlEncoder
);
string
secret
=
Common
.
Config
.
JwtSecretKey
;
string
token
=
encoder
.
Encode
(
payload
,
secret
);
return
token
;
}
/// <summary>
/// 解析Token
/// </summary>
/// <param name="token"></param>
/// <returns></returns>
public
static
TokenUserInfo
ParsingToken
(
string
token
)
{
TokenUserInfo
tokenUser
=
new
TokenUserInfo
();
if
(
string
.
IsNullOrEmpty
(
token
))
{
IJsonSerializer
serializer
=
new
JsonNetSerializer
();
IDateTimeProvider
provider
=
new
UtcDateTimeProvider
();
IJwtValidator
validator
=
new
JwtValidator
(
serializer
,
provider
);
IBase64UrlEncoder
urlEncoder
=
new
JwtBase64UrlEncoder
();
IJwtDecoder
decoder
=
new
JwtDecoder
(
serializer
,
validator
,
urlEncoder
);
string
secret
=
Common
.
Config
.
JwtSecretKey
;
var
json
=
decoder
.
Decode
(
token
,
secret
,
verify
:
true
);
//token为之前生成的字符串
if
(!
string
.
IsNullOrEmpty
(
json
))
{
JObject
jwtJson
=
JObject
.
Parse
(
json
);
var
mall_userInfo
=
JObject
.
Parse
(
jwtJson
.
GetStringValue
(
"mall_userInfo"
));
tokenUser
.
requestFrom
=
(
Common
.
Enum
.
ApiRequestFromEnum
)
mall_userInfo
.
GetInt
(
"requestFrom"
);
tokenUser
.
uid
=
mall_userInfo
.
GetStringValue
(
"uid"
);
}
}
return
tokenUser
;
}
}
}
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