作者 陈志颖

feat:完善素币兑换清单导入

... ... @@ -1450,10 +1450,11 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
cashIncrement := suMoneyIncrement * activityFound.Rate
// 更新兑换素币清单命令
updateExchangeCashPersonCommand := command.UpdateExchangeCashPersonCommand{
updateExchangeCashPersonCommand := &command.UpdateExchangeCashPersonCommand{
ListId: peopleFound[0].ListId,
ExchangedSuMoney: personFoundExchangedSuMoney + suMoneyIncrement,
ExchangedCash: (personFoundExchangedSuMoney + suMoneyIncrement) * activityFound.Rate,
ExchangedCash: (personFoundExchangedSuMoney + suMoneyIncrement) * activityFound.Rate,
Operator: createExchangeCashPersonCommand.Operator,
}
// 更新兑换素币清单
... ...
... ... @@ -438,52 +438,52 @@ func (controller *SuMoneyController) ImportExchangeList () {
return
}
// 空行记录
//nullLine := make([]interface{}, 0)
//空行记录
nullLine := make([]interface{}, 0)
// 单元格非空校验
//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
//}
//
//// 新增失败记录
for i, row := range rows {
if i > 2 {
if len(row) != 3 {
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)
// 新增成功计数
var successDataCount int64
fmt.Print(len(rows), "\n")
for i, row := range rows {
if i > 2 {
for _, _ = range row {
r2, _ := strconv.ParseFloat(row[2], 64)
createExchangeCashPersonCommand.ExchangeCashActivityId = activityId
createExchangeCashPersonCommand.Operator = operator
createExchangeCashPersonCommand.PersonName = row[0]
createExchangeCashPersonCommand.PersonAccount = row[1]
createExchangeCashPersonCommand.ExchangedSuMoney = r2
}
fmt.Printf("Row Number:%d, Row: %+v\n, Row Length: %d\n", i, row, len(row))
if i > 2 && len(row) > 1 {
// 创建兑换清单命令
createExchangeCashPersonCommand.ExchangeCashActivityId = activityId
createExchangeCashPersonCommand.Operator = operator
createExchangeCashPersonCommand.PersonName = row[0]
createExchangeCashPersonCommand.PersonAccount = row[1]
r2, _ := strconv.ParseFloat(row[2], 64)
createExchangeCashPersonCommand.ExchangedSuMoney = r2
// 创建兑换素币清单
_, err := cashPoolService.ImportCreateExchangeCashPerson(createExchangeCashPersonCommand)
if err != nil { // 导入失败处理
... ... @@ -503,6 +503,13 @@ func (controller *SuMoneyController) ImportExchangeList () {
},
}
if successDataCount == int64(len(rows) - 3) {
ret = map[string]interface{}{
"successCount": successDataCount,
"fail": nil,
}
}
response = utils.ResponseData(controller.Ctx, ret)
controller.Data["json"] = response
controller.ServeJSON()
... ...