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
705090d0
Commit
705090d0
authored
Sep 14, 2021
by
吴春
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提交代码
parent
2d3b8aab
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
860 additions
and
10 deletions
+860
-10
UserReidsCache.cs
Mall.CacheManager/User/UserReidsCache.cs
+48
-0
UserModuleCacheKeyConfig.cs
Mall.CacheManager/keyManager/UserModuleCacheKeyConfig.cs
+10
-0
OrderPaymentTypeEnum.cs
Mall.Common/Enum/Goods/OrderPaymentTypeEnum.cs
+1
-1
RB_FirstShop_ListEnroll_Extend.cs
...el/Extend/TradePavilion/RB_FirstShop_ListEnroll_Extend.cs
+9
-0
FirstShopListModule.cs
Mall.Module.TradePavilion/FirstShopListModule.cs
+632
-7
TradeController.cs
Mall.WebApi/Controllers/TradePavilion/TradeController.cs
+160
-2
No files found.
Mall.CacheManager/User/UserReidsCache.cs
View file @
705090d0
...
@@ -443,5 +443,53 @@ namespace Mall.CacheManager.User
...
@@ -443,5 +443,53 @@ namespace Mall.CacheManager.User
return
true
;
return
true
;
}
}
}
}
/// <summary>
/// 设置首店下载缓存
/// </summary>
/// <param name="cacheKey"></param>
/// <param name="Data"></param>
/// <param name="JwtExpirTime"></param>
public
static
void
SetMallDownLoadInfo
(
string
cacheKey
,
object
Data
,
int
JwtExpirTime
)
{
try
{
TimeSpan
ts
=
GetExpirTime
(
JwtExpirTime
);
redis
.
StringSet
(
cacheKey
,
Data
,
ts
);
}
catch
(
Exception
)
{
}
}
/// <summary>
/// 获取首店下载
/// </summary>
/// <param name="Id">账号Id</param>
/// <param name="apiRequestFromEnum">请求来源</param>
/// <returns></returns>
public
static
Model
.
Extend
.
TradePavilion
.
DownLoad
GetMallDownLoadInfo
(
object
Id
)
{
Model
.
Extend
.
TradePavilion
.
DownLoad
downLoad
=
new
Model
.
Extend
.
TradePavilion
.
DownLoad
();
if
(
Id
!=
null
)
{
string
cacheKey
=
Id
.
ToString
();
try
{
downLoad
=
redis
.
StringGet
<
Model
.
Extend
.
TradePavilion
.
DownLoad
>(
cacheKey
);
}
catch
(
Exception
ex
)
{
downLoad
=
new
Model
.
Extend
.
TradePavilion
.
DownLoad
();
Common
.
Plugin
.
LogHelper
.
Write
(
ex
,
"GetMallDownLoadInfo"
);
}
}
return
downLoad
;
}
}
}
}
}
Mall.CacheManager/keyManager/UserModuleCacheKeyConfig.cs
View file @
705090d0
...
@@ -65,5 +65,15 @@ namespace Mall.CacheKey
...
@@ -65,5 +65,15 @@ namespace Mall.CacheKey
{
{
get
{
return
"User_Send_Code_"
;
}
get
{
return
"User_Send_Code_"
;
}
}
}
/// <summary>
/// Mall_DownLoad_Info_(用户id)
/// </summary>
public
static
string
Mall_DownLoad_Info_
{
get
{
return
"Mall_DownLoad_Info_"
;
}
}
}
}
}
}
Mall.Common/Enum/Goods/OrderPaymentTypeEnum.cs
View file @
705090d0
...
@@ -43,7 +43,7 @@ namespace Mall.Common.Enum.Goods
...
@@ -43,7 +43,7 @@ namespace Mall.Common.Enum.Goods
/// 储值卡支付
/// 储值卡支付
/// </summary>
/// </summary>
[
EnumField
(
"储值卡支付"
)]
[
EnumField
(
"储值卡支付"
)]
PayCards
=
6
,
PayCards
=
7
,
/// <summary>
/// <summary>
/// 点数支付
/// 点数支付
...
...
Mall.Model/Extend/TradePavilion/RB_FirstShop_ListEnroll_Extend.cs
View file @
705090d0
...
@@ -68,4 +68,13 @@ namespace Mall.Model.Extend.TradePavilion
...
@@ -68,4 +68,13 @@ namespace Mall.Model.Extend.TradePavilion
/// </summary>
/// </summary>
public
string
ObjectIds
{
get
;
set
;
}
public
string
ObjectIds
{
get
;
set
;
}
}
}
/// <summary>
/// 下载实体
/// </summary>
public
class
DownLoad
{
public
string
Url
{
get
;
set
;
}
}
}
}
Mall.Module.TradePavilion/FirstShopListModule.cs
View file @
705090d0
using
Mall.Common
;
using
Mall.CacheManager.User
;
using
Mall.Common
;
using
Mall.Common.Plugin
;
using
Mall.Common.Plugin
;
using
Mall.Model.Extend.TradePavilion
;
using
Mall.Model.Extend.TradePavilion
;
using
Mall.Module.User
;
using
Mall.Module.User
;
using
Mall.Repository.TradePavilion
;
using
Mall.Repository.TradePavilion
;
using
Mall.Repository.User
;
using
Mall.Repository.User
;
using
Newtonsoft.Json
;
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Drawing
;
using
System.Drawing
;
...
@@ -1035,7 +1037,7 @@ namespace Mall.Module.TradePavilion
...
@@ -1035,7 +1037,7 @@ namespace Mall.Module.TradePavilion
}
}
#
region
/// <summary>
/// <summary>
/// 榜单报名下载word 单次
/// 榜单报名下载word 单次
/// </summary>
/// </summary>
...
@@ -1045,11 +1047,7 @@ namespace Mall.Module.TradePavilion
...
@@ -1045,11 +1047,7 @@ namespace Mall.Module.TradePavilion
public
string
GetFirstShopEnrollZipExport
(
string
listIds
,
int
mallBaseId
,
out
string
errorMsg
)
public
string
GetFirstShopEnrollZipExport
(
string
listIds
,
int
mallBaseId
,
out
string
errorMsg
)
{
{
errorMsg
=
""
;
errorMsg
=
""
;
//存储的临时文件地址
string
rootBook
=
AppDomain
.
CurrentDomain
.
BaseDirectory
;
string
timeStr
=
System
.
DateTime
.
Now
.
ToString
(
"yyyyMMddHHmmssffff"
);
string
endUrl
=
"upfile\\temporary\\firstshopenrollzip\\"
;
string
tempPath
=
Path
.
Combine
(
rootBook
+
endUrl
);
//获取榜单信息
//获取榜单信息
var
listModel
=
firstShop_ListRepository
.
GetList
(
new
RB_FirstShop_List_Extend
{
MallBaseId
=
mallBaseId
,
QIds
=
listIds
});
var
listModel
=
firstShop_ListRepository
.
GetList
(
new
RB_FirstShop_List_Extend
{
MallBaseId
=
mallBaseId
,
QIds
=
listIds
});
...
@@ -1058,6 +1056,13 @@ namespace Mall.Module.TradePavilion
...
@@ -1058,6 +1056,13 @@ namespace Mall.Module.TradePavilion
var
enrollList
=
firstShop_ListEnrollRepository
.
GetList
(
new
RB_FirstShop_ListEnroll_Extend
{
MallBaseId
=
mallBaseId
,
ListIds
=
listIds
});
var
enrollList
=
firstShop_ListEnrollRepository
.
GetList
(
new
RB_FirstShop_ListEnroll_Extend
{
MallBaseId
=
mallBaseId
,
ListIds
=
listIds
});
if
(
enrollList
==
null
||
!
enrollList
.
Any
())
{
errorMsg
=
"报名信息不存在"
;
return
""
;
}
if
(
enrollList
==
null
||
!
enrollList
.
Any
())
{
errorMsg
=
"报名信息不存在"
;
return
""
;
}
//存储的临时文件地址
string
rootBook
=
AppDomain
.
CurrentDomain
.
BaseDirectory
;
string
timeStr
=
Guid
.
NewGuid
().
ToString
(
"N"
);
//System.DateTime.Now.ToString("yyyyMMddHHmmssffff");
string
endUrl
=
"upfile\\temporary\\firstshopenrollzip\\"
;
string
tempPath
=
Path
.
Combine
(
rootBook
+
endUrl
);
string
userIds
=
string
.
Join
(
","
,
enrollList
.
Select
(
x
=>
x
.
UserId
).
Distinct
());
string
userIds
=
string
.
Join
(
","
,
enrollList
.
Select
(
x
=>
x
.
UserId
).
Distinct
());
var
clist
=
companyRepository
.
GetCompanyListRepository
(
new
RB_Company_Extend
()
{
MallBaseId
=
mallBaseId
,
UserIds
=
userIds
});
var
clist
=
companyRepository
.
GetCompanyListRepository
(
new
RB_Company_Extend
()
{
MallBaseId
=
mallBaseId
,
UserIds
=
userIds
});
...
@@ -1202,6 +1207,626 @@ namespace Mall.Module.TradePavilion
...
@@ -1202,6 +1207,626 @@ namespace Mall.Module.TradePavilion
}
}
#
endregion
#
region
改进
/// <summary>
/// 榜单报名下载word 单次
/// </summary>
/// <param name="enrollId"></param>
/// <param name="mallBaseId"></param>
/// <returns></returns>
public
string
GetFirstShopEnrollZipExport_V3
(
string
listIds
,
int
mallBaseId
,
out
string
errorMsg
)
{
errorMsg
=
""
;
//获取榜单信息
var
listModel
=
firstShop_ListRepository
.
GetList
(
new
RB_FirstShop_List_Extend
{
MallBaseId
=
mallBaseId
,
QIds
=
listIds
});
if
(
listModel
==
null
||
!
listModel
.
Any
())
{
errorMsg
=
"榜单不存在"
;
return
""
;
}
var
enrollList
=
firstShop_ListEnrollRepository
.
GetList
(
new
RB_FirstShop_ListEnroll_Extend
{
MallBaseId
=
mallBaseId
,
ListIds
=
listIds
});
if
(
enrollList
==
null
||
!
enrollList
.
Any
())
{
errorMsg
=
"报名信息不存在"
;
return
""
;
}
//存储的临时文件地址
string
rootBook
=
AppDomain
.
CurrentDomain
.
BaseDirectory
;
string
timeStr
=
Guid
.
NewGuid
().
ToString
(
"N"
);
//System.DateTime.Now.ToString("yyyyMMddHHmmssffff");
string
endUrl
=
"upfile\\temporary\\firstshopenrollzip\\"
;
string
tempPath
=
Path
.
Combine
(
rootBook
+
endUrl
);
string
userIds
=
string
.
Join
(
","
,
enrollList
.
Select
(
x
=>
x
.
UserId
).
Distinct
());
var
clist
=
companyRepository
.
GetCompanyListRepository
(
new
RB_Company_Extend
()
{
MallBaseId
=
mallBaseId
,
UserIds
=
userIds
});
//创建一个临时文件夹
string
tempFoldr
=
""
;
#
region
解析表单内容
foreach
(
var
enrollItem
in
enrollList
.
GroupBy
(
x
=>
x
.
UserId
))
{
var
companyName
=
clist
.
Where
(
x
=>
x
.
CreateBy
==
enrollItem
.
Key
).
FirstOrDefault
()?.
CompanyName
??
System
.
DateTime
.
Now
.
ToString
(
"yyyyMMddHHmmssfff"
);
var
nowEnroList
=
enrollList
.
Where
(
x
=>
x
.
UserId
==
enrollItem
.
Key
);
var
templistPath
=
Path
.
Combine
(
tempPath
+
"file\\"
+
timeStr
+
"\\"
+
companyName
.
Trim
()
+
"\\"
);
//路径
foreach
(
var
item
in
nowEnroList
)
{
var
enrollModel
=
listModel
.
Where
(
x
=>
x
.
Id
==
item
.
ListId
).
FirstOrDefault
();
if
(
enrollModel
!=
null
&&
enrollModel
.
Id
>
0
)
{
if
(
string
.
IsNullOrEmpty
(
item
.
Content
))
{
errorMsg
=
"报名内容不存在,请核实后再试"
;
return
""
;
}
List
<
FormDataItem
>
elist
=
JsonHelper
.
DeserializeObject
<
List
<
FormDataItem
>>(
item
.
Content
);
elist
=
elist
.
Where
(
x
=>
x
.
CompKey
==
"ImageUploadComp"
||
x
.
CompKey
==
"VideoUploadComp"
||
x
.
CompKey
==
"CommonUploadComp"
).
ToList
();
var
templistnowPath
=
Path
.
Combine
(
templistPath
+
enrollModel
.
ListName
.
Trim
()
+
"\\"
);
//路径
if
(!
Directory
.
Exists
(
templistnowPath
))
{
Directory
.
CreateDirectory
(
templistnowPath
);
}
foreach
(
var
itemFile
in
elist
)
{
var
obj
=
JsonHelper
.
DeserializeObject
<
UploadItem
>(
itemFile
.
CompData
.
ToString
());
if
(
itemFile
.
CompKey
==
"ImageUploadComp"
)
{
//图片处理
string
Name
=
obj
.
Name
;
foreach
(
var
qitem
in
obj
.
FileList
)
{
try
{
System
.
IO
.
File
.
Copy
(
qitem
,
templistnowPath
+
Path
.
GetFileName
(
qitem
));
//Uri uri = new Uri(qitem); //imgPath :网络图片地址
//WebRequest webRequest = WebRequest.Create(uri);
//// byte[] bytes;
//using (WebResponse webResponse = webRequest.GetResponse())
//{
// Bitmap bitmap = new Bitmap(webResponse.GetResponseStream());
// bitmap.Save(templistnowPath + Path.GetFileName(qitem), System.Drawing.Imaging.ImageFormat.Jpeg);
//}
}
catch
{
}
}
}
//else if (itemFile.CompKey == "VideoUploadComp" || itemFile.CompKey == "CommonUploadComp")
//{
// //视频处理
// foreach (var qitem in obj.FileList)
// {
// try
// {
// HttpWebRequest request = (HttpWebRequest)WebRequest.Create(qitem);
// request.Method = "GET";
// byte[] fileBytes;
// 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)
// {
// 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();
// }
// }
// catch
// {
// }
// }
//}
}
}
}
}
#
endregion
var
templistZipPath
=
Path
.
Combine
(
tempPath
+
"zip\\"
+
timeStr
+
"\\"
);
//路径
if
(!
Directory
.
Exists
(
templistZipPath
))
{
Directory
.
CreateDirectory
(
templistZipPath
);
}
bool
result
=
Common
.
Plugin
.
ZipHelper
.
Zip
(
Path
.
Combine
(
tempPath
+
"file\\"
+
timeStr
),
Path
.
Combine
(
templistZipPath
,
"榜单导出文件夹.zip"
),
ref
tempFoldr
);
if
(
result
)
{
try
{
DirectoryInfo
dir
=
new
DirectoryInfo
(
Path
.
Combine
(
tempPath
+
"file\\"
));
DirectoryInfo
[]
dirArr
=
dir
.
GetDirectories
();
foreach
(
DirectoryInfo
item
in
dirArr
)
{
if
(
item
.
Name
==
timeStr
)
{
foreach
(
FileInfo
fi
in
item
.
GetFiles
())
{
fi
.
Delete
();
}
item
.
Delete
(
true
);
}
}
}
catch
{
LogHelper
.
Write
(
"清理临时文件失败"
);
}
return
Path
.
Combine
(
"/upfile/temporary/firstshopenrollzip/"
+
"zip/"
+
timeStr
+
"/榜单导出文件夹.zip"
);
}
else
{
return
""
;
}
}
/// <summary>
/// 获取打包文件
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public
string
GetPackageFile
(
string
listIds
,
int
mallBaseId
,
out
string
errorMsg
)
{
//获取榜单信息
var
listModel
=
firstShop_ListRepository
.
GetList
(
new
RB_FirstShop_List_Extend
{
MallBaseId
=
mallBaseId
,
QIds
=
listIds
});
if
(
listModel
==
null
||
!
listModel
.
Any
())
{
errorMsg
=
"榜单不存在"
;
return
""
;
}
var
enrollList
=
firstShop_ListEnrollRepository
.
GetList
(
new
RB_FirstShop_ListEnroll_Extend
{
MallBaseId
=
mallBaseId
,
ListIds
=
listIds
});
if
(
enrollList
==
null
||
!
enrollList
.
Any
())
{
errorMsg
=
"报名信息不存在"
;
return
""
;
}
//创建一个根文件夹
string
timeTicks
=
DateTime
.
Now
.
Ticks
.
ToString
();
string
pathRoot
=
"/"
+
timeTicks
;
string
pathFolder
=
""
;
string
rootBook
=
AppDomain
.
CurrentDomain
.
BaseDirectory
;
// string endUrl = "upfile\\temporary\\firstshopenrollzip\\";
try
{
foreach
(
var
item
in
enrollList
)
{
List
<
FormDataItem
>
elist
=
JsonHelper
.
DeserializeObject
<
List
<
FormDataItem
>>(
item
.
Content
);
elist
=
elist
.
Where
(
x
=>
x
.
CompKey
==
"ImageUploadComp"
||
x
.
CompKey
==
"VideoUploadComp"
||
x
.
CompKey
==
"CommonUploadComp"
).
ToList
();
foreach
(
var
itemFile
in
elist
)
{
var
obj
=
JsonHelper
.
DeserializeObject
<
UploadItem
>(
itemFile
.
CompData
.
ToString
());
if
(
itemFile
.
CompKey
==
"ImageUploadComp"
)
{
foreach
(
var
qitem
in
obj
.
FileList
)
{
//根据文件夹id 找出上级所有的文件夹
pathFolder
=
GlobalKey
.
CloudFileTemporaryPath
+
pathRoot
+
"/"
;
//判断文件夹是否存在 不存在创建
if
(!
Directory
.
Exists
(
Path
.
Combine
(
rootBook
+
pathFolder
)))
{
Directory
.
CreateDirectory
(
Path
.
Combine
(
rootBook
+
pathFolder
));
}
//获取文件名
pathFolder
+=
Path
.
GetFileName
(
qitem
);
System
.
IO
.
File
.
Copy
(
qitem
,
Path
.
Combine
(
rootBook
+
pathFolder
));
}
}
}
}
string
errorStr
=
""
;
Common
.
Plugin
.
ZipHelper
.
Zip
(
Path
.
Combine
(
rootBook
+
GlobalKey
.
CloudFileTemporaryPath
+
pathRoot
),
Path
.
Combine
(
rootBook
+
GlobalKey
.
CloudFileTemporaryPath
+
"[打包下载]"
+
timeTicks
+
".zip"
),
ref
errorStr
);
if
(
errorStr
!=
""
)
{
errorMsg
=
""
;
}
else
{
errorMsg
=
""
;
}
string
Newpath
=
GlobalKey
.
CloudFileTemporaryPath
+
"[打包下载]"
+
timeTicks
+
".zip"
;
return
Newpath
;
}
catch
(
Exception
ex
)
{
LogHelper
.
Write
(
ex
,
"GetPackageFile"
);
errorMsg
=
"报错了"
;
return
""
;
}
}
#
endregion
/// <summary>
/// 榜单报名下载word 单次
/// </summary>
/// <param name="enrollId"></param>
/// <param name="mallBaseId"></param>
/// <returns></returns>
public
string
GetFirstShopEnrollZipExport_V2
(
string
listIds
,
int
mallBaseId
,
out
string
errorMsg
)
{
errorMsg
=
""
;
//获取榜单信息
var
listModel
=
firstShop_ListRepository
.
GetList
(
new
RB_FirstShop_List_Extend
{
MallBaseId
=
mallBaseId
,
QIds
=
listIds
});
if
(
listModel
==
null
||
!
listModel
.
Any
())
{
errorMsg
=
"榜单不存在"
;
return
""
;
}
var
enrollList
=
firstShop_ListEnrollRepository
.
GetList
(
new
RB_FirstShop_ListEnroll_Extend
{
MallBaseId
=
mallBaseId
,
ListIds
=
listIds
});
if
(
enrollList
==
null
||
!
enrollList
.
Any
())
{
errorMsg
=
"报名信息不存在"
;
return
""
;
}
//存储的临时文件地址
string
timeStr
=
Guid
.
NewGuid
().
ToString
(
"N"
);
//System.DateTime.Now.ToString("yyyyMMddHHmmssffff");
DownLoad
downLoad
=
new
DownLoad
()
{
Url
=
""
};
UserReidsCache
.
SetMallDownLoadInfo
(
CacheKey
.
UserModuleCacheKeyConfig
.
Mall_DownLoad_Info_
+
timeStr
,
downLoad
,
604800
);
System
.
Threading
.
Tasks
.
Task
.
Run
(()
=>
GetFirstShopEnrollZipExportUrl_V2
(
timeStr
,
mallBaseId
,
listModel
,
enrollList
));
return
timeStr
;
}
/// <summary>
/// 生成文件信息
/// </summary>
/// <param name="timeStr"></param>
/// <param name="mallBaseId"></param>
/// <param name="listModel"></param>
/// <param name="enrollList"></param>
public
void
GetFirstShopEnrollZipExportUrl_V2
(
string
timeStr
,
int
mallBaseId
,
List
<
RB_FirstShop_List_Extend
>
listModel
,
List
<
RB_FirstShop_ListEnroll_Extend
>
enrollList
)
{
string
rootBook
=
AppDomain
.
CurrentDomain
.
BaseDirectory
;
string
endUrl
=
"upfile\\temporary\\firstshopenrollzip\\"
;
string
tempPath
=
Path
.
Combine
(
rootBook
+
endUrl
);
string
userIds
=
string
.
Join
(
","
,
enrollList
.
Select
(
x
=>
x
.
UserId
).
Distinct
());
var
clist
=
companyRepository
.
GetCompanyListRepository
(
new
RB_Company_Extend
()
{
MallBaseId
=
mallBaseId
,
UserIds
=
userIds
});
//创建一个临时文件夹
string
tempFoldr
=
""
;
#
region
解析表单内容
foreach
(
var
listItem
in
listModel
)
{
foreach
(
var
enrollModel
in
enrollList
.
Where
(
x
=>
x
.
ListId
==
listItem
.
Id
))
//榜单下面的公司
{
if
(!
string
.
IsNullOrEmpty
(
enrollModel
.
Content
))
{
List
<
FormDataItem
>
elist
=
JsonHelper
.
DeserializeObject
<
List
<
FormDataItem
>>(
enrollModel
.
Content
);
elist
=
elist
.
Where
(
x
=>
x
.
CompKey
==
"ImageUploadComp"
||
x
.
CompKey
==
"VideoUploadComp"
||
x
.
CompKey
==
"CommonUploadComp"
).
ToList
();
if
(
elist
.
Any
())
{
var
companyName
=
clist
.
Where
(
x
=>
x
.
CreateBy
==
enrollModel
.
UserId
).
FirstOrDefault
()?.
CompanyName
??
System
.
DateTime
.
Now
.
ToString
(
"yyyyMMddHHmmssfff"
);
var
templistPath
=
Path
.
Combine
(
tempPath
+
"file\\"
+
timeStr
+
"\\"
+
listItem
.
ListName
.
Trim
()
+
"\\"
+
companyName
.
Trim
()
+
"\\"
);
//路径
if
(!
Directory
.
Exists
(
templistPath
))
{
Directory
.
CreateDirectory
(
templistPath
);
}
//开始下载图片视频至临时文件
foreach
(
var
itemFile
in
elist
)
{
var
obj
=
JsonHelper
.
DeserializeObject
<
UploadItem
>(
itemFile
.
CompData
.
ToString
());
if
(
itemFile
.
CompKey
==
"ImageUploadComp"
)
{
//图片处理
string
Name
=
obj
.
Name
;
foreach
(
var
qitem
in
obj
.
FileList
)
{
try
{
Uri
uri
=
new
Uri
(
qitem
);
//imgPath :网络图片地址
WebRequest
webRequest
=
WebRequest
.
Create
(
uri
);
// byte[] bytes;
using
(
WebResponse
webResponse
=
webRequest
.
GetResponse
())
{
Bitmap
bitmap
=
new
Bitmap
(
webResponse
.
GetResponseStream
());
bitmap
.
Save
(
templistPath
+
Path
.
GetFileName
(
qitem
),
System
.
Drawing
.
Imaging
.
ImageFormat
.
Jpeg
);
}
}
catch
(
Exception
ex
)
{
}
}
}
else
if
(
itemFile
.
CompKey
==
"VideoUploadComp"
||
itemFile
.
CompKey
==
"CommonUploadComp"
)
{
//视频处理
foreach
(
var
qitem
in
obj
.
FileList
)
{
try
{
HttpWebRequest
request
=
(
HttpWebRequest
)
WebRequest
.
Create
(
qitem
);
request
.
Method
=
"GET"
;
byte
[]
fileBytes
;
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
)
{
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
();
}
}
catch
(
Exception
ex
)
{
}
}
}
}
}
}
}
}
#
endregion
var
templistZipPath
=
Path
.
Combine
(
tempPath
+
"zip\\"
+
timeStr
+
"\\"
);
//路径
if
(!
Directory
.
Exists
(
templistZipPath
))
{
Directory
.
CreateDirectory
(
templistZipPath
);
}
bool
result
=
Common
.
Plugin
.
ZipHelper
.
Zip
(
Path
.
Combine
(
tempPath
+
"file\\"
+
timeStr
),
Path
.
Combine
(
templistZipPath
,
"榜单导出文件夹.zip"
),
ref
tempFoldr
);
if
(
result
)
{
try
{
DownLoad
downLoad
=
new
DownLoad
()
{
Url
=
Path
.
Combine
(
"/upfile/temporary/firstshopenrollzip/"
+
"zip/"
+
timeStr
+
"/榜单导出文件夹.zip"
)
};
UserReidsCache
.
SetMallDownLoadInfo
(
CacheKey
.
UserModuleCacheKeyConfig
.
Mall_DownLoad_Info_
+
timeStr
,
downLoad
,
604800
);
DirectoryInfo
dir
=
new
DirectoryInfo
(
Path
.
Combine
(
tempPath
+
"file\\"
));
DirectoryInfo
[]
dirArr
=
dir
.
GetDirectories
();
foreach
(
DirectoryInfo
item
in
dirArr
)
{
if
(
item
.
Name
==
timeStr
)
{
foreach
(
FileInfo
fi
in
item
.
GetFiles
())
{
fi
.
Delete
();
}
item
.
Delete
(
true
);
}
}
}
catch
{
LogHelper
.
Write
(
"清理临时文件失败"
);
}
// return Path.Combine("/upfile/temporary/firstshopenrollzip/" + "zip/" + timeStr + "/榜单导出文件夹.zip");
}
else
{
// return "";
}
}
/// <summary>
/// 生成文件信息
/// </summary>
/// <param name="timeStr"></param>
/// <param name="mallBaseId"></param>
/// <param name="listModel"></param>
/// <param name="enrollList"></param>
public
string
GetFirstShopEnrollZipExportUrl
(
string
timeStr
,
int
mallBaseId
,
List
<
RB_FirstShop_List_Extend
>
listModel
,
List
<
RB_FirstShop_ListEnroll_Extend
>
enrollList
)
{
string
rootBook
=
AppDomain
.
CurrentDomain
.
BaseDirectory
;
string
endUrl
=
"upfile\\temporary\\firstshopenrollzip\\"
;
string
tempPath
=
Path
.
Combine
(
rootBook
+
endUrl
);
string
userIds
=
string
.
Join
(
","
,
enrollList
.
Select
(
x
=>
x
.
UserId
).
Distinct
());
var
clist
=
companyRepository
.
GetCompanyListRepository
(
new
RB_Company_Extend
()
{
MallBaseId
=
mallBaseId
,
UserIds
=
userIds
});
//创建一个临时文件夹
string
tempFoldr
=
""
;
#
region
解析表单内容
foreach
(
var
enrollItem
in
enrollList
.
GroupBy
(
x
=>
x
.
UserId
))
{
var
companyName
=
clist
.
Where
(
x
=>
x
.
CreateBy
==
enrollItem
.
Key
).
FirstOrDefault
()?.
CompanyName
??
System
.
DateTime
.
Now
.
ToString
(
"yyyyMMddHHmmssfff"
);
var
nowEnroList
=
enrollList
.
Where
(
x
=>
x
.
UserId
==
enrollItem
.
Key
);
var
templistPath
=
Path
.
Combine
(
tempPath
+
"file\\"
+
timeStr
+
"\\"
+
companyName
.
Trim
()
+
"\\"
);
//路径
//if (!Directory.Exists(templistPath))
//{
// Directory.CreateDirectory(templistPath);
//}
foreach
(
var
item
in
nowEnroList
)
{
var
enrollModel
=
listModel
.
Where
(
x
=>
x
.
Id
==
item
.
ListId
).
FirstOrDefault
();
if
(
enrollModel
!=
null
&&
enrollModel
.
Id
>
0
)
{
if
(!
string
.
IsNullOrEmpty
(
item
.
Content
))
{
List
<
FormDataItem
>
elist
=
JsonHelper
.
DeserializeObject
<
List
<
FormDataItem
>>(
item
.
Content
);
elist
=
elist
.
Where
(
x
=>
x
.
CompKey
==
"ImageUploadComp"
||
x
.
CompKey
==
"VideoUploadComp"
||
x
.
CompKey
==
"CommonUploadComp"
).
ToList
();
if
(
elist
!=
null
&&
elist
.
Any
())
{
var
templistnowPath
=
Path
.
Combine
(
templistPath
+
enrollModel
.
ListName
.
Trim
()
+
"\\"
);
//路径
if
(!
Directory
.
Exists
(
templistnowPath
))
{
Directory
.
CreateDirectory
(
templistnowPath
);
}
foreach
(
var
itemFile
in
elist
)
{
var
obj
=
JsonHelper
.
DeserializeObject
<
UploadItem
>(
itemFile
.
CompData
.
ToString
());
if
(
itemFile
.
CompKey
==
"ImageUploadComp"
)
{
//图片处理
string
Name
=
obj
.
Name
;
foreach
(
var
qitem
in
obj
.
FileList
)
{
try
{
Uri
uri
=
new
Uri
(
qitem
);
//imgPath :网络图片地址
WebRequest
webRequest
=
WebRequest
.
Create
(
uri
);
// byte[] bytes;
using
(
WebResponse
webResponse
=
webRequest
.
GetResponse
())
{
Bitmap
bitmap
=
new
Bitmap
(
webResponse
.
GetResponseStream
());
bitmap
.
Save
(
templistnowPath
+
Path
.
GetFileName
(
qitem
),
System
.
Drawing
.
Imaging
.
ImageFormat
.
Jpeg
);
}
}
catch
{
}
}
}
else
if
(
itemFile
.
CompKey
==
"VideoUploadComp"
||
itemFile
.
CompKey
==
"CommonUploadComp"
)
{
//视频处理
foreach
(
var
qitem
in
obj
.
FileList
)
{
try
{
HttpWebRequest
request
=
(
HttpWebRequest
)
WebRequest
.
Create
(
qitem
);
request
.
Method
=
"GET"
;
byte
[]
fileBytes
;
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
)
{
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
();
}
}
catch
{
}
}
}
}
}
}
}
}
}
#
endregion
var
templistZipPath
=
Path
.
Combine
(
tempPath
+
"zip\\"
+
timeStr
+
"\\"
);
//路径
if
(!
Directory
.
Exists
(
templistZipPath
))
{
Directory
.
CreateDirectory
(
templistZipPath
);
}
bool
result
=
Common
.
Plugin
.
ZipHelper
.
Zip
(
Path
.
Combine
(
tempPath
+
"file\\"
+
timeStr
),
Path
.
Combine
(
templistZipPath
,
"榜单导出文件夹.zip"
),
ref
tempFoldr
);
if
(
result
)
{
try
{
DownLoad
downLoad
=
new
DownLoad
()
{
Url
=
Path
.
Combine
(
templistZipPath
,
"榜单导出文件夹.zip"
)
};
UserReidsCache
.
SetMallDownLoadInfo
(
CacheKey
.
UserModuleCacheKeyConfig
.
Mall_DownLoad_Info_
+
timeStr
,
downLoad
,
604800
);
DirectoryInfo
dir
=
new
DirectoryInfo
(
Path
.
Combine
(
tempPath
+
"file\\"
));
DirectoryInfo
[]
dirArr
=
dir
.
GetDirectories
();
foreach
(
DirectoryInfo
item
in
dirArr
)
{
if
(
item
.
Name
==
timeStr
)
{
foreach
(
FileInfo
fi
in
item
.
GetFiles
())
{
fi
.
Delete
();
}
item
.
Delete
(
true
);
}
}
}
catch
{
LogHelper
.
Write
(
"清理临时文件失败"
);
}
return
Path
.
Combine
(
"/upfile/temporary/firstshopenrollzip/"
+
"zip/"
+
timeStr
+
"/榜单导出文件夹.zip"
);
}
else
{
return
""
;
}
}
/// <summary>
/// 获取最后的打包信息
/// </summary>
/// <param name="timeStr"></param>
/// <param name="errorCode"></param>
/// <returns></returns>
public
string
GetFirstShopEnrollResultUrl
(
string
timeStr
,
out
int
errorCode
)
{
string
url
=
""
;
if
(
UserReidsCache
.
Exists
(
CacheKey
.
UserModuleCacheKeyConfig
.
Mall_DownLoad_Info_
+
timeStr
))
{
Model
.
Extend
.
TradePavilion
.
DownLoad
model
=
UserReidsCache
.
GetMallDownLoadInfo
(
CacheKey
.
UserModuleCacheKeyConfig
.
Mall_DownLoad_Info_
+
timeStr
);
url
=
model
.
Url
;
errorCode
=
1
;
}
else
{
errorCode
=
0
;
}
return
url
;
}
/// <summary>
/// <summary>
/// 删除生成的zip文件
/// 删除生成的zip文件
...
...
Mall.WebApi/Controllers/TradePavilion/TradeController.cs
View file @
705090d0
...
@@ -746,6 +746,82 @@ namespace Mall.WebApi.Controllers.TradePavilion
...
@@ -746,6 +746,82 @@ namespace Mall.WebApi.Controllers.TradePavilion
}
}
}
}
/// <summary>
/// 导出
/// </summary>
[
HttpPost
]
public
FileContentResult
DownLoadConsultStaticNew
()
{
ResultPageModel
pageModel
=
JsonConvert
.
DeserializeObject
<
ResultPageModel
>(
RequestParm
.
msg
.
ToString
());
pageModel
.
pageSize
=
100000
;
JObject
parms
=
JObject
.
Parse
(
RequestParm
.
msg
.
ToString
());
var
query
=
new
RB_Commerce_Consult_Extend
()
{
LinkMan
=
parms
.
GetStringValue
(
"LinkMan"
),
ActivityId
=
parms
.
GetInt
(
"ActivityId"
)
};
query
.
MallBaseId
=
RequestParm
.
MallBaseId
;
query
.
TenantId
=
RequestParm
.
TenantId
;
var
list
=
consultModule
.
GetCommerceConsultPageModule
(
pageModel
.
pageIndex
,
pageModel
.
pageSize
,
out
_
,
query
);
string
ExcelName
=
"活动用户导出"
+
DateTime
.
Now
.
ToString
(
"yyyyMMddHHmmss"
)
+
".xls"
;
List
<
ExcelDataSource
>
slist
=
new
List
<
ExcelDataSource
>();
ExcelDataSource
header
=
new
ExcelDataSource
()
{
ExcelRows
=
new
List
<
ExcelColumn
>(
30
)
{
new
ExcelColumn
(
value
:
"用户昵称"
)
{
CellWidth
=
15
,
HAlignmentEnum
=
HAlignmentEnum
.
CENTER
,
VAlignmentEnum
=
VAlignmentEnum
.
CENTER
},
new
ExcelColumn
(
value
:
"认证状态"
)
{
CellWidth
=
15
,
HAlignmentEnum
=
HAlignmentEnum
.
CENTER
,
VAlignmentEnum
=
VAlignmentEnum
.
CENTER
},
new
ExcelColumn
(
value
:
"认证公司"
)
{
CellWidth
=
25
,
HAlignmentEnum
=
HAlignmentEnum
.
CENTER
,
VAlignmentEnum
=
VAlignmentEnum
.
CENTER
},
new
ExcelColumn
(
value
:
"认证信息"
)
{
CellWidth
=
15
,
HAlignmentEnum
=
HAlignmentEnum
.
CENTER
,
VAlignmentEnum
=
VAlignmentEnum
.
CENTER
},
new
ExcelColumn
(
value
:
"公司"
)
{
CellWidth
=
25
,
HAlignmentEnum
=
HAlignmentEnum
.
CENTER
,
VAlignmentEnum
=
VAlignmentEnum
.
CENTER
},
new
ExcelColumn
(
value
:
"性质"
)
{
CellWidth
=
20
,
HAlignmentEnum
=
HAlignmentEnum
.
CENTER
,
VAlignmentEnum
=
VAlignmentEnum
.
CENTER
},
new
ExcelColumn
(
value
:
"联系人"
)
{
CellWidth
=
15
,
HAlignmentEnum
=
HAlignmentEnum
.
CENTER
,
VAlignmentEnum
=
VAlignmentEnum
.
CENTER
},
new
ExcelColumn
(
value
:
"联系电话"
)
{
CellWidth
=
15
,
HAlignmentEnum
=
HAlignmentEnum
.
CENTER
,
VAlignmentEnum
=
VAlignmentEnum
.
CENTER
},
new
ExcelColumn
(
value
:
"职务"
)
{
CellWidth
=
15
,
HAlignmentEnum
=
HAlignmentEnum
.
CENTER
,
VAlignmentEnum
=
VAlignmentEnum
.
CENTER
},
new
ExcelColumn
(
value
:
"地址"
)
{
CellWidth
=
30
,
HAlignmentEnum
=
HAlignmentEnum
.
CENTER
,
VAlignmentEnum
=
VAlignmentEnum
.
CENTER
},
},
};
slist
.
Add
(
header
);
try
{
#
region
组装数据
foreach
(
var
item
in
list
)
{
foreach
(
var
sItem
in
item
.
SignUserList
)
{
var
excelColumns
=
new
List
<
ExcelColumn
>(
30
);
excelColumns
.
Add
(
new
ExcelColumn
(
value
:
item
.
UserName
)
);
excelColumns
.
Add
(
new
ExcelColumn
(
value
:
item
.
CompanyStatusStr
)
);
excelColumns
.
Add
(
new
ExcelColumn
(
value
:
item
.
CompanyName
)
);
excelColumns
.
Add
(
new
ExcelColumn
(
value
:
item
.
AuthName
)
);
excelColumns
.
Add
(
new
ExcelColumn
(
value
:
sItem
.
CompanyName
));
excelColumns
.
Add
(
new
ExcelColumn
(
value
:
sItem
.
Nature
));
excelColumns
.
Add
(
new
ExcelColumn
(
value
:
sItem
.
LinkMan
));
excelColumns
.
Add
(
new
ExcelColumn
(
value
:
sItem
.
LinkTel
));
excelColumns
.
Add
(
new
ExcelColumn
(
value
:
sItem
.
Post
));
excelColumns
.
Add
(
new
ExcelColumn
(
value
:
sItem
.
CountryInfo
));
ExcelDataSource
datarow
=
new
ExcelDataSource
()
{
ExcelRows
=
excelColumns
};
slist
.
Add
(
datarow
);
}
}
#
endregion
var
byteData
=
ExcelTempLateHelper
.
ToExcelExtend
(
slist
);
return
File
(
byteData
,
"application/octet-stream"
,
ExcelName
);
}
catch
(
Exception
ex
)
{
LogHelper
.
Write
(
ex
,
string
.
Format
(
"DownLoadConsultStatic_requestData: {0}"
,
JsonHelper
.
Serialize
(
RequestParm
)));
var
byteData1
=
ExcelTempLateHelper
.
ToExcelExtend
(
slist
);
return
File
(
byteData1
,
"application/octet-stream"
,
ExcelName
);
}
}
/// <summary>
/// <summary>
/// 根据编号获取商会活动报名实体
/// 根据编号获取商会活动报名实体
/// </summary>
/// </summary>
...
@@ -1424,7 +1500,7 @@ namespace Mall.WebApi.Controllers.TradePavilion
...
@@ -1424,7 +1500,7 @@ namespace Mall.WebApi.Controllers.TradePavilion
public
ApiResult
GetSetCarrier
()
public
ApiResult
GetSetCarrier
()
{
{
RB_Carrier_Extend
query
=
JsonConvert
.
DeserializeObject
<
RB_Carrier_Extend
>(
RequestParm
.
msg
.
ToString
());
RB_Carrier_Extend
query
=
JsonConvert
.
DeserializeObject
<
RB_Carrier_Extend
>(
RequestParm
.
msg
.
ToString
());
if
(
string
.
IsNullOrWhiteSpace
(
query
.
CarrierName
))
if
(
string
.
IsNullOrWhiteSpace
(
query
.
CarrierName
))
{
{
return
ApiResult
.
Failed
(
"请输入载体名称"
);
return
ApiResult
.
Failed
(
"请输入载体名称"
);
...
@@ -1449,7 +1525,7 @@ namespace Mall.WebApi.Controllers.TradePavilion
...
@@ -1449,7 +1525,7 @@ namespace Mall.WebApi.Controllers.TradePavilion
{
{
return
ApiResult
.
Failed
(
"请输入可租赁面积"
);
return
ApiResult
.
Failed
(
"请输入可租赁面积"
);
}
}
if
(
string
.
IsNullOrWhiteSpace
(
query
.
Logo
))
if
(
string
.
IsNullOrWhiteSpace
(
query
.
Logo
))
{
{
return
ApiResult
.
Failed
(
"请上传Logo"
);
return
ApiResult
.
Failed
(
"请上传Logo"
);
...
@@ -2637,7 +2713,89 @@ namespace Mall.WebApi.Controllers.TradePavilion
...
@@ -2637,7 +2713,89 @@ namespace Mall.WebApi.Controllers.TradePavilion
return
ApiResult
.
Failed
(
errmsg
);
return
ApiResult
.
Failed
(
errmsg
);
}
}
}
}
/// <summary>
/// 报名列表批量导出
/// </summary>
/// <returns></returns>
[
HttpPost
]
[
AllowAnonymous
]
public
ApiResult
GetFirstShopEnrollZipExport_V3
()
{
var
req
=
base
.
RequestParm
;
JObject
parms
=
JObject
.
Parse
(
req
.
msg
.
ToString
());
string
ListIds
=
parms
.
GetStringValue
(
"ListIds"
);
if
(
string
.
IsNullOrWhiteSpace
(
ListIds
))
{
return
ApiResult
.
ParamIsNull
(
"请传递绑定ids"
);
}
string
path
=
firstShopListModule
.
GetPackageFile
(
ListIds
,
req
.
MallBaseId
,
out
string
errmsg
);
if
(
errmsg
==
""
)
{
return
ApiResult
.
Success
(
""
,
path
);
}
else
{
return
ApiResult
.
Failed
(
errmsg
);
}
}
/// <summary>
/// 报名列表批量导出
/// </summary>
/// <returns></returns>
[
HttpPost
]
[
AllowAnonymous
]
public
ApiResult
GetNewFirstShopEnrollZipExport
()
{
var
req
=
base
.
RequestParm
;
JObject
parms
=
JObject
.
Parse
(
req
.
msg
.
ToString
());
string
ListIds
=
parms
.
GetStringValue
(
"ListIds"
);
if
(
string
.
IsNullOrWhiteSpace
(
ListIds
))
{
return
ApiResult
.
ParamIsNull
(
"请传递绑定ids"
);
}
string
path
=
firstShopListModule
.
GetFirstShopEnrollZipExport_V2
(
ListIds
,
req
.
MallBaseId
,
out
string
errmsg
);
if
(
errmsg
==
""
)
{
return
ApiResult
.
Success
(
""
,
path
);
}
else
{
return
ApiResult
.
Failed
(
errmsg
);
}
}
/// <summary>
/// 报名列表批量导出
/// </summary>
/// <returns></returns>
[
HttpPost
]
[
AllowAnonymous
]
public
ApiResult
GetFirstShopEnrollResultUrl
()
{
var
req
=
base
.
RequestParm
;
JObject
parms
=
JObject
.
Parse
(
req
.
msg
.
ToString
());
string
UserFlag
=
parms
.
GetStringValue
(
"UserFlag"
);
if
(
string
.
IsNullOrWhiteSpace
(
UserFlag
))
{
return
ApiResult
.
ParamIsNull
(
"请传递绑定UserFlag"
);
}
string
path
=
firstShopListModule
.
GetFirstShopEnrollResultUrl
(
UserFlag
,
out
int
errcode
);
if
(
errcode
==
1
)
{
return
ApiResult
.
Success
(
""
,
path
);
}
else
{
return
ApiResult
.
Failed
(
"下载请求不存在"
);
}
}
/// <summary>
/// <summary>
/// 删除生成的zip文件
/// 删除生成的zip文件
...
...
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