...
|
...
|
@@ -10,7 +10,7 @@ import ( |
|
|
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/suMoney/command"
|
|
|
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/suMoney/query"
|
|
|
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/suMoney/service"
|
|
|
utils_tool "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/utils"
|
|
|
//utility "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/utils"
|
|
|
"os"
|
|
|
"path"
|
|
|
"strconv"
|
...
|
...
|
@@ -437,7 +437,7 @@ func (controller *SuMoneyController) ImportExchangeList () { |
|
|
|
|
|
// 文件行数校验
|
|
|
rows, _ := xlsx.GetRows("Sheet1")
|
|
|
fmt.Print(len(rows), "\n")
|
|
|
//fmt.Print(len(rows), "\n")
|
|
|
if len(rows) > 302 {
|
|
|
err := &application.ServiceError{
|
|
|
Code: 500,
|
...
|
...
|
@@ -461,36 +461,32 @@ func (controller *SuMoneyController) ImportExchangeList () { |
|
|
return
|
|
|
}
|
|
|
|
|
|
// 单元格校验
|
|
|
newstr := []string{"null"}
|
|
|
//nullChar := []string{"单元格包含空字符"}
|
|
|
// 必填项校验
|
|
|
nullLine := make([]interface{}, 0)
|
|
|
nullFlag := false
|
|
|
for i, row := range rows {
|
|
|
if i > 2 {
|
|
|
fmt.Print(len(row), "\n")
|
|
|
|
|
|
// 头部、中间空
|
|
|
if len(row) == 3 {
|
|
|
var myRow []string = row
|
|
|
for j, cell := range row {
|
|
|
fmt.Print(cell, "\n")
|
|
|
if cell == "" {
|
|
|
utils_tool.InsertSlice(j, newstr, row)
|
|
|
row = append(row, "单元格包含空字符")
|
|
|
nullLine = append(nullLine, row)
|
|
|
if cell == "" || cell == " " {
|
|
|
myRow[j] = ""
|
|
|
nullFlag = true
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 尾空
|
|
|
if len(row) < 3 {
|
|
|
for j, cell := range row {
|
|
|
fmt.Print(cell, "\n")
|
|
|
if cell == "" {
|
|
|
utils_tool.InsertSlice(j, row, newstr)
|
|
|
row = append(row, "单元格包含空字符")
|
|
|
nullLine = append(nullLine, row)
|
|
|
}
|
|
|
if nullFlag {
|
|
|
myRow = append(myRow, "必填项不能为空")
|
|
|
nullLine = append(nullLine, myRow)
|
|
|
nullFlag = false
|
|
|
}
|
|
|
} else if len(row) < 3 {
|
|
|
var myRow []string = row
|
|
|
for i := 0; i < 3 - len(row); i++ {
|
|
|
myRow = append(myRow, "")
|
|
|
}
|
|
|
myRow = append(myRow, "必填项不能为空")
|
|
|
nullLine = append(nullLine, myRow)
|
|
|
}
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -518,20 +514,41 @@ func (controller *SuMoneyController) ImportExchangeList () { |
|
|
// 导入命令
|
|
|
var createExchangeCashPersonCommands []*command.CreateExchangeCashPersonCommand
|
|
|
|
|
|
errorLine := make([]interface{}, 0)
|
|
|
for i, row := range rows {
|
|
|
if i > 2 && len(row) > 1 {
|
|
|
// 创建兑换清单命令
|
|
|
createExchangeCashPersonCommand := &command.CreateExchangeCashPersonCommand{}
|
|
|
createExchangeCashPersonCommand.ExchangeCashActivityId, _ = strconv.ParseInt(jsonMap["activityId"].(string), 10, 64 )
|
|
|
createExchangeCashPersonCommand.ExchangeCashActivityId, err = strconv.ParseInt(jsonMap["activityId"].(string), 10, 64 )
|
|
|
createExchangeCashPersonCommand.Operator = int64(jsonMap["uid"].(float64))
|
|
|
createExchangeCashPersonCommand.PersonName = row[0]
|
|
|
createExchangeCashPersonCommand.PersonAccount = row[1]
|
|
|
r2, _ := strconv.ParseFloat(row[2], 64)
|
|
|
r2, err := strconv.ParseFloat(row[2], 64)
|
|
|
if err != nil { // 已兑换素币格式不正确
|
|
|
var myRow []string = row
|
|
|
myRow = append(myRow, "已兑换素币格式不正确")
|
|
|
errorLine = append(errorLine, myRow)
|
|
|
continue
|
|
|
}
|
|
|
createExchangeCashPersonCommand.ExchangedSuMoney = r2
|
|
|
createExchangeCashPersonCommands = append(createExchangeCashPersonCommands, createExchangeCashPersonCommand)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if len(errorLine) > 0 {
|
|
|
ret = map[string]interface{}{
|
|
|
"successCount": 0,
|
|
|
"fail": map[string]interface{}{
|
|
|
"tableHeader": tableHeader,
|
|
|
"tableData": errorLine,
|
|
|
},
|
|
|
}
|
|
|
response = utils.ResponseData(controller.Ctx, ret)
|
|
|
controller.Data["json"] = response
|
|
|
controller.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// 创建兑换素币清单
|
|
|
failureDataList, err = cashPoolService.ImportCreateExchangeCashPerson(createExchangeCashPersonCommands, failureDataList)
|
|
|
if err != nil { // 导入失败处理
|
...
|
...
|
|