Commit 3ff6093a authored by 吴春's avatar 吴春

提交代码

parent 3c95394c
using System;
using System.Collections.Generic;
using System.Text;
using Mall.Common.Plugin;
namespace Mall.Common.Enum.TradePavilion
{
/// <summary>
/// 品牌下载枚举列表
/// </summary>
public enum BusinessExportEnum
{
/// <summary>
/// 品牌分类
/// </summary>
[EnumField("品牌分类")]
ClassName = 1,
/// <summary>
/// 品牌全名
/// </summary>
[EnumField("品牌全名")]
FullBrandName = 2,
/// <summary>
/// 品牌名
/// </summary>
[EnumField("品牌名")]
BrandName = 3,
/// <summary>
/// 品牌视频
/// </summary>
[EnumField("品牌视频")]
VideoUrl = 4,
/// <summary>
/// 店铺数量
/// </summary>
[EnumField("店铺数量")]
ShopNum = 5,
/// <summary>
/// 建筑面积
/// </summary>
[EnumField("建筑面积")]
BuiltUpArea = 6,
/// <summary>
/// 需求面积
/// </summary>
[EnumField("需求面积")]
AreaRequirement = 7,
/// <summary>
/// 客群定位
/// </summary>
[EnumField("客群定位")]
CustomerType = 8,
/// <summary>
/// 品牌定位
/// </summary>
[EnumField("品牌定位")]
BrandType = 9,
/// <summary>
/// 拓店区域
/// </summary>
[EnumField("拓店区域")]
StoreExpansion = 10,
/// <summary>
/// 商铺性质
/// </summary>
[EnumField("商铺性质")]
ProjectType = 11,
/// <summary>
/// 店铺开口尺寸
/// </summary>
[EnumField("店铺开口尺寸")]
IsShopSize = 12,
/// <summary>
/// 燃气
/// </summary>
[EnumField("燃气")]
RanQi = 13,
/// <summary>
/// 排烟量
/// </summary>
[EnumField("排烟量")]
PaiYan = 14,
/// <summary>
/// 电量
/// </summary>
[EnumField("电量")]
IsDianLiang = 15,
/// <summary>
/// 上下水
/// </summary>
[EnumField("上下水")]
Plumbing = 16,
/// <summary>
/// 管径
/// </summary>
[EnumField("管径")]
Caliber = 17,
/// <summary>
/// 排污
/// </summary>
[EnumField("排污")]
Sewage = 18,
/// <summary>
/// 空调
/// </summary>
[EnumField("空调")]
KongTiao = 19,
/// <summary>
/// 新风
/// </summary>
[EnumField("新风")]
XinFeng = 20,
/// <summary>
/// 广告
/// </summary>
[EnumField("广告")]
Advertising = 21,
/// <summary>
/// 其他
/// </summary>
[EnumField("其他")]
Other = 22,
/// <summary>
/// Logo
/// </summary>
[EnumField("Logo")]
Logo = 23,
}
}
...@@ -3,7 +3,10 @@ using NPOI.HSSF.Util; ...@@ -3,7 +3,10 @@ using NPOI.HSSF.Util;
using NPOI.SS.UserModel; using NPOI.SS.UserModel;
using NPOI.SS.Util; using NPOI.SS.Util;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO; using System.IO;
using System.Linq;
namespace Mall.Common.Plugin namespace Mall.Common.Plugin
{ {
...@@ -19,7 +22,7 @@ namespace Mall.Common.Plugin ...@@ -19,7 +22,7 @@ namespace Mall.Common.Plugin
/// <param name="list">模板数据</param> /// <param name="list">模板数据</param>
/// <param name="isTempLate">是否模板导出</param> /// <param name="isTempLate">是否模板导出</param>
/// <param name="tempLatePath">模板文件路劲</param> /// <param name="tempLatePath">模板文件路劲</param>
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 = null;
...@@ -53,7 +56,7 @@ namespace Mall.Common.Plugin ...@@ -53,7 +56,7 @@ namespace Mall.Common.Plugin
dataRow.Height = 20 * 20;//行高 dataRow.Height = 20 * 20;//行高
} }
int columnsIndex = 0; int columnsIndex = 0;
//循环添加列 //循环添加列
foreach (var subItem in item.ExcelRows) foreach (var subItem in item.ExcelRows)
{ {
...@@ -217,6 +220,9 @@ namespace Mall.Common.Plugin ...@@ -217,6 +220,9 @@ namespace Mall.Common.Plugin
} }
} }
/// <summary> /// <summary>
/// 模板导出 /// 模板导出
/// </summary> /// </summary>
...@@ -245,9 +251,10 @@ namespace Mall.Common.Plugin ...@@ -245,9 +251,10 @@ namespace Mall.Common.Plugin
HSSFPalette palette = workbook.GetCustomPalette(); HSSFPalette palette = workbook.GetCustomPalette();
int rowIndex = 0; int rowIndex = 0;
HSSFFont ffont = (HSSFFont)workbook.CreateFont(); HSSFFont ffont = (HSSFFont)workbook.CreateFont();
//单元格样式 //单元格样式
HSSFCellStyle fCellStyle = (HSSFCellStyle)workbook.CreateCellStyle(); HSSFCellStyle fCellStyle = (HSSFCellStyle)workbook.CreateCellStyle();
//循环添加行 //循环添加行
foreach (var item in list) foreach (var item in list)
{ {
...@@ -261,145 +268,198 @@ namespace Mall.Common.Plugin ...@@ -261,145 +268,198 @@ namespace Mall.Common.Plugin
dataRow.Height = 50 * 10;//行高 dataRow.Height = 50 * 10;//行高
} }
int columnsIndex = 0; int columnsIndex = 0;
//循环添加列 //循环添加列
foreach (var subItem in item.ExcelRows) foreach (var subItem in item.ExcelRows)
{ {
var cell = dataRow.CreateCell(columnsIndex); if (subItem.Pic == 1 && !string.IsNullOrWhiteSpace(subItem.Value))
fCellStyle.WrapText = true;
//设置单元宽度
if (subItem.CellWidth > 0)
{ {
sheet.SetColumnWidth(columnsIndex, subItem.CellWidth * 256); HSSFPatriarch patriarch = (HSSFPatriarch)sheet.CreateDrawingPatriarch();
}
//设置单元格背景颜色 //System.Net.WebRequest request = System.Net.WebRequest.Create(subItem.Value);
switch (subItem.BgColorEnum) //System.Net.WebResponse response = request.GetResponse();
{ //Stream responseStream = response.GetResponseStream();
case ColorEnum.BrightGreen:
fCellStyle.FillForegroundColor = HSSFColor.BrightGreen.Index; try
fCellStyle.FillPattern = FillPattern.SolidForeground;
break;
case ColorEnum.DarkBlue:
fCellStyle.FillForegroundColor = HSSFColor.DarkBlue.Index;
fCellStyle.FillPattern = FillPattern.SolidForeground;
break;
case ColorEnum.Red:
fCellStyle.FillForegroundColor = HSSFColor.Red.Index;
fCellStyle.FillPattern = FillPattern.SolidForeground;
break;
}
if (subItem.FontHeight > 0)
{
ffont.FontHeight = subItem.FontHeight * 20;
}
else
{
ffont.FontHeight = 11 * 20;
}
if (!string.IsNullOrWhiteSpace(subItem.FontName))
{
ffont.FontName = subItem.FontName;
}
else
{
ffont.FontName = "宋体";
}
if (subItem.FontSize > 0)
{
ffont.FontHeightInPoints = subItem.FontSize;
}
//设置字体颜色
switch (subItem.FontColorEnum)
{
case ColorEnum.Red:
ffont.Color = HSSFColor.Red.Index;
break;
case ColorEnum.Green:
ffont.Color = HSSFColor.Green.Index;
break;
}
//字体加粗 {
if (subItem.IsBold) //byte[] bytes = new byte[1024];
{ //int osize = responseStream.Read(bytes, 0, (int)bytes.Length);
ffont.Boldweight = (short)NPOI.SS.UserModel.FontBoldWeight.Bold; //while (osize > 0)
} //{
fCellStyle.SetFont(ffont);
//水平对齐方式 // responseStream.Write(bytes, 0, osize);
switch (subItem.HAlignmentEnum) // osize = responseStream.Read(bytes, 0, (int)bytes.Length);//读取当前字节流的总长度
{ //}
case HAlignmentEnum.CENTER: //responseStream.Flush();
fCellStyle.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center;
break;
case HAlignmentEnum.LEFT:
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;
}
//垂直对齐方式 int pictureIdx = workbook.AddPicture(bytes, PictureType.JPEG);
switch (subItem.VAlignmentEnum)
{
case VAlignmentEnum.CENTER:
fCellStyle.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center;
break;
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)
{ // byte[] bytes = System.IO.File.ReadAllBytes(subItem.Value);
fCellStyle.BorderBottom = BorderStyle.Thin; // int pictureIdx = workbook.AddPicture(bytes, PictureType.JPEG);
fCellStyle.BorderLeft = BorderStyle.Thin; // 插图片的位置 HSSFClientAnchor(dx1,dy1,dx2,dy2,col1,row1,col2,row2) 后面再作解释
fCellStyle.BorderRight = BorderStyle.Thin; HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 0, 0, columnsIndex, rowIndex, columnsIndex + 1, rowIndex + 1);
fCellStyle.BorderTop = BorderStyle.Thin; //把图片插到相应的位置
HSSFPicture pict = (HSSFPicture)patriarch.CreatePicture(anchor, pictureIdx);
}
finally
{
// 释放资源
//if (responseStream != null) responseStream.Close();
//if (response != null) { response.Close(); response.Dispose(); }
//if (request != null) { request.Abort(); }
}
// SetPic(workbook, patriarch, subItem.Value, sheet, rowIndex, columnsIndex);
} }
else else
{ {
fCellStyle.BorderBottom = BorderStyle.None; var cell = dataRow.CreateCell(columnsIndex);
fCellStyle.BorderLeft = BorderStyle.None; fCellStyle.WrapText = true;
fCellStyle.BorderRight = BorderStyle.None; //设置单元宽度
fCellStyle.BorderTop = BorderStyle.None; if (subItem.CellWidth > 0)
} {
//合并单元格 sheet.SetColumnWidth(columnsIndex, subItem.CellWidth * 256);
if (subItem.Colspan > 1 || subItem.Rowspan > 1) }
{
var region = new CellRangeAddress(rowIndex, rowIndex + (subItem.Rowspan - 1), columnsIndex, columnsIndex + (subItem.Colspan - 1));
sheet.AddMergedRegion(region);
for (int i = region.FirstRow; i <= region.LastRow; i++) //设置单元格背景颜色
switch (subItem.BgColorEnum)
{ {
IRow row = HSSFCellUtil.GetRow(i, sheet); case ColorEnum.BrightGreen:
for (int j = region.FirstColumn; j <= region.LastColumn; j++) fCellStyle.FillForegroundColor = HSSFColor.BrightGreen.Index;
fCellStyle.FillPattern = FillPattern.SolidForeground;
break;
case ColorEnum.DarkBlue:
fCellStyle.FillForegroundColor = HSSFColor.DarkBlue.Index;
fCellStyle.FillPattern = FillPattern.SolidForeground;
break;
case ColorEnum.Red:
fCellStyle.FillForegroundColor = HSSFColor.Red.Index;
fCellStyle.FillPattern = FillPattern.SolidForeground;
break;
}
if (subItem.FontHeight > 0)
{
ffont.FontHeight = subItem.FontHeight * 20;
}
else
{
ffont.FontHeight = 11 * 20;
}
if (!string.IsNullOrWhiteSpace(subItem.FontName))
{
ffont.FontName = subItem.FontName;
}
else
{
ffont.FontName = "宋体";
}
if (subItem.FontSize > 0)
{
ffont.FontHeightInPoints = subItem.FontSize;
}
//设置字体颜色
switch (subItem.FontColorEnum)
{
case ColorEnum.Red:
ffont.Color = HSSFColor.Red.Index;
break;
case ColorEnum.Green:
ffont.Color = HSSFColor.Green.Index;
break;
}
//字体加粗
if (subItem.IsBold)
{
ffont.Boldweight = (short)NPOI.SS.UserModel.FontBoldWeight.Bold;
}
fCellStyle.SetFont(ffont);
//水平对齐方式
switch (subItem.HAlignmentEnum)
{
case HAlignmentEnum.CENTER:
fCellStyle.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center;
break;
case HAlignmentEnum.LEFT:
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)
{
case VAlignmentEnum.CENTER:
fCellStyle.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center;
break;
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)
{
fCellStyle.BorderBottom = BorderStyle.Thin;
fCellStyle.BorderLeft = BorderStyle.Thin;
fCellStyle.BorderRight = BorderStyle.Thin;
fCellStyle.BorderTop = BorderStyle.Thin;
}
else
{
fCellStyle.BorderBottom = BorderStyle.None;
fCellStyle.BorderLeft = BorderStyle.None;
fCellStyle.BorderRight = BorderStyle.None;
fCellStyle.BorderTop = BorderStyle.None;
}
//合并单元格
if (subItem.Colspan > 1 || subItem.Rowspan > 1)
{
var region = new CellRangeAddress(rowIndex, rowIndex + (subItem.Rowspan - 1), columnsIndex, columnsIndex + (subItem.Colspan - 1));
sheet.AddMergedRegion(region);
for (int i = region.FirstRow; i <= region.LastRow; i++)
{ {
ICell singleCell = HSSFCellUtil.GetCell(row, (short)j); IRow row = HSSFCellUtil.GetRow(i, sheet);
singleCell.CellStyle = fCellStyle; for (int j = region.FirstColumn; j <= region.LastColumn; j++)
{
ICell singleCell = HSSFCellUtil.GetCell(row, (short)j);
singleCell.CellStyle = fCellStyle;
}
} }
columnsIndex = columnsIndex + subItem.Colspan;
} }
columnsIndex = columnsIndex + subItem.Colspan; else
} {
else cell.CellStyle = fCellStyle;
{ columnsIndex++;
cell.CellStyle = fCellStyle; }
columnsIndex++; cell.SetCellValue(subItem.Value == null ? "" : subItem.Value);
} }
cell.SetCellValue(subItem.Value == null ? "" : subItem.Value);
} }
rowIndex++; rowIndex++;
} }
...@@ -414,6 +474,40 @@ namespace Mall.Common.Plugin ...@@ -414,6 +474,40 @@ namespace Mall.Common.Plugin
} }
private static void SetPic(HSSFWorkbook workbook, HSSFPatriarch patriarch, string path, ISheet sheet, int rowline, int col)
{
try
{
if (string.IsNullOrEmpty(path)) return;
System.Net.WebRequest request = System.Net.WebRequest.Create(path);
System.Net.WebResponse response = request.GetResponse();
Stream responseStream = response.GetResponseStream();
int buffersize = 1024;
byte[] buffer = new byte[buffersize];
int count = responseStream.Read(buffer, 0, buffersize);
while (count > 0)
{
count = responseStream.Read(buffer, 0, buffersize);
}
int pictureIdx = workbook.AddPicture(buffer, PictureType.JPEG);
// byte[] bytes = System.IO.File.ReadAllBytes(path);
// int pictureIdx = workbook.AddPicture(bytes, PictureType.JPEG);
// 插图片的位置 HSSFClientAnchor(dx1,dy1,dx2,dy2,col1,row1,col2,row2) 后面再作解释
HSSFClientAnchor anchor = new HSSFClientAnchor(70, 10, 0, 0, col, rowline, col + 1, rowline + 1);
//把图片插到相应的位置
HSSFPicture pict = (HSSFPicture)patriarch.CreatePicture(anchor, pictureIdx);
}
catch (System.Exception ex)
{
return;
}
}
#region [颜色:16进制转成RGB] #region [颜色:16进制转成RGB]
/// <summary> /// <summary>
/// [颜色:16进制转成RGB] /// [颜色:16进制转成RGB]
...@@ -505,11 +599,13 @@ namespace Mall.Common.Plugin ...@@ -505,11 +599,13 @@ namespace Mall.Common.Plugin
/// <param name="colspan">跨列(默认一列,不跨列)</param> /// <param name="colspan">跨列(默认一列,不跨列)</param>
/// <param name="rowspan">跨行(默认一行,不跨行)</param> /// <param name="rowspan">跨行(默认一行,不跨行)</param>
/// <param name="selfBgColorIndex">自定义单元格背景颜色(索引)</param> /// <param name="selfBgColorIndex">自定义单元格背景颜色(索引)</param>
public ExcelColumn(string value = "", int colspan = 1, int rowspan = 1, short selfBgColorIndex = 0) /// <param name="isPic">0-不是图片,1-是图片</param>
public ExcelColumn(string value = "", int colspan = 1, int rowspan = 1, short selfBgColorIndex = 0, int isPic = 0)
{ {
this.Value = value; this.Value = value;
this.Colspan = colspan; this.Colspan = colspan;
this.Rowspan = rowspan; this.Rowspan = rowspan;
this.Pic = isPic;
this.SelfBgColorIndex = selfBgColorIndex; this.SelfBgColorIndex = selfBgColorIndex;
} }
...@@ -580,6 +676,11 @@ namespace Mall.Common.Plugin ...@@ -580,6 +676,11 @@ namespace Mall.Common.Plugin
/// 字体大小 /// 字体大小
/// </summary> /// </summary>
public short FontSize { get; set; } public short FontSize { get; set; }
/// <summary>
/// 1-是图片
/// </summary>
public int Pic { get; set; }
} }
/// <summary> /// <summary>
......
...@@ -27,5 +27,10 @@ namespace Mall.Model.Extend.TradePavilion ...@@ -27,5 +27,10 @@ namespace Mall.Model.Extend.TradePavilion
/// 收藏id /// 收藏id
/// </summary> /// </summary>
public int CollectId { get; set; } public int CollectId { get; set; }
/// <summary>
/// 导出枚举ids
/// </summary>
public List<int> ExcelEnumIds { get; set; }
} }
} }
...@@ -137,6 +137,11 @@ WHERE 1=1 ...@@ -137,6 +137,11 @@ WHERE 1=1
{ {
builder.AppendFormat(" AND a.{0}={1} ", nameof(RB_Brand_Extend.BrandClassId), query.BrandClassId); builder.AppendFormat(" AND a.{0}={1} ", nameof(RB_Brand_Extend.BrandClassId), query.BrandClassId);
} }
if (query.ProjectType.HasValue && query.ProjectType > 0)
{
builder.AppendFormat(" AND a.{0}={1} ", nameof(RB_Brand_Extend.ProjectType), (int)query.ProjectType);
}
} }
return Get<RB_Brand_Extend>(builder.ToString(), parameters).FirstOrDefault(); return Get<RB_Brand_Extend>(builder.ToString(), parameters).FirstOrDefault();
} }
...@@ -167,10 +172,6 @@ WHERE 1=1 ...@@ -167,10 +172,6 @@ WHERE 1=1
{ {
builder.AppendFormat(" AND a.{0}={1} ", nameof(RB_Brand_Extend.TenantId), query.TenantId); builder.AppendFormat(" AND a.{0}={1} ", nameof(RB_Brand_Extend.TenantId), query.TenantId);
} }
if (query.ID > 0)
{
builder.AppendFormat(" AND a.{0}={1} ", nameof(RB_Brand_Extend.ID), query.ID);
}
if (query.MallBaseId > 0) if (query.MallBaseId > 0)
{ {
builder.AppendFormat(" AND a.{0}={1} ", nameof(RB_Brand_Extend.MallBaseId), query.MallBaseId); builder.AppendFormat(" AND a.{0}={1} ", nameof(RB_Brand_Extend.MallBaseId), query.MallBaseId);
...@@ -184,6 +185,44 @@ WHERE 1=1 ...@@ -184,6 +185,44 @@ WHERE 1=1
{ {
builder.AppendFormat(" AND a.{0}={1} ", nameof(RB_Brand_Extend.BrandClassId), query.BrandClassId); builder.AppendFormat(" AND a.{0}={1} ", nameof(RB_Brand_Extend.BrandClassId), query.BrandClassId);
} }
if (query.ProjectType.HasValue && query.ProjectType > 0)
{
builder.AppendFormat(" AND a.{0}={1} ", nameof(RB_Brand_Extend.ProjectType), (int)query.ProjectType);
}
if (query.RanQi > -1)
{
builder.AppendFormat(" AND a.{0}={1} ", nameof(RB_Brand_Extend.RanQi), query.RanQi);
}
if (query.KongTiao > -1)
{
builder.AppendFormat(" AND a.{0}={1} ", nameof(RB_Brand_Extend.KongTiao), query.KongTiao);
}
if (query.XinFeng > -1)
{
builder.AppendFormat(" AND a.{0}={1} ", nameof(RB_Brand_Extend.XinFeng), query.XinFeng);
}
if (query.Plumbing > -1)
{
builder.AppendFormat(" AND a.{0}={1} ", nameof(RB_Brand_Extend.Plumbing), query.Plumbing);
}
if (query.Caliber > -1)
{
builder.AppendFormat(" AND a.{0}={1} ", nameof(RB_Brand_Extend.Caliber), query.Caliber);
}
if (query.Sewage > -1)
{
builder.AppendFormat(" AND a.{0}={1} ", nameof(RB_Brand_Extend.Sewage), query.Sewage);
}
if (query.PaiYan > -1)
{
builder.AppendFormat(" AND a.{0}={1} ", nameof(RB_Brand_Extend.PaiYan), query.PaiYan);
}
if (!string.IsNullOrEmpty(query.DianLiang))
{
builder.AppendFormat(" AND a.{0} LIKE @DianLiang ", nameof(RB_Brand_Extend.DianLiang));
parameters.Add("DianLiang", "%" + query.DianLiang.Trim() + "%");
}
} }
return Get<RB_Brand_Extend>(builder.ToString(), parameters).ToList(); return Get<RB_Brand_Extend>(builder.ToString(), parameters).ToList();
} }
......
...@@ -871,7 +871,8 @@ namespace Mall.WebApi.Controllers.TradePavilion ...@@ -871,7 +871,8 @@ namespace Mall.WebApi.Controllers.TradePavilion
{ {
item.BannerList = JsonConvert.DeserializeObject<List<string>>(item.Banner); item.BannerList = JsonConvert.DeserializeObject<List<string>>(item.Banner);
} }
else { else
{
item.BannerList = new List<string>(); item.BannerList = new List<string>();
} }
} }
...@@ -1134,7 +1135,13 @@ namespace Mall.WebApi.Controllers.TradePavilion ...@@ -1134,7 +1135,13 @@ namespace Mall.WebApi.Controllers.TradePavilion
}; };
query.MallBaseId = RequestParm.MallBaseId; query.MallBaseId = RequestParm.MallBaseId;
query.TenantId = RequestParm.TenantId; query.TenantId = RequestParm.TenantId;
query.RanQi = -1;
query.KongTiao = -1;
query.XinFeng = -1;
query.Plumbing = -1;
query.Caliber = -1;
query.PaiYan = -1;
query.Sewage = -1;
var extModel = carrierModule.GetBrand(query); var extModel = carrierModule.GetBrand(query);
if (!string.IsNullOrWhiteSpace(extModel.Banner)) if (!string.IsNullOrWhiteSpace(extModel.Banner))
...@@ -1171,6 +1178,9 @@ namespace Mall.WebApi.Controllers.TradePavilion ...@@ -1171,6 +1178,9 @@ namespace Mall.WebApi.Controllers.TradePavilion
var list = carrierModule.GetBrandClassList(query); var list = carrierModule.GetBrandClassList(query);
return ApiResult.Success(data: list); return ApiResult.Success(data: list);
} }
#endregion #endregion
#region 关注 #region 关注
...@@ -1186,9 +1196,9 @@ namespace Mall.WebApi.Controllers.TradePavilion ...@@ -1186,9 +1196,9 @@ namespace Mall.WebApi.Controllers.TradePavilion
JObject jobj = JObject.Parse(RequestParm.msg.ToString()); JObject jobj = JObject.Parse(RequestParm.msg.ToString());
var query = new RB_Collect_Extend() var query = new RB_Collect_Extend()
{ {
Id=jobj.GetInt("Id"), Id = jobj.GetInt("Id"),
Type=jobj.GetInt("Type"), Type = jobj.GetInt("Type"),
SourceId=jobj.GetInt("SourceId"), SourceId = jobj.GetInt("SourceId"),
}; };
query.TenantId = userInfo.TenantId; query.TenantId = userInfo.TenantId;
query.MallBaseId = userInfo.MallBaseId; query.MallBaseId = userInfo.MallBaseId;
......
...@@ -1013,8 +1013,8 @@ namespace Mall.WebApi.Controllers.TradePavilion ...@@ -1013,8 +1013,8 @@ namespace Mall.WebApi.Controllers.TradePavilion
if (flag) if (flag)
{ {
//查询用户的信息 //查询用户的信息
string uids = string.Join(",", list.Select(x=>x.CreateBy)); string uids = string.Join(",", list.Select(x => x.CreateBy));
var memberList = userModule.GetMemberUserList(new Model.Extend.User.RB_Member_User_Extend { TenantId = userInfo.TenantId, MallBaseId = userInfo.MallBaseId ,UserIds= uids }); var memberList = userModule.GetMemberUserList(new Model.Extend.User.RB_Member_User_Extend { TenantId = userInfo.TenantId, MallBaseId = userInfo.MallBaseId, UserIds = uids });
if (memberList != null && memberList.Any()) if (memberList != null && memberList.Any())
{ {
List<string> openidList = new List<string>(); List<string> openidList = new List<string>();
...@@ -1025,7 +1025,7 @@ namespace Mall.WebApi.Controllers.TradePavilion ...@@ -1025,7 +1025,7 @@ namespace Mall.WebApi.Controllers.TradePavilion
openidList.Add(item.OpenId); openidList.Add(item.OpenId);
} }
} }
if (openidList!=null&& openidList.Any()) if (openidList != null && openidList.Any())
{ {
new Module.User.MiniProgramMsgModule().SendHatchExamineMsg(userInfo.TenantId, userInfo.MallBaseId, openidList, AuditState == 2 ? "认证通过" : "认证失败", "首店认证结果通知", System.DateTime.Now.ToString("yyyy年MM月dd日 HH:mm")); new Module.User.MiniProgramMsgModule().SendHatchExamineMsg(userInfo.TenantId, userInfo.MallBaseId, openidList, AuditState == 2 ? "认证通过" : "认证失败", "首店认证结果通知", System.DateTime.Now.ToString("yyyy年MM月dd日 HH:mm"));
} }
...@@ -1347,6 +1347,13 @@ namespace Mall.WebApi.Controllers.TradePavilion ...@@ -1347,6 +1347,13 @@ namespace Mall.WebApi.Controllers.TradePavilion
}; };
query.MallBaseId = RequestParm.MallBaseId; query.MallBaseId = RequestParm.MallBaseId;
query.TenantId = RequestParm.TenantId; query.TenantId = RequestParm.TenantId;
query.RanQi = -1;
query.KongTiao = -1;
query.XinFeng = -1;
query.Plumbing = -1;
query.Caliber = -1;
query.PaiYan = -1;
query.Sewage = -1;
var extModel = carrierModule.GetBrand(query); var extModel = carrierModule.GetBrand(query);
if (!string.IsNullOrWhiteSpace(extModel.Banner)) if (!string.IsNullOrWhiteSpace(extModel.Banner))
...@@ -1406,6 +1413,7 @@ namespace Mall.WebApi.Controllers.TradePavilion ...@@ -1406,6 +1413,7 @@ namespace Mall.WebApi.Controllers.TradePavilion
/// 删除品牌信息 /// 删除品牌信息
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[HttpPost]
public ApiResult RemoveBrand() public ApiResult RemoveBrand()
{ {
JObject parms = JObject.Parse(RequestParm.msg.ToString()); JObject parms = JObject.Parse(RequestParm.msg.ToString());
...@@ -1413,6 +1421,174 @@ namespace Mall.WebApi.Controllers.TradePavilion ...@@ -1413,6 +1421,174 @@ namespace Mall.WebApi.Controllers.TradePavilion
var flag = carrierModule.RemoveBrandModule(CarrierId); var flag = carrierModule.RemoveBrandModule(CarrierId);
return flag ? ApiResult.Success() : ApiResult.Failed(); return flag ? ApiResult.Success() : ApiResult.Failed();
} }
/// <summary>
/// 用户信息下载
/// </summary>
[HttpPost]
public FileContentResult GetMemberUserListToExcel()
{
JObject parms = JObject.Parse(RequestParm.msg.ToString());
var demodel = new RB_Brand_Extend()
{
BrandName = parms.GetStringValue("BrandName"),
ProjectType = (Common.Enum.TradePavilion.ProjectTypeEnum)parms.GetInt("ProjectType", 0),
BrandClassId = parms.GetInt("BrandClassId", 0),
RanQi = parms.GetInt("RanQi", -1),
KongTiao = parms.GetInt("KongTiao", -1),
XinFeng = parms.GetInt("XinFeng", -1),
Plumbing = parms.GetInt("Plumbing", -1),
Caliber = parms.GetInt("Caliber", -1),
Sewage = parms.GetInt("Sewage", -1),
PaiYan = parms.GetInt("PaiYan", -1),
DianLiang = parms.GetStringValue("DianLiang"),
};
try
{
List<int> ExcelEnumIds = JsonConvert.DeserializeObject<List<int>>(parms.GetStringValue("ExcelEnumIds"));
demodel.ExcelEnumIds = ExcelEnumIds;
if (ExcelEnumIds==null||!ExcelEnumIds.Any())
{
demodel.ExcelEnumIds = new List<int>();
//demodel.ExcelEnumIds.Add(23);
for (int i = 1; i <= 23; i++)
{
demodel.ExcelEnumIds.Add(i);
}
}
}
catch (Exception ex)
{
demodel.ExcelEnumIds = new List<int>();
for (int i = 1; i <= 23; i++)
{
demodel.ExcelEnumIds.Add(i);
}
}
string ExcelName = "品牌列表" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls";
List<ExcelDataSource> slist = new List<ExcelDataSource>();
if (demodel.ExcelEnumIds == null || !demodel.ExcelEnumIds.Any())
{
var byteData1 = ExcelTempLateHelper.ToExcelExtend(slist);
return File(byteData1, "application/octet-stream", ExcelName);
}
var Enumlist = EnumHelper.GetEnumList(typeof(Common.Enum.TradePavilion.BusinessExportEnum));
ExcelDataSource header = new ExcelDataSource()
{
ExcelRows = new List<ExcelColumn>(30)
{
new ExcelColumn(value: "序号") { CellWidth = 15, HAlignmentEnum = HAlignmentEnum.CENTER, VAlignmentEnum = VAlignmentEnum.CENTER }
}
};
foreach (var item in demodel.ExcelEnumIds)
{
var Name = Enumlist.Where(x => x.Value == item.ToString()).FirstOrDefault().Key ?? "";
header.ExcelRows.Add(new ExcelColumn(value: Name) { CellWidth = 15, HAlignmentEnum = HAlignmentEnum.CENTER, VAlignmentEnum = VAlignmentEnum.CENTER });
}
slist.Add(header);
try
{
var list = carrierModule.GetBrandListByWhere(demodel).Take(2);
#region 组装数据
int Num = 0;
foreach (var item in list)
{
Num++;
ExcelDataSource datarow = new ExcelDataSource()
{
ExcelRows = new List<ExcelColumn>(30) {
new ExcelColumn(value:Num.ToString()){ },
}
};
foreach (var qitem in demodel.ExcelEnumIds)
{
switch (qitem)
{
case 1:
datarow.ExcelRows.Add(new ExcelColumn(value: item.ClassName) { }); break;
case 2:
datarow.ExcelRows.Add(new ExcelColumn(value: item.FullBrandName) { }); break;
case 3:
datarow.ExcelRows.Add(new ExcelColumn(value: item.BrandName) { }); break;
case 4:
datarow.ExcelRows.Add(new ExcelColumn(value: item.VideoUrl) { }); break;
case 5:
datarow.ExcelRows.Add(new ExcelColumn(value: item.ShopNum.ToString()) { }); break;
case 6:
datarow.ExcelRows.Add(new ExcelColumn(value: (item.BuiltUpArea.ToString()) + "-" + (item.EndBuiltUpArea.ToString())) { }); break;
case 7:
datarow.ExcelRows.Add(new ExcelColumn(value: (item.AreaRequirement.ToString()) + "-" + (item.EndAreaRequirement.ToString())) { }); break;
case 8:
datarow.ExcelRows.Add(new ExcelColumn(value: item.CustomerType) { }); break;
case 9:
datarow.ExcelRows.Add(new ExcelColumn(value: item.BrandType) { }); break;
case 10:
datarow.ExcelRows.Add(new ExcelColumn(value: item.StoreExpansion) { }); break;
case 11:
datarow.ExcelRows.Add(new ExcelColumn(value: ((item.ProjectType.HasValue && item.ProjectType.Value > 0) ? item.ProjectType.GetEnumName() : "")) { }); break;
case 12:
datarow.ExcelRows.Add(new ExcelColumn(value: (item.IsShopSize == 1 ? ("有" + (!string.IsNullOrWhiteSpace(item.ShopSize) ? item.ShopSize : "")) : "无")) { }); break;
case 13:
datarow.ExcelRows.Add(new ExcelColumn(value: (item.RanQi == 1 ? ("有" + (!string.IsNullOrWhiteSpace(item.RanQiBZ) ? item.RanQiBZ : "")) : "无")) { }); break;
case 14:
datarow.ExcelRows.Add(new ExcelColumn(value: (item.PaiYan == 1 ? ("有" + (!string.IsNullOrWhiteSpace(item.PaiYanBZ) ? item.PaiYanBZ : "")) : "无")) { }); break;
case 15:
datarow.ExcelRows.Add(new ExcelColumn(value: (item.IsDianLiang == 1 ? ("有" + (!string.IsNullOrWhiteSpace(item.DianLiang) ? item.DianLiang : "")) : "无")) { }); break;
case 16:
datarow.ExcelRows.Add(new ExcelColumn(value: (item.Plumbing == 1 ? "有" : "无")) { }); break;
case 17:
datarow.ExcelRows.Add(new ExcelColumn(value: (item.Caliber == 1 ? ("有") : "无")) { }); break;
case 18:
datarow.ExcelRows.Add(new ExcelColumn(value: (item.Sewage == 1 ? ("有") : "无")) { }); break;
case 19:
datarow.ExcelRows.Add(new ExcelColumn(value: (item.KongTiao == 1 ? ("有") : "无")) { }); break;
case 20:
datarow.ExcelRows.Add(new ExcelColumn(value: (item.XinFeng == 1 ? ("有") : "无")) { }); break;
case 21:
datarow.ExcelRows.Add(new ExcelColumn(value: item.Advertising) { }); break;
case 22:
datarow.ExcelRows.Add(new ExcelColumn(value: item.Other) { }); break;
case 23:
datarow.ExcelRows.Add(new ExcelColumn(value: item.Logo, isPic: 1) { }); break;
}
}
slist.Add(datarow);
}
#endregion
var byteData = ExcelTempLateHelper.ToExcelExtend(slist);
return File(byteData, "application/octet-stream", ExcelName);
}
catch (Exception ex)
{
LogHelper.Write(ex, string.Format("GetFileFromWebApi_requestData: {0}", JsonHelper.Serialize(RequestParm)));
var byteData1 = ExcelTempLateHelper.ToExcelExtend(slist);
return File(byteData1, "application/octet-stream", ExcelName);
}
}
/// <summary>
/// 获取品牌下载枚举列表
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetBusinessExportEnumList()
{
var list = EnumHelper.GetEnumList(typeof(Common.Enum.TradePavilion.BusinessExportEnum));
return ApiResult.Success("", list.Select(x => new
{
Name = x.Key,
Id = Convert.ToInt32(x.Value)
}));
}
#endregion #endregion
} }
} }
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