...
|
...
|
@@ -399,7 +399,71 @@ func (controller *SuMoneyController) ListDeadline() { |
|
|
|
|
|
// TODO 导出素币兑换清单,选择导出(ids),增加导出失败信息
|
|
|
func (controller *SuMoneyController) ExportExchangeList() {
|
|
|
|
|
|
cashPoolService := service.NewCashPoolService(nil)
|
|
|
exportExchangeCashListCommand := &command.ExportExchangeCashListCommand{}
|
|
|
json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), exportExchangeCashListCommand)
|
|
|
fmt.Print(exportExchangeCashListCommand, "\n")
|
|
|
// 列标题
|
|
|
titles := []string{
|
|
|
"姓名","手机账号","已兑换现金","已兑换素币",
|
|
|
}
|
|
|
// 列单元
|
|
|
cells := []string{
|
|
|
"A","B","C","D",
|
|
|
}
|
|
|
// 数据源
|
|
|
var data []map[string]interface{}
|
|
|
people, err := cashPoolService.ListExchangeCashPersonById(exportExchangeCashListCommand)
|
|
|
for _, person := range people {
|
|
|
p := map[string]interface{} {
|
|
|
"name": person.EmployeeInfo.EmployeeName,
|
|
|
"account": person.EmployeeInfo.EmployeeAccount,
|
|
|
"exchanged_cash": person.ExchangedCash,
|
|
|
"exchanged_su_money": person.ExchangedSuMoney,
|
|
|
}
|
|
|
data = append(data, p)
|
|
|
}
|
|
|
fmt.Print(data, "\n")
|
|
|
var response utils.JsonResponse
|
|
|
if err != nil {
|
|
|
response = utils.ResponseError(controller.Ctx, err)
|
|
|
controller.Data["json"] = response
|
|
|
controller.ServeJSON()
|
|
|
} else {
|
|
|
// 新建文件
|
|
|
f := excelize.NewFile()
|
|
|
// 新建工作簿
|
|
|
index := f.NewSheet("Sheet1")
|
|
|
//列标题赋值
|
|
|
for column, v := range titles {
|
|
|
f.SetCellValue("Sheet1", cells[column]+"1", v)
|
|
|
}
|
|
|
for lineNum, v := range data { //行数 lineNum 行内容 v
|
|
|
columnNum := 0 //列数
|
|
|
for _, vv := range v {
|
|
|
sheetPosition := cells[columnNum] + strconv.Itoa(lineNum+2)
|
|
|
switch vv.(type) {
|
|
|
case string:
|
|
|
f.SetCellValue("Sheet1", sheetPosition, vv.(string))
|
|
|
break
|
|
|
case int:
|
|
|
f.SetCellValue("Sheet1", sheetPosition, vv.(int))
|
|
|
break
|
|
|
case float64:
|
|
|
f.SetCellValue("Sheet1", sheetPosition, vv.(float64))
|
|
|
break
|
|
|
}
|
|
|
columnNum++
|
|
|
}
|
|
|
}
|
|
|
f.SetActiveSheet(index)
|
|
|
//保存为文件
|
|
|
f.Path="public/file/素币兑换清单.xlsx"
|
|
|
if err := f.Save(); err != nil {
|
|
|
fmt.Println(err)
|
|
|
}
|
|
|
controller.Ctx.Output.Download(f.Path,"素币兑换清单.xlsx")
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// TODO 导出素币流水记录,选择导出(ids),增加导出失败信息
|
...
|
...
|
|