|
@@ -10,7 +10,7 @@ import ( |
|
@@ -10,7 +10,7 @@ import ( |
|
10
|
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/suMoney/command"
|
10
|
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/suMoney/command"
|
|
11
|
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/suMoney/query"
|
11
|
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/suMoney/query"
|
|
12
|
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/suMoney/service"
|
12
|
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/suMoney/service"
|
|
13
|
- utils_tool "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/utils"
|
13
|
+ //utility "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/utils"
|
|
14
|
"os"
|
14
|
"os"
|
|
15
|
"path"
|
15
|
"path"
|
|
16
|
"strconv"
|
16
|
"strconv"
|
|
@@ -437,7 +437,7 @@ func (controller *SuMoneyController) ImportExchangeList () { |
|
@@ -437,7 +437,7 @@ func (controller *SuMoneyController) ImportExchangeList () { |
|
437
|
|
437
|
|
|
438
|
// 文件行数校验
|
438
|
// 文件行数校验
|
|
439
|
rows, _ := xlsx.GetRows("Sheet1")
|
439
|
rows, _ := xlsx.GetRows("Sheet1")
|
|
440
|
- fmt.Print(len(rows), "\n")
|
440
|
+ //fmt.Print(len(rows), "\n")
|
|
441
|
if len(rows) > 302 {
|
441
|
if len(rows) > 302 {
|
|
442
|
err := &application.ServiceError{
|
442
|
err := &application.ServiceError{
|
|
443
|
Code: 500,
|
443
|
Code: 500,
|
|
@@ -461,36 +461,32 @@ func (controller *SuMoneyController) ImportExchangeList () { |
|
@@ -461,36 +461,32 @@ func (controller *SuMoneyController) ImportExchangeList () { |
|
461
|
return
|
461
|
return
|
|
462
|
}
|
462
|
}
|
|
463
|
|
463
|
|
|
464
|
- // 单元格校验
|
|
|
|
465
|
- newstr := []string{"null"}
|
|
|
|
466
|
- //nullChar := []string{"单元格包含空字符"}
|
464
|
+ // 必填项校验
|
|
467
|
nullLine := make([]interface{}, 0)
|
465
|
nullLine := make([]interface{}, 0)
|
|
|
|
466
|
+ nullFlag := false
|
|
468
|
for i, row := range rows {
|
467
|
for i, row := range rows {
|
|
469
|
if i > 2 {
|
468
|
if i > 2 {
|
|
470
|
fmt.Print(len(row), "\n")
|
469
|
fmt.Print(len(row), "\n")
|
|
471
|
-
|
|
|
|
472
|
- // 头部、中间空
|
|
|
|
473
|
if len(row) == 3 {
|
470
|
if len(row) == 3 {
|
|
|
|
471
|
+ var myRow []string = row
|
|
474
|
for j, cell := range row {
|
472
|
for j, cell := range row {
|
|
475
|
- fmt.Print(cell, "\n")
|
|
|
|
476
|
- if cell == "" {
|
|
|
|
477
|
- utils_tool.InsertSlice(j, newstr, row)
|
|
|
|
478
|
- row = append(row, "单元格包含空字符")
|
|
|
|
479
|
- nullLine = append(nullLine, row)
|
473
|
+ if cell == "" || cell == " " {
|
|
|
|
474
|
+ myRow[j] = ""
|
|
|
|
475
|
+ nullFlag = true
|
|
480
|
}
|
476
|
}
|
|
481
|
}
|
477
|
}
|
|
482
|
- }
|
|
|
|
483
|
-
|
|
|
|
484
|
- // 尾空
|
|
|
|
485
|
- if len(row) < 3 {
|
|
|
|
486
|
- for j, cell := range row {
|
|
|
|
487
|
- fmt.Print(cell, "\n")
|
|
|
|
488
|
- if cell == "" {
|
|
|
|
489
|
- utils_tool.InsertSlice(j, row, newstr)
|
|
|
|
490
|
- row = append(row, "单元格包含空字符")
|
|
|
|
491
|
- nullLine = append(nullLine, row)
|
|
|
|
492
|
- }
|
478
|
+ if nullFlag {
|
|
|
|
479
|
+ myRow = append(myRow, "必填项不能为空")
|
|
|
|
480
|
+ nullLine = append(nullLine, myRow)
|
|
|
|
481
|
+ nullFlag = false
|
|
493
|
}
|
482
|
}
|
|
|
|
483
|
+ } else if len(row) < 3 {
|
|
|
|
484
|
+ var myRow []string = row
|
|
|
|
485
|
+ for i := 0; i < 3 - len(row); i++ {
|
|
|
|
486
|
+ myRow = append(myRow, "")
|
|
|
|
487
|
+ }
|
|
|
|
488
|
+ myRow = append(myRow, "必填项不能为空")
|
|
|
|
489
|
+ nullLine = append(nullLine, myRow)
|
|
494
|
}
|
490
|
}
|
|
495
|
}
|
491
|
}
|
|
496
|
}
|
492
|
}
|
|
@@ -518,20 +514,41 @@ func (controller *SuMoneyController) ImportExchangeList () { |
|
@@ -518,20 +514,41 @@ func (controller *SuMoneyController) ImportExchangeList () { |
|
518
|
// 导入命令
|
514
|
// 导入命令
|
|
519
|
var createExchangeCashPersonCommands []*command.CreateExchangeCashPersonCommand
|
515
|
var createExchangeCashPersonCommands []*command.CreateExchangeCashPersonCommand
|
|
520
|
|
516
|
|
|
|
|
517
|
+ errorLine := make([]interface{}, 0)
|
|
521
|
for i, row := range rows {
|
518
|
for i, row := range rows {
|
|
522
|
if i > 2 && len(row) > 1 {
|
519
|
if i > 2 && len(row) > 1 {
|
|
523
|
// 创建兑换清单命令
|
520
|
// 创建兑换清单命令
|
|
524
|
createExchangeCashPersonCommand := &command.CreateExchangeCashPersonCommand{}
|
521
|
createExchangeCashPersonCommand := &command.CreateExchangeCashPersonCommand{}
|
|
525
|
- createExchangeCashPersonCommand.ExchangeCashActivityId, _ = strconv.ParseInt(jsonMap["activityId"].(string), 10, 64 )
|
522
|
+ createExchangeCashPersonCommand.ExchangeCashActivityId, err = strconv.ParseInt(jsonMap["activityId"].(string), 10, 64 )
|
|
526
|
createExchangeCashPersonCommand.Operator = int64(jsonMap["uid"].(float64))
|
523
|
createExchangeCashPersonCommand.Operator = int64(jsonMap["uid"].(float64))
|
|
527
|
createExchangeCashPersonCommand.PersonName = row[0]
|
524
|
createExchangeCashPersonCommand.PersonName = row[0]
|
|
528
|
createExchangeCashPersonCommand.PersonAccount = row[1]
|
525
|
createExchangeCashPersonCommand.PersonAccount = row[1]
|
|
529
|
- r2, _ := strconv.ParseFloat(row[2], 64)
|
526
|
+ r2, err := strconv.ParseFloat(row[2], 64)
|
|
|
|
527
|
+ if err != nil { // 已兑换素币格式不正确
|
|
|
|
528
|
+ var myRow []string = row
|
|
|
|
529
|
+ myRow = append(myRow, "已兑换素币格式不正确")
|
|
|
|
530
|
+ errorLine = append(errorLine, myRow)
|
|
|
|
531
|
+ continue
|
|
|
|
532
|
+ }
|
|
530
|
createExchangeCashPersonCommand.ExchangedSuMoney = r2
|
533
|
createExchangeCashPersonCommand.ExchangedSuMoney = r2
|
|
531
|
createExchangeCashPersonCommands = append(createExchangeCashPersonCommands, createExchangeCashPersonCommand)
|
534
|
createExchangeCashPersonCommands = append(createExchangeCashPersonCommands, createExchangeCashPersonCommand)
|
|
532
|
}
|
535
|
}
|
|
533
|
}
|
536
|
}
|
|
534
|
|
537
|
|
|
|
|
538
|
+ if len(errorLine) > 0 {
|
|
|
|
539
|
+ ret = map[string]interface{}{
|
|
|
|
540
|
+ "successCount": 0,
|
|
|
|
541
|
+ "fail": map[string]interface{}{
|
|
|
|
542
|
+ "tableHeader": tableHeader,
|
|
|
|
543
|
+ "tableData": errorLine,
|
|
|
|
544
|
+ },
|
|
|
|
545
|
+ }
|
|
|
|
546
|
+ response = utils.ResponseData(controller.Ctx, ret)
|
|
|
|
547
|
+ controller.Data["json"] = response
|
|
|
|
548
|
+ controller.ServeJSON()
|
|
|
|
549
|
+ return
|
|
|
|
550
|
+ }
|
|
|
|
551
|
+
|
|
535
|
// 创建兑换素币清单
|
552
|
// 创建兑换素币清单
|
|
536
|
failureDataList, err = cashPoolService.ImportCreateExchangeCashPerson(createExchangeCashPersonCommands, failureDataList)
|
553
|
failureDataList, err = cashPoolService.ImportCreateExchangeCashPerson(createExchangeCashPersonCommands, failureDataList)
|
|
537
|
if err != nil { // 导入失败处理
|
554
|
if err != nil { // 导入失败处理
|