Commit 9a65b332 authored by liudong1993's avatar liudong1993

1

parent ae2fc86b
......@@ -111,12 +111,12 @@ WHERE 1=1
DateStr = "DATE_FORMAT(c.CreateDate,'%Y')";
}
string sql = $@"SELECT e1.EduSellId as CreateBy,{DateStr} as Date,
case when e.Id is null and c.BuyType =1 then SUM(c.Number) else 0 end AS LBFreeNum,
case when e.Id is null and c.BuyType =2 then SUM(c.Number) else 0 end AS LBBuyNum,
case when (e.Type =1 or (e.Type =2 and e.StuIsEmp =1)) and c.BuyType =1 then SUM(c.Number) else 0 end AS EmpFreeNum,
case when (e.Type =1 or (e.Type =2 and e.StuIsEmp =1)) and c.BuyType =2 then SUM(c.Number) else 0 end AS EmpBuyNum,
case when e.Type =2 and e.StuIsEmp =0 and c.BuyType =1 then SUM(c.Number) else 0 end AS StuFreeNum,
case when e.Type =2 and e.StuIsEmp =0 and c.BuyType =2 then SUM(c.Number) else 0 end AS StuBuyNum
SUM(case when e.Id is null and c.BuyType =1 then c.Number else 0 end) AS LBFreeNum,
SUM(case when e.Id is null and c.BuyType =2 then c.Number else 0 end) AS LBBuyNum,
SUM(case when (e.Type =1 or (e.Type =2 and e.StuIsEmp =1)) and c.BuyType =1 then c.Number else 0 end) AS EmpFreeNum,
SUM(case when (e.Type =1 or (e.Type =2 and e.StuIsEmp =1)) and c.BuyType =2 then c.Number else 0 end) AS EmpBuyNum,
SUM(case when e.Type =2 and e.StuIsEmp =0 and c.BuyType =1 then c.Number else 0 end) AS StuFreeNum,
SUM(case when e.Type =2 and e.StuIsEmp =0 and c.BuyType =2 then c.Number else 0 end) AS StuBuyNum
FROM rb_member_coffeelog c
INNER JOIN rb_education_edusell e1 on c.CreateBy = e1.UserId
LEFT JOIN rb_education_edusell e on c.UserId = e.UserId
......
......@@ -52,7 +52,7 @@ namespace Mall.WebApi.Controllers.Education
{
RB_Member_CoffeeLog_Extend demodel = JsonHelper.DeserializeObject<RB_Member_CoffeeLog_Extend>(base.RequestParm.msg.ToString());
demodel.MallBaseId = RequestParm.MallBaseId;
string ExcelName = "咖啡统计" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls";
string ExcelName = "咖啡" + (demodel.SelectType == 1 ? "日报表" : demodel.SelectType == 2 ? "月报表" : "年报表") + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls";
List<ExcelDataSource> slist = new List<ExcelDataSource>();
ExcelDataSource header = new ExcelDataSource()
{
......@@ -69,7 +69,6 @@ namespace Mall.WebApi.Controllers.Education
new ExcelColumn(value: "出品杯数") { CellWidth = 15, HAlignmentEnum = HAlignmentEnum.CENTER, VAlignmentEnum = VAlignmentEnum.CENTER }
}
};
slist.Add(header);
try
......@@ -119,5 +118,75 @@ namespace Mall.WebApi.Controllers.Education
});
return ApiResult.Success("", pageModel);
}
/// <summary>
/// 导出咖啡劵明细
/// </summary>
/// <returns></returns>
[HttpPost]
public FileContentResult GetCoffeeCouponsListToExcel()
{
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 = 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 = 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 = 15, HAlignmentEnum = HAlignmentEnum.CENTER, VAlignmentEnum = VAlignmentEnum.CENTER },
new ExcelColumn(value: "时间") { CellWidth = 15, HAlignmentEnum = HAlignmentEnum.CENTER, VAlignmentEnum = VAlignmentEnum.CENTER }
}
};
slist.Add(header);
try
{
RB_Member_CoffeeLog_Extend demodel = JsonHelper.DeserializeObject<RB_Member_CoffeeLog_Extend>(base.RequestParm.msg.ToString());
demodel.MallBaseId = RequestParm.MallBaseId;
//不能超过2月时间
if ((Convert.ToDateTime(demodel.EndTime) - Convert.ToDateTime(demodel.StartTime)).Days > 62) {
var byteData1 = ExcelTempLateHelper.ToExcelExtend(slist);
return File(byteData1, "application/octet-stream", ExcelName);
}
var list = coffeeModule.GetCoffeeCouponsPageList(1, 9999, out long count, demodel);
foreach (var item in list) {
ExcelDataSource datarow = new ExcelDataSource()
{
ExcelRows = new List<ExcelColumn>(30) {
new ExcelColumn(value: item.UserName){ },
new ExcelColumn(value: item.UserIcon){ },
new ExcelColumn(value: item.Type ==1?"存入":"消费"){ },
new ExcelColumn(value: item.BuyType ==1?"赠送":item.BuyType==2?"购买":"-"){ },
new ExcelColumn(value: item.EmpType==1?"员工":item.EmpType==2?"学员":"来宾"){ },
new ExcelColumn(value: item.EmpStuName){ },
new ExcelColumn(value: item.Number.ToString()){ },
new ExcelColumn(value: item.Remark){ },
new ExcelColumn(value: item.EmpName){ },
new ExcelColumn(value: item.CreateDate.ToString("yyyy-MM-dd HH:mm")){ },
},
ColumnHight = 30
};
slist.Add(datarow);
}
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);
}
}
}
}
\ No newline at end of file
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