|
@@ -438,52 +438,52 @@ func (controller *SuMoneyController) ImportExchangeList () { |
|
@@ -438,52 +438,52 @@ func (controller *SuMoneyController) ImportExchangeList () { |
438
|
return
|
438
|
return
|
439
|
}
|
439
|
}
|
440
|
|
440
|
|
441
|
- // 空行记录
|
|
|
442
|
- //nullLine := make([]interface{}, 0)
|
441
|
+ //空行记录
|
|
|
442
|
+ nullLine := make([]interface{}, 0)
|
443
|
|
443
|
|
444
|
// 单元格非空校验
|
444
|
// 单元格非空校验
|
445
|
- //for i, row := range rows {
|
|
|
446
|
- // if i > 2 {
|
|
|
447
|
- // for _, _ = range row {
|
|
|
448
|
- // if len(row) != 3 {
|
|
|
449
|
- // row = append(row, "null")
|
|
|
450
|
- // row = append(row, "单元格包含空字符")
|
|
|
451
|
- // nullLine = append(nullLine, row)
|
|
|
452
|
- // }
|
|
|
453
|
- // }
|
|
|
454
|
- // }
|
|
|
455
|
- //}
|
|
|
456
|
- //
|
|
|
457
|
- //if len(nullLine) > 0 {
|
|
|
458
|
- // ret = map[string]interface{}{
|
|
|
459
|
- // "successCount": 0,
|
|
|
460
|
- // "fail": map[string]interface{}{
|
|
|
461
|
- // "tableHeader": tableHeader,
|
|
|
462
|
- // "tableData": nullLine,
|
|
|
463
|
- // },
|
|
|
464
|
- // }
|
|
|
465
|
- // response = utils.ResponseData(controller.Ctx, ret)
|
|
|
466
|
- // controller.Data["json"] = response
|
|
|
467
|
- // controller.ServeJSON()
|
|
|
468
|
- // return
|
|
|
469
|
- //}
|
|
|
470
|
- //
|
|
|
471
|
- //// 新增失败记录
|
445
|
+ for i, row := range rows {
|
|
|
446
|
+ if i > 2 {
|
|
|
447
|
+ if len(row) != 3 {
|
|
|
448
|
+ row = append(row, "单元格包含空字符")
|
|
|
449
|
+ nullLine = append(nullLine, row)
|
|
|
450
|
+ }
|
|
|
451
|
+ }
|
|
|
452
|
+ }
|
|
|
453
|
+
|
|
|
454
|
+ if len(nullLine) > 0 {
|
|
|
455
|
+ ret = map[string]interface{}{
|
|
|
456
|
+ "successCount": 0,
|
|
|
457
|
+ "fail": map[string]interface{}{
|
|
|
458
|
+ "tableHeader": tableHeader,
|
|
|
459
|
+ "tableData": nullLine,
|
|
|
460
|
+ },
|
|
|
461
|
+ }
|
|
|
462
|
+ response = utils.ResponseData(controller.Ctx, ret)
|
|
|
463
|
+ controller.Data["json"] = response
|
|
|
464
|
+ controller.ServeJSON()
|
|
|
465
|
+ return
|
|
|
466
|
+ }
|
|
|
467
|
+
|
|
|
468
|
+ // 新增失败记录
|
472
|
failureDataList := make([]interface{}, 0)
|
469
|
failureDataList := make([]interface{}, 0)
|
473
|
|
470
|
|
474
|
// 新增成功计数
|
471
|
// 新增成功计数
|
475
|
var successDataCount int64
|
472
|
var successDataCount int64
|
476
|
|
473
|
|
|
|
474
|
+ fmt.Print(len(rows), "\n")
|
|
|
475
|
+
|
477
|
for i, row := range rows {
|
476
|
for i, row := range rows {
|
478
|
- if i > 2 {
|
|
|
479
|
- for _, _ = range row {
|
|
|
480
|
- r2, _ := strconv.ParseFloat(row[2], 64)
|
|
|
481
|
- createExchangeCashPersonCommand.ExchangeCashActivityId = activityId
|
|
|
482
|
- createExchangeCashPersonCommand.Operator = operator
|
|
|
483
|
- createExchangeCashPersonCommand.PersonName = row[0]
|
|
|
484
|
- createExchangeCashPersonCommand.PersonAccount = row[1]
|
|
|
485
|
- createExchangeCashPersonCommand.ExchangedSuMoney = r2
|
|
|
486
|
- }
|
477
|
+ fmt.Printf("Row Number:%d, Row: %+v\n, Row Length: %d\n", i, row, len(row))
|
|
|
478
|
+ if i > 2 && len(row) > 1 {
|
|
|
479
|
+ // 创建兑换清单命令
|
|
|
480
|
+ createExchangeCashPersonCommand.ExchangeCashActivityId = activityId
|
|
|
481
|
+ createExchangeCashPersonCommand.Operator = operator
|
|
|
482
|
+ createExchangeCashPersonCommand.PersonName = row[0]
|
|
|
483
|
+ createExchangeCashPersonCommand.PersonAccount = row[1]
|
|
|
484
|
+ r2, _ := strconv.ParseFloat(row[2], 64)
|
|
|
485
|
+ createExchangeCashPersonCommand.ExchangedSuMoney = r2
|
|
|
486
|
+
|
487
|
// 创建兑换素币清单
|
487
|
// 创建兑换素币清单
|
488
|
_, err := cashPoolService.ImportCreateExchangeCashPerson(createExchangeCashPersonCommand)
|
488
|
_, err := cashPoolService.ImportCreateExchangeCashPerson(createExchangeCashPersonCommand)
|
489
|
if err != nil { // 导入失败处理
|
489
|
if err != nil { // 导入失败处理
|
|
@@ -503,6 +503,13 @@ func (controller *SuMoneyController) ImportExchangeList () { |
|
@@ -503,6 +503,13 @@ func (controller *SuMoneyController) ImportExchangeList () { |
503
|
},
|
503
|
},
|
504
|
}
|
504
|
}
|
505
|
|
505
|
|
|
|
506
|
+ if successDataCount == int64(len(rows) - 3) {
|
|
|
507
|
+ ret = map[string]interface{}{
|
|
|
508
|
+ "successCount": successDataCount,
|
|
|
509
|
+ "fail": nil,
|
|
|
510
|
+ }
|
|
|
511
|
+ }
|
|
|
512
|
+
|
506
|
response = utils.ResponseData(controller.Ctx, ret)
|
513
|
response = utils.ResponseData(controller.Ctx, ret)
|
507
|
controller.Data["json"] = response
|
514
|
controller.Data["json"] = response
|
508
|
controller.ServeJSON()
|
515
|
controller.ServeJSON()
|