...
|
...
|
@@ -418,6 +418,7 @@ func (controller *SuMoneyController) ImportExchangeList () { |
|
|
response = utils.ResponseError(controller.Ctx, err)
|
|
|
controller.Data["json"] = response
|
|
|
controller.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
|
|
|
xlsx, err := excelize.OpenReader(file)
|
...
|
...
|
@@ -428,43 +429,46 @@ func (controller *SuMoneyController) ImportExchangeList () { |
|
|
|
|
|
// 文件行数校验
|
|
|
rows, _ := xlsx.GetRows("Sheet1")
|
|
|
|
|
|
if len(rows) > 302 {
|
|
|
err := fmt.Errorf("%s", "导入行数超过300行")
|
|
|
response = utils.ResponseError(controller.Ctx, err)
|
|
|
controller.Data["json"] = response
|
|
|
controller.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// 空行记录
|
|
|
nullLine := make([]interface{}, 0)
|
|
|
//nullLine := make([]interface{}, 0)
|
|
|
|
|
|
// 单元格非空校验
|
|
|
for i, row := range rows {
|
|
|
if i > 2 {
|
|
|
for _, _ = range row {
|
|
|
r2, _ := strconv.ParseFloat(row[2], 64)
|
|
|
if row[0] == "" || row[1] == "" || r2 == 0 {
|
|
|
//row = append(row, "单元格包含空字符")
|
|
|
//nullLine = append(nullLine, row)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if len(nullLine) > 0 {
|
|
|
ret = map[string]interface{}{
|
|
|
"successCount": 0,
|
|
|
"fail": map[string]interface{}{
|
|
|
"tableHeader": tableHeader,
|
|
|
"tableData": nullLine,
|
|
|
},
|
|
|
}
|
|
|
response = utils.ResponseData(controller.Ctx, ret)
|
|
|
controller.Data["json"] = response
|
|
|
controller.ServeJSON()
|
|
|
}
|
|
|
|
|
|
// 新增失败记录
|
|
|
//for i, row := range rows {
|
|
|
// if i > 2 {
|
|
|
// for _, _ = range row {
|
|
|
// if len(row) != 3 {
|
|
|
// row = append(row, "null")
|
|
|
// row = append(row, "单元格包含空字符")
|
|
|
// nullLine = append(nullLine, row)
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
//}
|
|
|
//
|
|
|
//if len(nullLine) > 0 {
|
|
|
// ret = map[string]interface{}{
|
|
|
// "successCount": 0,
|
|
|
// "fail": map[string]interface{}{
|
|
|
// "tableHeader": tableHeader,
|
|
|
// "tableData": nullLine,
|
|
|
// },
|
|
|
// }
|
|
|
// response = utils.ResponseData(controller.Ctx, ret)
|
|
|
// controller.Data["json"] = response
|
|
|
// controller.ServeJSON()
|
|
|
// return
|
|
|
//}
|
|
|
//
|
|
|
//// 新增失败记录
|
|
|
failureDataList := make([]interface{}, 0)
|
|
|
|
|
|
// 新增成功计数
|
...
|
...
|
@@ -483,8 +487,8 @@ func (controller *SuMoneyController) ImportExchangeList () { |
|
|
// 创建兑换素币清单
|
|
|
_, err := cashPoolService.ImportCreateExchangeCashPerson(createExchangeCashPersonCommand)
|
|
|
if err != nil { // 导入失败处理
|
|
|
//rows[i] = append(rows[i], err.Error())
|
|
|
//failureDataList = append(failureDataList, rows[i]) // 导入失败的记录
|
|
|
rows[i] = append(rows[i], err.Error())
|
|
|
failureDataList = append(failureDataList, rows[i]) // 导入失败的记录
|
|
|
} else { // 导入成功处理
|
|
|
successDataCount += 1
|
|
|
}
|
...
|
...
|
@@ -502,6 +506,7 @@ func (controller *SuMoneyController) ImportExchangeList () { |
|
|
response = utils.ResponseData(controller.Ctx, ret)
|
|
|
controller.Data["json"] = response
|
|
|
controller.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// 导出素币兑换清单,选择导出(ids),增加导出失败信息
|
...
|
...
|
|