|
@@ -341,7 +341,7 @@ func (controller *SuMoneyController) ImportExchangeList () { |
|
@@ -341,7 +341,7 @@ func (controller *SuMoneyController) ImportExchangeList () { |
|
341
|
fmt.Println(err)
|
341
|
fmt.Println(err)
|
|
342
|
return
|
342
|
return
|
|
343
|
}
|
343
|
}
|
|
344
|
- // TODO 增加导入失败原因返回
|
344
|
+ // TODO 增加非空校验,导入失败原因返回
|
|
345
|
var response utils.JsonResponse
|
345
|
var response utils.JsonResponse
|
|
346
|
dataList := make([]interface{}, 0)
|
346
|
dataList := make([]interface{}, 0)
|
|
347
|
rows, _ := xlsx.GetRows("Sheet1")
|
347
|
rows, _ := xlsx.GetRows("Sheet1")
|
|
@@ -353,9 +353,9 @@ func (controller *SuMoneyController) ImportExchangeList () { |
|
@@ -353,9 +353,9 @@ func (controller *SuMoneyController) ImportExchangeList () { |
|
353
|
if i > 2 {
|
353
|
if i > 2 {
|
|
354
|
for _, _ = range row {
|
354
|
for _, _ = range row {
|
|
355
|
createExchangeCashPersonCommand.ExchangeCashActivityId = activityId
|
355
|
createExchangeCashPersonCommand.ExchangeCashActivityId = activityId
|
|
356
|
- // TODO 非空校验
|
|
|
|
357
|
- if row[0] == "" || createExchangeCashPersonCommand.PersonAccount == "" || createExchangeCashPersonCommand.ExchangedSuMoney == 0{
|
|
|
|
358
|
- controller.Ctx.WriteString( "空字段" )
|
356
|
+ r2, _ := strconv.ParseFloat(row[2], 64)
|
|
|
|
357
|
+ if row[0] == "" || row[1] == "" || r2 == 0 {
|
|
|
|
358
|
+ controller.Ctx.WriteString("单元格包含空字段")
|
|
359
|
return
|
359
|
return
|
|
360
|
}
|
360
|
}
|
|
361
|
createExchangeCashPersonCommand.Operator = operator
|
361
|
createExchangeCashPersonCommand.Operator = operator
|
|
@@ -402,7 +402,6 @@ func (controller *SuMoneyController) ExportExchangeList() { |
|
@@ -402,7 +402,6 @@ func (controller *SuMoneyController) ExportExchangeList() { |
|
402
|
cashPoolService := service.NewCashPoolService(nil)
|
402
|
cashPoolService := service.NewCashPoolService(nil)
|
|
403
|
exportExchangeCashListCommand := &command.ExportExchangeCashListCommand{}
|
403
|
exportExchangeCashListCommand := &command.ExportExchangeCashListCommand{}
|
|
404
|
json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), exportExchangeCashListCommand)
|
404
|
json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), exportExchangeCashListCommand)
|
|
405
|
- fmt.Print(exportExchangeCashListCommand, "\n")
|
|
|
|
406
|
// 列标题
|
405
|
// 列标题
|
|
407
|
titles := []string{
|
406
|
titles := []string{
|
|
408
|
"姓名","手机账号","已兑换现金","已兑换素币",
|
407
|
"姓名","手机账号","已兑换现金","已兑换素币",
|
|
@@ -423,7 +422,6 @@ func (controller *SuMoneyController) ExportExchangeList() { |
|
@@ -423,7 +422,6 @@ func (controller *SuMoneyController) ExportExchangeList() { |
|
423
|
}
|
422
|
}
|
|
424
|
data = append(data, p)
|
423
|
data = append(data, p)
|
|
425
|
}
|
424
|
}
|
|
426
|
- fmt.Print(data, "\n")
|
|
|
|
427
|
var response utils.JsonResponse
|
425
|
var response utils.JsonResponse
|
|
428
|
if err != nil {
|
426
|
if err != nil {
|
|
429
|
response = utils.ResponseError(controller.Ctx, err)
|
427
|
response = utils.ResponseError(controller.Ctx, err)
|
|
@@ -457,21 +455,17 @@ func (controller *SuMoneyController) ExportExchangeList() { |
|
@@ -457,21 +455,17 @@ func (controller *SuMoneyController) ExportExchangeList() { |
|
457
|
}
|
455
|
}
|
|
458
|
}
|
456
|
}
|
|
459
|
f.SetActiveSheet(index)
|
457
|
f.SetActiveSheet(index)
|
|
460
|
-
|
|
|
|
461
|
// 创建下载文件夹
|
458
|
// 创建下载文件夹
|
|
462
|
mkErr :=os.Mkdir("download", os.ModePerm)
|
459
|
mkErr :=os.Mkdir("download", os.ModePerm)
|
|
463
|
if err!=nil{
|
460
|
if err!=nil{
|
|
464
|
fmt.Println(mkErr)
|
461
|
fmt.Println(mkErr)
|
|
465
|
}
|
462
|
}
|
|
466
|
-
|
|
|
|
467
|
//保存为文件
|
463
|
//保存为文件
|
|
468
|
f.Path="download/素币兑换清单.xlsx"
|
464
|
f.Path="download/素币兑换清单.xlsx"
|
|
469
|
if err := f.Save(); err != nil {
|
465
|
if err := f.Save(); err != nil {
|
|
470
|
fmt.Println(err)
|
466
|
fmt.Println(err)
|
|
471
|
}
|
467
|
}
|
|
472
|
-
|
|
|
|
473
|
controller.Ctx.Output.Download(f.Path,"素币兑换清单.xlsx")
|
468
|
controller.Ctx.Output.Download(f.Path,"素币兑换清单.xlsx")
|
|
474
|
-
|
|
|
|
475
|
// 下载完成删除文件
|
469
|
// 下载完成删除文件
|
|
476
|
removeErr := os.Remove(f.Path)
|
470
|
removeErr := os.Remove(f.Path)
|
|
477
|
if err != nil {
|
471
|
if err != nil {
|