Commit 315cee32 authored by 黄奎's avatar 黄奎
parents b22ab5d9 038ee419
...@@ -62,5 +62,10 @@ namespace Mall.Model.Extend.TradePavilion ...@@ -62,5 +62,10 @@ namespace Mall.Model.Extend.TradePavilion
/// 对象ids /// 对象ids
/// </summary> /// </summary>
public string ObjectIds { get; set; } public string ObjectIds { get; set; }
/// <summary>
/// 绑定ids
/// </summary>
public string ListIds { get; set; }
} }
} }
...@@ -70,5 +70,11 @@ namespace Mall.Model.Extend.TradePavilion ...@@ -70,5 +70,11 @@ namespace Mall.Model.Extend.TradePavilion
/// </summary> /// </summary>
public int RankListState { get; set; } public int RankListState { get; set; }
#endregion #endregion
/// <summary>
/// 查询多个榜单
/// </summary>
public string QIds { get; set; }
} }
} }
...@@ -369,7 +369,7 @@ namespace Mall.Module.TradePavilion ...@@ -369,7 +369,7 @@ namespace Mall.Module.TradePavilion
if (demodel.Id > 0) if (demodel.Id > 0)
{ {
#region 验证 #region 验证
var valistList = firstShop_ListEnrollRepository.GetList(new RB_FirstShop_ListEnroll_Extend() { MallBaseId = demodel.MallBaseId, UserId = demodel.UserId, ObjectType = demodel.ObjectType, ObjectId = demodel.ObjectId }); var valistList = firstShop_ListEnrollRepository.GetList(new RB_FirstShop_ListEnroll_Extend() { MallBaseId = demodel.MallBaseId, ListId = demodel.ListId, UserId = demodel.UserId, ObjectType = demodel.ObjectType, ObjectId = demodel.ObjectId });
if (valistList.Where(x => x.Id != demodel.Id).Any()) if (valistList.Where(x => x.Id != demodel.Id).Any())
{ {
return "该品牌/载体已报名,无法重复报名"; return "该品牌/载体已报名,无法重复报名";
...@@ -452,17 +452,19 @@ namespace Mall.Module.TradePavilion ...@@ -452,17 +452,19 @@ namespace Mall.Module.TradePavilion
public List<RB_FirstShop_ListEnroll_Extend> GetFirstShopEnrollPageList(int pageIndex, int pageSize, out long count, RB_FirstShop_ListEnroll_Extend demodel) public List<RB_FirstShop_ListEnroll_Extend> GetFirstShopEnrollPageList(int pageIndex, int pageSize, out long count, RB_FirstShop_ListEnroll_Extend demodel)
{ {
var list = firstShop_ListEnrollRepository.GetPageList(pageIndex, pageSize, out count, demodel); var list = firstShop_ListEnrollRepository.GetPageList(pageIndex, pageSize, out count, demodel);
if (list.Any()) { if (list.Any())
{
string userIds = string.Join(",", list.Select(x => x.UserId).Distinct()); string userIds = string.Join(",", list.Select(x => x.UserId).Distinct());
//企业名称 //企业名称
var companylist = companyRepository.GetCompanyListRepository(new RB_Company_Extend() { MallBaseId = demodel.MallBaseId, UserIds = userIds }); var companylist = companyRepository.GetCompanyListRepository(new RB_Company_Extend() { MallBaseId = demodel.MallBaseId, UserIds = userIds });
foreach (var item in list) { foreach (var item in list)
{
var companyModel = companylist.Where(x => x.CreateBy == item.UserId).FirstOrDefault(); var companyModel = companylist.Where(x => x.CreateBy == item.UserId).FirstOrDefault();
item.CompanyName = companyModel.CompanyName; item.CompanyName = companyModel.CompanyName;
item.Principal = companyModel.Principal; item.Principal = companyModel.Principal;
item.Mobile = companyModel.Mobile; item.Mobile = companyModel.Mobile;
} }
//查询 品牌/载体 名称 图片 //查询 品牌/载体 名称 图片
var e1list = list.Where(x => x.ObjectType == Common.Enum.TradePavilion.ListObjectTypeEnum.Brand).ToList(); var e1list = list.Where(x => x.ObjectType == Common.Enum.TradePavilion.ListObjectTypeEnum.Brand).ToList();
var e2list = list.Where(x => x.ObjectType == Common.Enum.TradePavilion.ListObjectTypeEnum.Carrier).ToList(); var e2list = list.Where(x => x.ObjectType == Common.Enum.TradePavilion.ListObjectTypeEnum.Carrier).ToList();
...@@ -494,6 +496,46 @@ namespace Mall.Module.TradePavilion ...@@ -494,6 +496,46 @@ namespace Mall.Module.TradePavilion
return list; return list;
} }
#region 报名excel导出
/// <summary>
/// 单榜单excel导出
/// </summary>
/// <param name="listId"></param>
/// <param name="mallBaseId"></param>
/// <returns></returns>
public List<ExcelDataSource> GetFirstShopListEnrollToExcel(int listId, int mallBaseId)
{
List<ExcelDataSource> RList = new List<ExcelDataSource>();
var enrollList = firstShop_ListEnrollRepository.GetList(new RB_FirstShop_ListEnroll_Extend() { MallBaseId = mallBaseId, ListId = listId });
if (enrollList.Any()) {
#region 组装头部
var enrollModel = enrollList.FirstOrDefault();
if (string.IsNullOrEmpty(enrollModel.Content))
{
return new List<ExcelDataSource>();
}
ExcelDataSource header = new ExcelDataSource()
{
ExcelRows = new List<ExcelColumn>(30) {
new ExcelColumn(value: "企业名称") { CellWidth = 15, HAlignmentEnum = HAlignmentEnum.CENTER, VAlignmentEnum = VAlignmentEnum.CENTER }
},
ColumnHight = 30
};
List<FormDataItem> elist = JsonHelper.DeserializeObject<List<FormDataItem>>(enrollModel.Content);
if (elist.Any())
{
foreach (var item in elist)
{
var obj = JsonHelper.DeserializeObject<UploadItem>(item.CompData.ToString());
header.ExcelRows.Add(new ExcelColumn(value: obj.Name) { CellWidth = 15, HAlignmentEnum = HAlignmentEnum.CENTER, VAlignmentEnum = VAlignmentEnum.CENTER });
}
}
#endregion
}
return RList;
}
#endregion
/// <summary> /// <summary>
/// 设置报名状态 /// 设置报名状态
/// </summary> /// </summary>
...@@ -523,7 +565,8 @@ namespace Mall.Module.TradePavilion ...@@ -523,7 +565,8 @@ namespace Mall.Module.TradePavilion
//重置 //重置
keyValues.Add(nameof(RB_FirstShop_ListEnroll_Extend.CandidateState), 1); keyValues.Add(nameof(RB_FirstShop_ListEnroll_Extend.CandidateState), 1);
} }
else { else
{
return "状态有误,请核实后再试"; return "状态有误,请核实后再试";
} }
List<WhereHelper> wheres = new List<WhereHelper>() { List<WhereHelper> wheres = new List<WhereHelper>() {
...@@ -612,7 +655,8 @@ namespace Mall.Module.TradePavilion ...@@ -612,7 +655,8 @@ namespace Mall.Module.TradePavilion
//首先清除历史评比 //首先清除历史评比
firstShop_ListEnrollRepository.ClearHostoryAppraisal(listId, mallBaseId); firstShop_ListEnrollRepository.ClearHostoryAppraisal(listId, mallBaseId);
int RankListState = type == 1 ? 3 : 2; int RankListState = type == 1 ? 3 : 2;
if (type == 1) { if (type == 1)
{
//设置榜单为已放榜 //设置榜单为已放榜
Dictionary<string, object> keyValues = new Dictionary<string, object>() { Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_FirstShop_List_Extend.ListState),Common.Enum.TradePavilion.ListStateEnum.Confirmed}, { nameof(RB_FirstShop_List_Extend.ListState),Common.Enum.TradePavilion.ListStateEnum.Confirmed},
...@@ -628,7 +672,8 @@ namespace Mall.Module.TradePavilion ...@@ -628,7 +672,8 @@ namespace Mall.Module.TradePavilion
}; };
firstShop_ListRepository.Update(keyValues, wheres); firstShop_ListRepository.Update(keyValues, wheres);
} }
foreach (var item in deList) { foreach (var item in deList)
{
Dictionary<string, object> keyValues = new Dictionary<string, object>() { Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_FirstShop_ListEnroll_Extend.Reviews),item.Reviews }, { nameof(RB_FirstShop_ListEnroll_Extend.Reviews),item.Reviews },
{ nameof(RB_FirstShop_ListEnroll_Extend.Rank),item.Rank }, { nameof(RB_FirstShop_ListEnroll_Extend.Rank),item.Rank },
...@@ -784,7 +829,7 @@ namespace Mall.Module.TradePavilion ...@@ -784,7 +829,7 @@ namespace Mall.Module.TradePavilion
if (enrollModel == null) { errorMsg = "报名信息不存在"; return ""; } if (enrollModel == null) { errorMsg = "报名信息不存在"; return ""; }
//获取榜单信息 //获取榜单信息
var listModel = firstShop_ListRepository.GetEntity(enrollModel.ListId); var listModel = firstShop_ListRepository.GetEntity(enrollModel.ListId);
if (listModel == null) { errorMsg = "榜单不存在";return ""; } if (listModel == null) { errorMsg = "榜单不存在"; return ""; }
//创建一个临时文件夹 //创建一个临时文件夹
string tempFoldr = ""; string tempFoldr = "";
...@@ -801,13 +846,15 @@ namespace Mall.Module.TradePavilion ...@@ -801,13 +846,15 @@ namespace Mall.Module.TradePavilion
if (elist.Any()) if (elist.Any())
{ {
//开始下载图片视频至临时文件 //开始下载图片视频至临时文件
foreach (var item in elist) { foreach (var item in elist)
{
var obj = JsonHelper.DeserializeObject<UploadItem>(item.CompData.ToString()); var obj = JsonHelper.DeserializeObject<UploadItem>(item.CompData.ToString());
if (item.CompKey == "ImageUploadComp") if (item.CompKey == "ImageUploadComp")
{ {
//图片处理 //图片处理
string Name = obj.Name; string Name = obj.Name;
foreach (var qitem in obj.FileList) { foreach (var qitem in obj.FileList)
{
//FileHelper.CreateImage(); 下载腾讯云至本地 //FileHelper.CreateImage(); 下载腾讯云至本地
} }
} }
...@@ -835,5 +882,72 @@ namespace Mall.Module.TradePavilion ...@@ -835,5 +882,72 @@ namespace Mall.Module.TradePavilion
{ {
return ""; return "";
} }
/// <summary>
/// 榜单报名下载word 单次
/// </summary>
/// <param name="enrollId"></param>
/// <param name="mallBaseId"></param>
/// <returns></returns>
public string GetFirstShopEnrollZipExport(string listIds, int mallBaseId, out string errorMsg)
{
errorMsg = "";
//存储的临时文件地址
string rootBook = AppDomain.CurrentDomain.BaseDirectory;
string tempPath = rootBook + "/upfile/temporary/firstshopenrollzip";
//获取榜单信息
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 tempFoldr = "";
#region 解析表单内容
foreach (var enrollModel in listModel)
{
if (string.IsNullOrEmpty(enrollModel.Content))
{
errorMsg = "报名内容不存在,请核实后再试";
return "";
}
List<FormDataItem> elist = JsonHelper.DeserializeObject<List<FormDataItem>>(enrollModel.Content);
elist = elist.Where(x => x.CompKey == "ImageUploadComp" || x.CompKey == "VideoUploadComp").ToList();
if (elist.Any())
{
//开始下载图片视频至临时文件
foreach (var item in elist)
{
var obj = JsonHelper.DeserializeObject<UploadItem>(item.CompData.ToString());
if (item.CompKey == "ImageUploadComp")
{
//图片处理
string Name = obj.Name;
foreach (var qitem in obj.FileList)
{
//FileHelper.CreateImage(); 下载腾讯云至本地
}
}
else if (item.CompKey == "VideoUploadComp")
{
//视频处理
}
}
}
}
//ZipHelper.Zip(); 打包方法
#endregion
return "";
}
} }
} }
...@@ -83,6 +83,10 @@ where {where} order by w.Id desc ...@@ -83,6 +83,10 @@ where {where} order by w.Id desc
{ {
where += $@" and w.{nameof(RB_FirstShop_ListEnroll_Extend.ListId)}={dmodel.ListId}"; where += $@" and w.{nameof(RB_FirstShop_ListEnroll_Extend.ListId)}={dmodel.ListId}";
} }
if (!string.IsNullOrEmpty(dmodel.ListIds))
{
where += $@" and w.{nameof(RB_FirstShop_ListEnroll_Extend.ListId)} in ({dmodel.ListIds})";
}
if (dmodel.UserId > 0) if (dmodel.UserId > 0)
{ {
where += $@" and w.{nameof(RB_FirstShop_ListEnroll_Extend.UserId)}={dmodel.UserId}"; where += $@" and w.{nameof(RB_FirstShop_ListEnroll_Extend.UserId)}={dmodel.UserId}";
......
...@@ -119,6 +119,10 @@ where {where} {orderBy} ...@@ -119,6 +119,10 @@ where {where} {orderBy}
{ {
where += $@" and find_in_set('{dmodel.ObjectTypeId}',w.{nameof(RB_FirstShop_List_Extend.ListType)})"; where += $@" and find_in_set('{dmodel.ObjectTypeId}',w.{nameof(RB_FirstShop_List_Extend.ListType)})";
} }
if (!string.IsNullOrWhiteSpace(dmodel.QIds))
{
where += $@" and w.{nameof(RB_FirstShop_List_Extend.Id)} in ({dmodel.QIds})";
}
if (dmodel.ListState > 0) if (dmodel.ListState > 0)
{ {
if (dmodel.ListState == Common.Enum.TradePavilion.ListStateEnum.Enroll) if (dmodel.ListState == Common.Enum.TradePavilion.ListStateEnum.Enroll)
......
...@@ -9,6 +9,7 @@ using System.Threading.Tasks; ...@@ -9,6 +9,7 @@ using System.Threading.Tasks;
using Mall.Common.API; using Mall.Common.API;
using Mall.WebApi.Controllers.User; using Mall.WebApi.Controllers.User;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using NPOI.XWPF.UserModel;
namespace Mall.WebApi.Controllers.Export namespace Mall.WebApi.Controllers.Export
{ {
......
...@@ -2280,6 +2280,41 @@ namespace Mall.WebApi.Controllers.TradePavilion ...@@ -2280,6 +2280,41 @@ namespace Mall.WebApi.Controllers.TradePavilion
return ApiResult.Success("", pageModel); return ApiResult.Success("", pageModel);
} }
/// <summary>
/// 获取榜单
/// </summary>
/// <returns></returns>
[HttpPost]
public FileContentResult GetFirstShopListEnrollToExcel() {
string ExcelName = "榜单报名" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls";
List<ExcelDataSource> slist = new List<ExcelDataSource>();
var req = base.RequestParm;
JObject parms = JObject.Parse(req.msg.ToString());
int ListId = parms.GetInt("ListId", 0);//榜单id
if (ListId <= 0)
{
var byteData1 = ExcelTempLateHelper.ToExcelExtend(slist);
return File(byteData1, "application/octet-stream", ExcelName);
}
try
{
List<ExcelDataSource> RList = firstShopListModule.GetFirstShopListEnrollToExcel(ListId, req.MallBaseId);
slist.AddRange(RList);
var byteData = ExcelTempLateHelper.ToExcelExtend(slist);
return File(byteData, "application/octet-stream", ExcelName);
}
catch (Exception ex)
{
LogHelper.Write(ex, string.Format("GetFirstShopListEnrollToExcel: {0}", JsonHelper.Serialize(RequestParm)));
var byteData1 = ExcelTempLateHelper.ToExcelExtend(slist);
return File(byteData1, "application/octet-stream", ExcelName);
}
}
/// <summary> /// <summary>
/// 报名列表word导出 /// 报名列表word导出
/// </summary> /// </summary>
...@@ -2477,6 +2512,36 @@ namespace Mall.WebApi.Controllers.TradePavilion ...@@ -2477,6 +2512,36 @@ namespace Mall.WebApi.Controllers.TradePavilion
x.ObjectIcon, x.ObjectIcon,
})); }));
} }
/// <summary>
/// 报名列表word导出
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetFirstShopEnrollZipExport()
{
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(ListIds, req.MallBaseId, out string errmsg);
if (errmsg == "")
{
return ApiResult.Success("", path);
}
else
{
return ApiResult.Failed(errmsg);
}
}
#endregion #endregion
#region 心愿单列表 #region 心愿单列表
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment