作者 陈志颖

refactor:优化导入功能

@@ -548,3 +548,32 @@ @@ -548,3 +548,32 @@
548 BodyData: 548 BodyData:
549 2020/11/24 13:45:45.059 [D] [server.go:2843] <====Send RequestId:POST./cash-pool/activity/exchange-list/import.1606196744625039000 BodyData:{"code":0,"data":{"fail":null,"successCount":1},"msg":"ok"} 549 2020/11/24 13:45:45.059 [D] [server.go:2843] <====Send RequestId:POST./cash-pool/activity/exchange-list/import.1606196744625039000 BodyData:{"code":0,"data":{"fail":null,"successCount":1},"msg":"ok"}
550 2020/11/24 13:45:45.059 [D] [server.go:1925] | 127.0.0.1| 200 | 437.704111ms| match| POST  /cash-pool/activity/exchange-list/import r:/cash-pool/activity/exchange-list/import 550 2020/11/24 13:45:45.059 [D] [server.go:1925] | 127.0.0.1| 200 | 437.704111ms| match| POST  /cash-pool/activity/exchange-list/import r:/cash-pool/activity/exchange-list/import
  551 +2020/11/24 15:51:18.546 [I] [???:0] http server Running on http://:8082
  552 +2020/11/24 15:51:26.674 [D] [server.go:2843] ====>Recv User:<nil> RequestId:POST./cash-pool/activity/exchange-list/import.1606204286674056000
  553 + Auth=
  554 + BodyData:
  555 +2020/11/24 15:51:27.664 [D] [server.go:2843] <====Send RequestId:POST./cash-pool/activity/exchange-list/import.1606204286674056000 BodyData:{"code":0,"data":{"fail":null,"successCount":1},"msg":"ok"}
  556 +2020/11/24 15:51:27.664 [D] [server.go:1925] | 127.0.0.1| 200 | 990.726762ms| match| POST  /cash-pool/activity/exchange-list/import r:/cash-pool/activity/exchange-list/import
  557 +2020/11/24 15:52:10.472 [D] [server.go:2843] ====>Recv User:<nil> RequestId:POST./cash-pool/activity/exchange-list/import.1606204330472439000
  558 + Auth=
  559 + BodyData:
  560 +2020/11/24 15:52:10.488 [D] [server.go:2843] <====Send RequestId:POST./cash-pool/activity/exchange-list/import.1606204330472439000 BodyData:{"code":0,"data":{"fail":{"tableData":[["卞信华","18900000000","单元格包含空字符"]],"tableHeader":["员工姓名","手机号","已兑换素币","错误详情"]},"successCount":0},"msg":"ok"}
  561 +2020/11/24 15:52:10.488 [D] [server.go:1925] | 127.0.0.1| 200 | 16.812751ms| match| POST  /cash-pool/activity/exchange-list/import r:/cash-pool/activity/exchange-list/import
  562 +2020/11/24 15:56:05.844 [I] [???:0] http server Running on http://:8082
  563 +2020/11/24 15:57:07.287 [D] [server.go:2843] ====>Recv User:<nil> RequestId:POST./cash-pool/activity/exchange-list/import.1606204627287511000
  564 + Auth=
  565 + BodyData:
  566 +2020/11/24 15:57:07.586 [D] [server.go:2843] <====Send RequestId:POST./cash-pool/activity/exchange-list/import.1606204627287511000 BodyData:{"code":0,"data":{"fail":null,"successCount":2},"msg":"ok"}
  567 +2020/11/24 15:57:07.586 [D] [server.go:1925] | 127.0.0.1| 200 | 301.568812ms| match| POST  /cash-pool/activity/exchange-list/import r:/cash-pool/activity/exchange-list/import
  568 +2020/11/24 16:00:00.327 [D] [server.go:2843] ====>Recv User:<nil> RequestId:POST./cash-pool/activity/exchange-list/import.1606204800327448000
  569 + Auth=
  570 + BodyData:
  571 +2020/11/24 16:04:40.206 [D] [server.go:2843] <====Send RequestId:POST./cash-pool/activity/exchange-list/import.1606204800327448000 BodyData:{"code":0,"data":{"fail":null,"successCount":2},"msg":"ok"}
  572 +2020/11/24 16:04:40.206 [D] [server.go:1925] | 127.0.0.1| 200 |4m39.880470496s| match| POST  /cash-pool/activity/exchange-list/import r:/cash-pool/activity/exchange-list/import
  573 +2020/11/24 16:04:53.206 [I] [???:0] http server Running on http://:8082
  574 +2020/11/24 16:04:55.624 [D] [server.go:2843] ====>Recv User:<nil> RequestId:POST./cash-pool/activity/exchange-list/import.1606205095624342000
  575 + Auth=
  576 + BodyData:
  577 +2020/11/24 16:04:59.355 [D] [server.go:2843] <====Send RequestId:POST./cash-pool/activity/exchange-list/import.1606205095624342000 BodyData:{"code":0,"data":{"fail":{"tableData":[["hello","13162672794",2,{"Code":501,"Message":"内部服务出错:没有此员工"}]],"tableHeader":["员工姓名","手机号","已兑换素币","错误详情"]},"successCount":1},"msg":"ok"}
  578 +2020/11/24 16:04:59.355 [D] [server.go:1925] | 127.0.0.1| 200 | 3.731193052s| match| POST  /cash-pool/activity/exchange-list/import r:/cash-pool/activity/exchange-list/import
  579 +2020/11/24 16:21:47.937 [I] [???:0] http server Running on http://:8082
@@ -154,20 +154,6 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co @@ -154,20 +154,6 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co
154 } 154 }
155 } 155 }
156 156
157 - // 更新现金池  
158 - //newCashPool := &domain.CashPool{  
159 - // CashPoolId: cashPools[0].CashPoolId,  
160 - // CompanyId: createCashPoolCommand.CompanyId,  
161 - // Cash: createCashPoolCommand.Cash,  
162 - // ExchangedCash: cashPools[0].ExchangedCash,  
163 - // UnExchangeCash: cashPools[0].UnExchangeCash + (createCashPoolCommand.Cash - cashPools[0].Cash),  
164 - // ExchangedSuMoney: systemExchangedSuMoney,  
165 - // UnExchangeSuMoney: systemUnExchangeSuMoney,  
166 - // Rate: newRate,  
167 - // LastRate: lastActivityRate,  
168 - // CreateTime: time.Now().Local(),  
169 - //}  
170 -  
171 // 更新现金池命令 157 // 更新现金池命令
172 updateCashPoolCommand := &command.UpdateCashPoolCommand{ 158 updateCashPoolCommand := &command.UpdateCashPoolCommand{
173 CashPoolId: cashPools[0].CashPoolId, 159 CashPoolId: cashPools[0].CashPoolId,
@@ -1288,17 +1274,31 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC @@ -1288,17 +1274,31 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC
1288 } 1274 }
1289 1275
1290 // 导入新增兑换素币清单 1276 // 导入新增兑换素币清单
1291 -func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExchangeCashPersonCommand *command.CreateExchangeCashPersonCommand) (interface{}, error) { 1277 +func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExchangeCashPersonCommands []*command.CreateExchangeCashPersonCommand, failureDataList []interface{}) ([]interface{}, error) {
  1278 + // 批量校验
  1279 + for _, createExchangeCashPersonCommand := range createExchangeCashPersonCommands {
1292 if err := createExchangeCashPersonCommand.ValidateCommand(); err != nil { 1280 if err := createExchangeCashPersonCommand.ValidateCommand(); err != nil {
1293 - return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 1281 + row := []interface{}{
  1282 + createExchangeCashPersonCommand.PersonName,
  1283 + createExchangeCashPersonCommand.PersonAccount,
  1284 + createExchangeCashPersonCommand.ExchangedSuMoney,
  1285 + err.Error(),
  1286 + }
  1287 + failureDataList = append(failureDataList, row)
  1288 + continue
  1289 + }
  1290 + }
  1291 +
  1292 + if len(failureDataList) > 0 {
  1293 + return []interface{}{}, application.ThrowError(application.TRANSACTION_ERROR, "校验失败")
1294 } 1294 }
1295 1295
1296 transactionContext, err := factory.CreateTransactionContext(nil) 1296 transactionContext, err := factory.CreateTransactionContext(nil)
1297 if err != nil { 1297 if err != nil {
1298 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 1298 + return []interface{}{}, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
1299 } 1299 }
1300 if err := transactionContext.StartTransaction(); err != nil { 1300 if err := transactionContext.StartTransaction(); err != nil {
1301 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 1301 + return []interface{}{}, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
1302 } 1302 }
1303 defer func() { 1303 defer func() {
1304 transactionContext.RollbackTransaction() 1304 transactionContext.RollbackTransaction()
@@ -1309,7 +1309,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1309,7 +1309,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1309 if value, err := factory.CreateExchangeCashActivityRepository(map[string]interface{}{ 1309 if value, err := factory.CreateExchangeCashActivityRepository(map[string]interface{}{
1310 "transactionContext": transactionContext, 1310 "transactionContext": transactionContext,
1311 }); err != nil { 1311 }); err != nil {
1312 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1312 + return []interface{}{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
1313 } else { 1313 } else {
1314 exchangeCashActivityRepository = value 1314 exchangeCashActivityRepository = value
1315 } 1315 }
@@ -1319,7 +1319,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1319,7 +1319,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1319 if value, err := factory.CreateExchangeCashPersonListRepository(map[string]interface{}{ 1319 if value, err := factory.CreateExchangeCashPersonListRepository(map[string]interface{}{
1320 "transactionContext": transactionContext, 1320 "transactionContext": transactionContext,
1321 }); err != nil { 1321 }); err != nil {
1322 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1322 + return []interface{}{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
1323 } else { 1323 } else {
1324 exchangeCashPersonListRepository = value 1324 exchangeCashPersonListRepository = value
1325 } 1325 }
@@ -1329,7 +1329,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1329,7 +1329,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1329 if value, err := factory.CreateCashPoolRepository(map[string] interface{} { 1329 if value, err := factory.CreateCashPoolRepository(map[string] interface{} {
1330 "transactionContext": transactionContext, 1330 "transactionContext": transactionContext,
1331 }); err != nil { 1331 }); err != nil {
1332 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1332 + return []interface{}{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
1333 } else { 1333 } else {
1334 cashPoolRepository = value 1334 cashPoolRepository = value
1335 } 1335 }
@@ -1339,7 +1339,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1339,7 +1339,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1339 if value, err := factory.CreateEmployeeRepository(map[string]interface{}{ 1339 if value, err := factory.CreateEmployeeRepository(map[string]interface{}{
1340 "transactionContext": transactionContext, 1340 "transactionContext": transactionContext,
1341 }); err != nil { 1341 }); err != nil {
1342 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1342 + return []interface{}{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
1343 } else { 1343 } else {
1344 employeeRepository = value 1344 employeeRepository = value
1345 } 1345 }
@@ -1349,7 +1349,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1349,7 +1349,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1349 if value, err := factory.CreateEmployeeDao(map[string]interface{}{ 1349 if value, err := factory.CreateEmployeeDao(map[string]interface{}{
1350 "transactionContext": transactionContext, 1350 "transactionContext": transactionContext,
1351 }); err != nil { 1351 }); err != nil {
1352 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 1352 + return []interface{}{}, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
1353 } else { 1353 } else {
1354 employeeDao = value 1354 employeeDao = value
1355 } 1355 }
@@ -1359,18 +1359,34 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1359,18 +1359,34 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1359 if value, err := factory.CreateOperationSuMoneyService(map[string]interface{}{ 1359 if value, err := factory.CreateOperationSuMoneyService(map[string]interface{}{
1360 "transactionContext": transactionContext, 1360 "transactionContext": transactionContext,
1361 }); err != nil { 1361 }); err != nil {
1362 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1362 + return []interface{}{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
1363 } else { 1363 } else {
1364 operationSuMoneyService = value 1364 operationSuMoneyService = value
1365 } 1365 }
1366 1366
  1367 + // 循环添加
  1368 + for _, createExchangeCashPersonCommand := range createExchangeCashPersonCommands {
1367 // 获取当前兑换清单兑换活动 1369 // 获取当前兑换清单兑换活动
1368 activityFound, err := exchangeCashActivityRepository.FindOne(map[string]interface{}{"activityId": createExchangeCashPersonCommand.ExchangeCashActivityId}) 1370 activityFound, err := exchangeCashActivityRepository.FindOne(map[string]interface{}{"activityId": createExchangeCashPersonCommand.ExchangeCashActivityId})
1369 if err != nil { 1371 if err != nil {
1370 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1372 + row := []interface{}{
  1373 + createExchangeCashPersonCommand.PersonName,
  1374 + createExchangeCashPersonCommand.PersonAccount,
  1375 + createExchangeCashPersonCommand.ExchangedSuMoney,
  1376 + err.Error(),
  1377 + }
  1378 + failureDataList = append(failureDataList, row)
  1379 + continue
1371 } 1380 }
1372 if activityFound == nil { 1381 if activityFound == nil {
1373 - return nil, application.ThrowError(application.RES_NO_FIND_ERROR,"当前未创建任务兑换活动") 1382 + row := []interface{}{
  1383 + createExchangeCashPersonCommand.PersonName,
  1384 + createExchangeCashPersonCommand.PersonAccount,
  1385 + createExchangeCashPersonCommand.ExchangedSuMoney,
  1386 + "当前未创建任务兑换活动",
  1387 + }
  1388 + failureDataList = append(failureDataList, row)
  1389 + continue
1374 } 1390 }
1375 1391
1376 // 获取当前公司现金池 1392 // 获取当前公司现金池
@@ -1378,26 +1394,53 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1378,26 +1394,53 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1378 "companyId": activityFound.CompanyId, 1394 "companyId": activityFound.CompanyId,
1379 }) 1395 })
1380 if err != nil { 1396 if err != nil {
1381 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1397 + row := []interface{}{
  1398 + createExchangeCashPersonCommand.PersonName,
  1399 + createExchangeCashPersonCommand.PersonAccount,
  1400 + createExchangeCashPersonCommand.ExchangedSuMoney,
  1401 + err.Error(),
  1402 + }
  1403 + failureDataList = append(failureDataList, row)
  1404 + continue
1382 } 1405 }
1383 if len(cashPoolsFound) == 0 { 1406 if len(cashPoolsFound) == 0 {
1384 - return nil, application.ThrowError(application.RES_NO_FIND_ERROR, "当前现金池为空,请先投入现金") 1407 + row := []interface{}{
  1408 + createExchangeCashPersonCommand.PersonName,
  1409 + createExchangeCashPersonCommand.PersonAccount,
  1410 + createExchangeCashPersonCommand.ExchangedSuMoney,
  1411 + "当前现金池为空,请先投入现金",
  1412 + }
  1413 + failureDataList = append(failureDataList, row)
  1414 + continue
1385 } 1415 }
1386 1416
1387 // 获取员工查询条件 1417 // 获取员工查询条件
1388 getEmployee := map[string]interface{}{ 1418 getEmployee := map[string]interface{}{
1389 "account": createExchangeCashPersonCommand.PersonAccount, 1419 "account": createExchangeCashPersonCommand.PersonAccount,
1390 "companyId": activityFound.CompanyId, 1420 "companyId": activityFound.CompanyId,
1391 - "status": 1,  
1392 } 1421 }
1393 1422
1394 // 判断当前员工是否有效 1423 // 判断当前员工是否有效
1395 employeeFound, err := employeeRepository.FindOne(getEmployee) 1424 employeeFound, err := employeeRepository.FindOne(getEmployee)
1396 if err != nil { 1425 if err != nil {
1397 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1426 + row := []interface{}{
  1427 + createExchangeCashPersonCommand.PersonName,
  1428 + createExchangeCashPersonCommand.PersonAccount,
  1429 + createExchangeCashPersonCommand.ExchangedSuMoney,
  1430 + err.Error(),
  1431 + }
  1432 + failureDataList = append(failureDataList, row)
  1433 + continue
1398 } 1434 }
1399 if employeeFound == nil { 1435 if employeeFound == nil {
1400 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的员工") 1436 + row := []interface{}{
  1437 + createExchangeCashPersonCommand.PersonName,
  1438 + createExchangeCashPersonCommand.PersonAccount,
  1439 + createExchangeCashPersonCommand.ExchangedSuMoney,
  1440 + "无效的导入员工",
  1441 + }
  1442 + failureDataList = append(failureDataList, row)
  1443 + continue
1401 } 1444 }
1402 1445
1403 // 判断当前员工是否已经在素币兑换清单中 1446 // 判断当前员工是否已经在素币兑换清单中
@@ -1408,12 +1451,26 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1408,12 +1451,26 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1408 "limit": 1, 1451 "limit": 1,
1409 }) 1452 })
1410 if err != nil { 1453 if err != nil {
1411 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1454 + row := []interface{}{
  1455 + createExchangeCashPersonCommand.PersonName,
  1456 + createExchangeCashPersonCommand.PersonAccount,
  1457 + createExchangeCashPersonCommand.ExchangedSuMoney,
  1458 + err.Error(),
  1459 + }
  1460 + failureDataList = append(failureDataList, row)
  1461 + continue
1412 } 1462 }
1413 1463
1414 // 判断该员工兑换的素币是否超过本人持有的素币 1464 // 判断该员工兑换的素币是否超过本人持有的素币
1415 if employeeFound.SuMoney < createExchangeCashPersonCommand.ExchangedSuMoney { 1465 if employeeFound.SuMoney < createExchangeCashPersonCommand.ExchangedSuMoney {
1416 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "当前兑换素币超过本人持有的素币值") 1466 + row := []interface{}{
  1467 + createExchangeCashPersonCommand.PersonName,
  1468 + createExchangeCashPersonCommand.PersonAccount,
  1469 + createExchangeCashPersonCommand.ExchangedSuMoney,
  1470 + "当前兑换素币超过本人持有的素币值",
  1471 + }
  1472 + failureDataList = append(failureDataList, row)
  1473 + continue
1417 } 1474 }
1418 1475
1419 if len(peopleFound) > 0 { // 当前导入员工在素币兑换清单中,判断追加素币兑换或撤回素币兑换 1476 if len(peopleFound) > 0 { // 当前导入员工在素币兑换清单中,判断追加素币兑换或撤回素币兑换
@@ -1440,13 +1497,27 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1440,13 +1497,27 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1440 1497
1441 // 更新兑换素币清单 1498 // 更新兑换素币清单
1442 if err := peopleFound[0].Update(tool_funs.SimpleStructToMap(updateExchangeCashPersonCommand)); err != nil { 1499 if err := peopleFound[0].Update(tool_funs.SimpleStructToMap(updateExchangeCashPersonCommand)); err != nil {
1443 - return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 1500 + row := []interface{}{
  1501 + createExchangeCashPersonCommand.PersonName,
  1502 + createExchangeCashPersonCommand.PersonAccount,
  1503 + createExchangeCashPersonCommand.ExchangedSuMoney,
  1504 + err.Error(),
  1505 + }
  1506 + failureDataList = append(failureDataList, row)
  1507 + continue
1444 } 1508 }
1445 1509
1446 // 保存兑换素币清单更新 1510 // 保存兑换素币清单更新
1447 personUpdated, err := exchangeCashPersonListRepository.Save(peopleFound[0]) 1511 personUpdated, err := exchangeCashPersonListRepository.Save(peopleFound[0])
1448 if err != nil { 1512 if err != nil {
1449 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1513 + row := []interface{}{
  1514 + createExchangeCashPersonCommand.PersonName,
  1515 + createExchangeCashPersonCommand.PersonAccount,
  1516 + createExchangeCashPersonCommand.ExchangedSuMoney,
  1517 + err.Error(),
  1518 + }
  1519 + failureDataList = append(failureDataList, row)
  1520 + continue
1450 } 1521 }
1451 1522
1452 // 更新素币兑换活动命令 1523 // 更新素币兑换活动命令
@@ -1461,16 +1532,37 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1461,16 +1532,37 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1461 1532
1462 // 更新兑换活动 1533 // 更新兑换活动
1463 if err := activityFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashActivityCommand)); err != nil { 1534 if err := activityFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashActivityCommand)); err != nil {
1464 - return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 1535 + row := []interface{}{
  1536 + createExchangeCashPersonCommand.PersonName,
  1537 + createExchangeCashPersonCommand.PersonAccount,
  1538 + createExchangeCashPersonCommand.ExchangedSuMoney,
  1539 + err.Error(),
  1540 + }
  1541 + failureDataList = append(failureDataList, row)
  1542 + continue
1465 } 1543 }
1466 1544
1467 // 保存兑换现金活动更新 1545 // 保存兑换现金活动更新
1468 activityUpdated, err := exchangeCashActivityRepository.Save(activityFound) 1546 activityUpdated, err := exchangeCashActivityRepository.Save(activityFound)
1469 if err != nil { 1547 if err != nil {
1470 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1548 + row := []interface{}{
  1549 + createExchangeCashPersonCommand.PersonName,
  1550 + createExchangeCashPersonCommand.PersonAccount,
  1551 + createExchangeCashPersonCommand.ExchangedSuMoney,
  1552 + err.Error(),
  1553 + }
  1554 + failureDataList = append(failureDataList, row)
  1555 + continue
1471 } 1556 }
1472 if activityUpdated == nil { 1557 if activityUpdated == nil {
1473 - return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(createExchangeCashPersonCommand.ExchangeCashActivityId))) 1558 + row := []interface{}{
  1559 + createExchangeCashPersonCommand.PersonName,
  1560 + createExchangeCashPersonCommand.PersonAccount,
  1561 + createExchangeCashPersonCommand.ExchangedSuMoney,
  1562 + "兑换现金活动保存失败",
  1563 + }
  1564 + failureDataList = append(failureDataList, row)
  1565 + continue
1474 } 1566 }
1475 1567
1476 // 操作类型->记录类型对应:1->3: 增加 2->4: 扣除 3->1: 兑换物资 4->5: 兑换现金活动 41->6: 撤回兑换现金素币 5->2: 任务奖励 1568 // 操作类型->记录类型对应:1->3: 增加 2->4: 扣除 3->1: 兑换物资 4->5: 兑换现金活动 41->6: 撤回兑换现金素币 5->2: 任务奖励
@@ -1487,24 +1579,59 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1487,24 +1579,59 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1487 // 操作个人素币,生成素币流水记录 1579 // 操作个人素币,生成素币流水记录
1488 task, err := operationSuMoneyService.Operation(operationSuMoneyCommand.Uid, operationSuMoneyCommand.Operator, operationSuMoneyCommand.SuMoney, operationSuMoneyCommand.OperationType, operationSuMoneyCommand.OperationDescription) 1580 task, err := operationSuMoneyService.Operation(operationSuMoneyCommand.Uid, operationSuMoneyCommand.Operator, operationSuMoneyCommand.SuMoney, operationSuMoneyCommand.OperationType, operationSuMoneyCommand.OperationDescription)
1489 if err != nil { 1581 if err != nil {
1490 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1582 + row := []interface{}{
  1583 + createExchangeCashPersonCommand.PersonName,
  1584 + createExchangeCashPersonCommand.PersonAccount,
  1585 + createExchangeCashPersonCommand.ExchangedSuMoney,
  1586 + "操作个人素币失败",
  1587 + }
  1588 + failureDataList = append(failureDataList, row)
  1589 + continue
1491 } 1590 }
1492 if task == nil { 1591 if task == nil {
1493 - return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(operationSuMoneyCommand.Uid))) 1592 + row := []interface{}{
  1593 + createExchangeCashPersonCommand.PersonName,
  1594 + createExchangeCashPersonCommand.PersonAccount,
  1595 + createExchangeCashPersonCommand.ExchangedSuMoney,
  1596 + "操作个人素币失败",
  1597 + }
  1598 + failureDataList = append(failureDataList, row)
  1599 + continue
1494 } 1600 }
1495 1601
1496 // 判断兑换活动的现金是否超过现金池未兑换现金 1602 // 判断兑换活动的现金是否超过现金池未兑换现金
1497 if activityUpdated.ExchangedSuMoney * updateExchangeCashActivityCommand.ExchangeRate > cashPoolsFound[0].UnExchangeCash { 1603 if activityUpdated.ExchangedSuMoney * updateExchangeCashActivityCommand.ExchangeRate > cashPoolsFound[0].UnExchangeCash {
1498 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "已超过现金池未兑换现金") 1604 + row := []interface{}{
  1605 + createExchangeCashPersonCommand.PersonName,
  1606 + createExchangeCashPersonCommand.PersonAccount,
  1607 + createExchangeCashPersonCommand.ExchangedSuMoney,
  1608 + "已超过现金池未兑换现金",
  1609 + }
  1610 + failureDataList = append(failureDataList, row)
  1611 + continue
1499 } 1612 }
1500 1613
1501 // 获取平台素币兑换情况 1614 // 获取平台素币兑换情况
1502 systemSuMoneyStatistics, err := employeeDao.CalculateSystemSuMoney(activityFound.CompanyId) 1615 systemSuMoneyStatistics, err := employeeDao.CalculateSystemSuMoney(activityFound.CompanyId)
1503 if err != nil { 1616 if err != nil {
1504 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1617 + row := []interface{}{
  1618 + createExchangeCashPersonCommand.PersonName,
  1619 + createExchangeCashPersonCommand.PersonAccount,
  1620 + createExchangeCashPersonCommand.ExchangedSuMoney,
  1621 + err.Error(),
  1622 + }
  1623 + failureDataList = append(failureDataList, row)
  1624 + continue
1505 } 1625 }
1506 if systemSuMoneyStatistics == nil { 1626 if systemSuMoneyStatistics == nil {
1507 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的公司") 1627 + row := []interface{}{
  1628 + createExchangeCashPersonCommand.PersonName,
  1629 + createExchangeCashPersonCommand.PersonAccount,
  1630 + createExchangeCashPersonCommand.ExchangedSuMoney,
  1631 + "无效的公司",
  1632 + }
  1633 + failureDataList = append(failureDataList, row)
  1634 + continue
1508 } 1635 }
1509 systemExchangedSuMoney := systemSuMoneyStatistics["systemExchangedSuMoney"].(float64) 1636 systemExchangedSuMoney := systemSuMoneyStatistics["systemExchangedSuMoney"].(float64)
1510 systemUnExchangeSuMoney := systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64) 1637 systemUnExchangeSuMoney := systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64)
@@ -1531,23 +1658,39 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1531,23 +1658,39 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1531 1658
1532 // 更新现金池 1659 // 更新现金池
1533 if err := cashPoolsFound[0].Update(tool_funs.SimpleStructToMap(updateCashPoolCommand)); err != nil { 1660 if err := cashPoolsFound[0].Update(tool_funs.SimpleStructToMap(updateCashPoolCommand)); err != nil {
1534 - return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 1661 + row := []interface{}{
  1662 + createExchangeCashPersonCommand.PersonName,
  1663 + createExchangeCashPersonCommand.PersonAccount,
  1664 + createExchangeCashPersonCommand.ExchangedSuMoney,
  1665 + err.Error(),
  1666 + }
  1667 + failureDataList = append(failureDataList, row)
  1668 + continue
1535 } 1669 }
1536 1670
1537 // 保存现金池更新 1671 // 保存现金池更新
1538 cashPoolUpdated, err := cashPoolRepository.Save(cashPoolsFound[0]) 1672 cashPoolUpdated, err := cashPoolRepository.Save(cashPoolsFound[0])
1539 if err != nil { 1673 if err != nil {
1540 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1674 + row := []interface{}{
  1675 + createExchangeCashPersonCommand.PersonName,
  1676 + createExchangeCashPersonCommand.PersonAccount,
  1677 + createExchangeCashPersonCommand.ExchangedSuMoney,
  1678 + "内部业务错误" + err.Error(),
  1679 + }
  1680 + failureDataList = append(failureDataList, row)
  1681 + continue
1541 } 1682 }
1542 if cashPoolUpdated == nil { 1683 if cashPoolUpdated == nil {
1543 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1684 + row := []interface{}{
  1685 + createExchangeCashPersonCommand.PersonName,
  1686 + createExchangeCashPersonCommand.PersonAccount,
  1687 + createExchangeCashPersonCommand.ExchangedSuMoney,
  1688 + "内部业务错误" + err.Error(),
1544 } 1689 }
1545 -  
1546 - if err := transactionContext.CommitTransaction(); err != nil {  
1547 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 1690 + failureDataList = append(failureDataList, row)
  1691 + continue
1548 } 1692 }
1549 - return personUpdated, nil  
1550 - } else if createExchangeCashPersonCommand.ExchangedSuMoney > personFoundExchangedSuMoney { // 当前兑换素币大于已兑换素币,追加兑换素币 1693 + } else { // 当前兑换素币大于等于已兑换素币,追加兑换素币
1551 // 素币增量 1694 // 素币增量
1552 suMoneyIncrement := createExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney 1695 suMoneyIncrement := createExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney
1553 1696
@@ -1564,13 +1707,27 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1564,13 +1707,27 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1564 1707
1565 // 更新兑换素币清单 1708 // 更新兑换素币清单
1566 if err := peopleFound[0].Update(tool_funs.SimpleStructToMap(updateExchangeCashPersonCommand)); err != nil { 1709 if err := peopleFound[0].Update(tool_funs.SimpleStructToMap(updateExchangeCashPersonCommand)); err != nil {
1567 - return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 1710 + row := []interface{}{
  1711 + createExchangeCashPersonCommand.PersonName,
  1712 + createExchangeCashPersonCommand.PersonAccount,
  1713 + createExchangeCashPersonCommand.ExchangedSuMoney,
  1714 + "内部业务错误" + err.Error(),
  1715 + }
  1716 + failureDataList = append(failureDataList, row)
  1717 + continue
1568 } 1718 }
1569 1719
1570 // 保存兑换素币清单更新 1720 // 保存兑换素币清单更新
1571 personUpdated, err := exchangeCashPersonListRepository.Save(peopleFound[0]) 1721 personUpdated, err := exchangeCashPersonListRepository.Save(peopleFound[0])
1572 if err != nil { 1722 if err != nil {
1573 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1723 + row := []interface{}{
  1724 + createExchangeCashPersonCommand.PersonName,
  1725 + createExchangeCashPersonCommand.PersonAccount,
  1726 + createExchangeCashPersonCommand.ExchangedSuMoney,
  1727 + "内部业务错误" + err.Error(),
  1728 + }
  1729 + failureDataList = append(failureDataList, row)
  1730 + continue
1574 } 1731 }
1575 1732
1576 // 更新素币兑换活动命令 1733 // 更新素币兑换活动命令
@@ -1585,16 +1742,37 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1585,16 +1742,37 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1585 1742
1586 // 更新兑换活动 1743 // 更新兑换活动
1587 if err := activityFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashActivityCommand)); err != nil { 1744 if err := activityFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashActivityCommand)); err != nil {
1588 - return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 1745 + row := []interface{}{
  1746 + createExchangeCashPersonCommand.PersonName,
  1747 + createExchangeCashPersonCommand.PersonAccount,
  1748 + createExchangeCashPersonCommand.ExchangedSuMoney,
  1749 + "内部业务错误" + err.Error(),
  1750 + }
  1751 + failureDataList = append(failureDataList, row)
  1752 + continue
1589 } 1753 }
1590 1754
1591 // 保存兑换现金活动更新 1755 // 保存兑换现金活动更新
1592 activityUpdated, err := exchangeCashActivityRepository.Save(activityFound) 1756 activityUpdated, err := exchangeCashActivityRepository.Save(activityFound)
1593 if err != nil { 1757 if err != nil {
1594 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1758 + row := []interface{}{
  1759 + createExchangeCashPersonCommand.PersonName,
  1760 + createExchangeCashPersonCommand.PersonAccount,
  1761 + createExchangeCashPersonCommand.ExchangedSuMoney,
  1762 + "内部业务错误" + err.Error(),
  1763 + }
  1764 + failureDataList = append(failureDataList, row)
  1765 + continue
1595 } 1766 }
1596 if activityUpdated == nil { 1767 if activityUpdated == nil {
1597 - return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(createExchangeCashPersonCommand.ExchangeCashActivityId))) 1768 + row := []interface{}{
  1769 + createExchangeCashPersonCommand.PersonName,
  1770 + createExchangeCashPersonCommand.PersonAccount,
  1771 + createExchangeCashPersonCommand.ExchangedSuMoney,
  1772 + "内部业务错误",
  1773 + }
  1774 + failureDataList = append(failureDataList, row)
  1775 + continue
1598 } 1776 }
1599 1777
1600 // 操作类型->记录类型对应:1->3: 增加 2->4: 扣除 3->1: 兑换物资 4->5: 兑换现金活动 41->6: 撤回兑换现金素币 5->2: 任务奖励 1778 // 操作类型->记录类型对应:1->3: 增加 2->4: 扣除 3->1: 兑换物资 4->5: 兑换现金活动 41->6: 撤回兑换现金素币 5->2: 任务奖励
@@ -1611,24 +1789,59 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1611,24 +1789,59 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1611 // 操作素币,生成素币流水 1789 // 操作素币,生成素币流水
1612 task, err := operationSuMoneyService.Operation(operationSuMoneyCommand.Uid, operationSuMoneyCommand.Operator, operationSuMoneyCommand.SuMoney, operationSuMoneyCommand.OperationType, operationSuMoneyCommand.OperationDescription) 1790 task, err := operationSuMoneyService.Operation(operationSuMoneyCommand.Uid, operationSuMoneyCommand.Operator, operationSuMoneyCommand.SuMoney, operationSuMoneyCommand.OperationType, operationSuMoneyCommand.OperationDescription)
1613 if err != nil { 1791 if err != nil {
1614 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1792 + row := []interface{}{
  1793 + createExchangeCashPersonCommand.PersonName,
  1794 + createExchangeCashPersonCommand.PersonAccount,
  1795 + createExchangeCashPersonCommand.ExchangedSuMoney,
  1796 + "内部业务错误" + err.Error(),
  1797 + }
  1798 + failureDataList = append(failureDataList, row)
  1799 + continue
1615 } 1800 }
1616 if task == nil { 1801 if task == nil {
1617 - return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(operationSuMoneyCommand.Uid))) 1802 + row := []interface{}{
  1803 + createExchangeCashPersonCommand.PersonName,
  1804 + createExchangeCashPersonCommand.PersonAccount,
  1805 + createExchangeCashPersonCommand.ExchangedSuMoney,
  1806 + "内部业务错误",
  1807 + }
  1808 + failureDataList = append(failureDataList, row)
  1809 + continue
1618 } 1810 }
1619 1811
1620 // 判断兑换活动的现金是否超过现金池未兑换现金 1812 // 判断兑换活动的现金是否超过现金池未兑换现金
1621 if activityUpdated.ExchangedSuMoney * updateExchangeCashActivityCommand.ExchangeRate > cashPoolsFound[0].UnExchangeCash { 1813 if activityUpdated.ExchangedSuMoney * updateExchangeCashActivityCommand.ExchangeRate > cashPoolsFound[0].UnExchangeCash {
1622 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "已超过现金池未兑换现金") 1814 + row := []interface{}{
  1815 + createExchangeCashPersonCommand.PersonName,
  1816 + createExchangeCashPersonCommand.PersonAccount,
  1817 + createExchangeCashPersonCommand.ExchangedSuMoney,
  1818 + "已超过现金池未兑换现金",
  1819 + }
  1820 + failureDataList = append(failureDataList, row)
  1821 + continue
1623 } 1822 }
1624 1823
1625 // 获取平台素币兑换情况 1824 // 获取平台素币兑换情况
1626 systemSuMoneyStatistics, err := employeeDao.CalculateSystemSuMoney(activityFound.CompanyId) 1825 systemSuMoneyStatistics, err := employeeDao.CalculateSystemSuMoney(activityFound.CompanyId)
1627 if err != nil { 1826 if err != nil {
1628 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1827 + row := []interface{}{
  1828 + createExchangeCashPersonCommand.PersonName,
  1829 + createExchangeCashPersonCommand.PersonAccount,
  1830 + createExchangeCashPersonCommand.ExchangedSuMoney,
  1831 + "内部业务错误" + err.Error(),
  1832 + }
  1833 + failureDataList = append(failureDataList, row)
  1834 + continue
1629 } 1835 }
1630 if systemSuMoneyStatistics == nil { 1836 if systemSuMoneyStatistics == nil {
1631 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的公司") 1837 + row := []interface{}{
  1838 + createExchangeCashPersonCommand.PersonName,
  1839 + createExchangeCashPersonCommand.PersonAccount,
  1840 + createExchangeCashPersonCommand.ExchangedSuMoney,
  1841 + "无效的公司员工",
  1842 + }
  1843 + failureDataList = append(failureDataList, row)
  1844 + continue
1632 } 1845 }
1633 systemExchangedSuMoney := systemSuMoneyStatistics["systemExchangedSuMoney"].(float64) 1846 systemExchangedSuMoney := systemSuMoneyStatistics["systemExchangedSuMoney"].(float64)
1634 systemUnExchangeSuMoney := systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64) 1847 systemUnExchangeSuMoney := systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64)
@@ -1655,27 +1868,38 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1655,27 +1868,38 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1655 1868
1656 // 更新现金池 1869 // 更新现金池
1657 if err := cashPoolsFound[0].Update(tool_funs.SimpleStructToMap(updateCashPoolCommand)); err != nil { 1870 if err := cashPoolsFound[0].Update(tool_funs.SimpleStructToMap(updateCashPoolCommand)); err != nil {
1658 - return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 1871 + row := []interface{}{
  1872 + createExchangeCashPersonCommand.PersonName,
  1873 + createExchangeCashPersonCommand.PersonAccount,
  1874 + createExchangeCashPersonCommand.ExchangedSuMoney,
  1875 + "内部业务错误" + err.Error(),
  1876 + }
  1877 + failureDataList = append(failureDataList, row)
  1878 + continue
1659 } 1879 }
1660 1880
1661 // 保存现金池更新 1881 // 保存现金池更新
1662 cashPoolUpdated, err := cashPoolRepository.Save(cashPoolsFound[0]) 1882 cashPoolUpdated, err := cashPoolRepository.Save(cashPoolsFound[0])
1663 if err != nil { 1883 if err != nil {
1664 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1884 + row := []interface{}{
  1885 + createExchangeCashPersonCommand.PersonName,
  1886 + createExchangeCashPersonCommand.PersonAccount,
  1887 + createExchangeCashPersonCommand.ExchangedSuMoney,
  1888 + "内务业务错误" + err.Error(),
1665 } 1889 }
1666 - if cashPoolUpdated == nil {  
1667 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1890 + failureDataList = append(failureDataList, row)
  1891 + continue
1668 } 1892 }
1669 -  
1670 - if err := transactionContext.CommitTransaction(); err != nil {  
1671 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 1893 + if cashPoolUpdated == nil {
  1894 + row := []interface{}{
  1895 + createExchangeCashPersonCommand.PersonName,
  1896 + createExchangeCashPersonCommand.PersonAccount,
  1897 + createExchangeCashPersonCommand.ExchangedSuMoney,
  1898 + "内部业务错误" + err.Error(),
1672 } 1899 }
1673 - return personUpdated, nil  
1674 - } else { // 当前导入兑换素币清单素币等于本人已兑换素币  
1675 - if err := transactionContext.CommitTransaction(); err != nil {  
1676 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 1900 + failureDataList = append(failureDataList, row)
  1901 + continue
1677 } 1902 }
1678 - return nil, nil  
1679 } 1903 }
1680 } else if len(peopleFound) == 0 { // 导入兑换素币清单员工不存在兑换素币清单中,新增兑换素币清单 1904 } else if len(peopleFound) == 0 { // 导入兑换素币清单员工不存在兑换素币清单中,新增兑换素币清单
1681 // 新增兑换素币清单命令 1905 // 新增兑换素币清单命令
@@ -1694,7 +1918,14 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1694,7 +1918,14 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1694 // 保存兑换素币清单 1918 // 保存兑换素币清单
1695 personSaved, err := exchangeCashPersonListRepository.Save(newPerson) 1919 personSaved, err := exchangeCashPersonListRepository.Save(newPerson)
1696 if err != nil { 1920 if err != nil {
1697 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1921 + row := []interface{}{
  1922 + createExchangeCashPersonCommand.PersonName,
  1923 + createExchangeCashPersonCommand.PersonAccount,
  1924 + createExchangeCashPersonCommand.ExchangedSuMoney,
  1925 + "内务业务错误" + err.Error(),
  1926 + }
  1927 + failureDataList = append(failureDataList, row)
  1928 + continue
1698 } 1929 }
1699 1930
1700 // 操作类型->记录类型对应:1->3: 增加 2->4: 扣除 3->1: 兑换物资 4->5: 兑换现金活动 41->6: 撤回兑换现金素币 5->2: 任务奖励 1931 // 操作类型->记录类型对应:1->3: 增加 2->4: 扣除 3->1: 兑换物资 4->5: 兑换现金活动 41->6: 撤回兑换现金素币 5->2: 任务奖励
@@ -1711,10 +1942,24 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1711,10 +1942,24 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1711 // 操作素币,生成素币流水 1942 // 操作素币,生成素币流水
1712 task, err := operationSuMoneyService.Operation(operationSuMoneyCommand.Uid, operationSuMoneyCommand.Operator, operationSuMoneyCommand.SuMoney, operationSuMoneyCommand.OperationType, operationSuMoneyCommand.OperationDescription) 1943 task, err := operationSuMoneyService.Operation(operationSuMoneyCommand.Uid, operationSuMoneyCommand.Operator, operationSuMoneyCommand.SuMoney, operationSuMoneyCommand.OperationType, operationSuMoneyCommand.OperationDescription)
1713 if err != nil { 1944 if err != nil {
1714 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1945 + row := []interface{}{
  1946 + createExchangeCashPersonCommand.PersonName,
  1947 + createExchangeCashPersonCommand.PersonAccount,
  1948 + createExchangeCashPersonCommand.ExchangedSuMoney,
  1949 + "内部业务错误" + err.Error(),
  1950 + }
  1951 + failureDataList = append(failureDataList, row)
  1952 + continue
1715 } 1953 }
1716 if task == nil { 1954 if task == nil {
1717 - return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(operationSuMoneyCommand.Uid))) 1955 + row := []interface{}{
  1956 + createExchangeCashPersonCommand.PersonName,
  1957 + createExchangeCashPersonCommand.PersonAccount,
  1958 + createExchangeCashPersonCommand.ExchangedSuMoney,
  1959 + "内部业务错误",
  1960 + }
  1961 + failureDataList = append(failureDataList, row)
  1962 + continue
1718 } 1963 }
1719 1964
1720 // 更新兑换活动命令 1965 // 更新兑换活动命令
@@ -1730,30 +1975,72 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1730,30 +1975,72 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1730 1975
1731 // 更新兑换活动 1976 // 更新兑换活动
1732 if err := activityFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashActivityCommand)); err != nil { 1977 if err := activityFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashActivityCommand)); err != nil {
1733 - return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 1978 + row := []interface{}{
  1979 + createExchangeCashPersonCommand.PersonName,
  1980 + createExchangeCashPersonCommand.PersonAccount,
  1981 + createExchangeCashPersonCommand.ExchangedSuMoney,
  1982 + "当前兑换素币超过本人持有的素币值",
  1983 + }
  1984 + failureDataList = append(failureDataList, row)
  1985 + continue
1734 } 1986 }
1735 1987
1736 // 保存兑换现金活动更新 1988 // 保存兑换现金活动更新
1737 activityUpdated, err := exchangeCashActivityRepository.Save(activityFound) 1989 activityUpdated, err := exchangeCashActivityRepository.Save(activityFound)
1738 if err != nil { 1990 if err != nil {
1739 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1991 + row := []interface{}{
  1992 + createExchangeCashPersonCommand.PersonName,
  1993 + createExchangeCashPersonCommand.PersonAccount,
  1994 + createExchangeCashPersonCommand.ExchangedSuMoney,
  1995 + "内部业务错误" + err.Error(),
  1996 + }
  1997 + failureDataList = append(failureDataList, row)
  1998 + continue
1740 } 1999 }
1741 if activityUpdated == nil { 2000 if activityUpdated == nil {
1742 - return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(createExchangeCashPersonCommand.ExchangeCashActivityId))) 2001 + row := []interface{}{
  2002 + createExchangeCashPersonCommand.PersonName,
  2003 + createExchangeCashPersonCommand.PersonAccount,
  2004 + createExchangeCashPersonCommand.ExchangedSuMoney,
  2005 + "内部业务错误",
  2006 + }
  2007 + failureDataList = append(failureDataList, row)
  2008 + continue
1743 } 2009 }
1744 2010
1745 // 判断兑换活动的现金是否超过现金池未兑换现金 2011 // 判断兑换活动的现金是否超过现金池未兑换现金
1746 if activityUpdated.ExchangedSuMoney * updateExchangeCashActivityCommand.ExchangeRate > cashPoolsFound[0].UnExchangeCash { 2012 if activityUpdated.ExchangedSuMoney * updateExchangeCashActivityCommand.ExchangeRate > cashPoolsFound[0].UnExchangeCash {
1747 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "已超过现金池未兑换现金") 2013 + row := []interface{}{
  2014 + createExchangeCashPersonCommand.PersonName,
  2015 + createExchangeCashPersonCommand.PersonAccount,
  2016 + createExchangeCashPersonCommand.ExchangedSuMoney,
  2017 + "已超过现金池未兑换现金",
  2018 + }
  2019 + failureDataList = append(failureDataList, row)
  2020 + continue
1748 } 2021 }
1749 2022
1750 // 获取平台素币兑换情况 2023 // 获取平台素币兑换情况
1751 systemSuMoneyStatistics, err := employeeDao.CalculateSystemSuMoney(activityFound.CompanyId) 2024 systemSuMoneyStatistics, err := employeeDao.CalculateSystemSuMoney(activityFound.CompanyId)
1752 if err != nil { 2025 if err != nil {
1753 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 2026 + row := []interface{}{
  2027 + createExchangeCashPersonCommand.PersonName,
  2028 + createExchangeCashPersonCommand.PersonAccount,
  2029 + createExchangeCashPersonCommand.ExchangedSuMoney,
  2030 + "内部业务错误" + err.Error(),
  2031 + }
  2032 + failureDataList = append(failureDataList, row)
  2033 + continue
1754 } 2034 }
1755 if systemSuMoneyStatistics == nil { 2035 if systemSuMoneyStatistics == nil {
1756 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的公司") 2036 + row := []interface{}{
  2037 + createExchangeCashPersonCommand.PersonName,
  2038 + createExchangeCashPersonCommand.PersonAccount,
  2039 + createExchangeCashPersonCommand.ExchangedSuMoney,
  2040 + "无效的公司员工",
  2041 + }
  2042 + failureDataList = append(failureDataList, row)
  2043 + continue
1757 } 2044 }
1758 systemExchangedSuMoney := systemSuMoneyStatistics["systemExchangedSuMoney"].(float64) 2045 systemExchangedSuMoney := systemSuMoneyStatistics["systemExchangedSuMoney"].(float64)
1759 systemUnExchangeSuMoney := systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64) 2046 systemUnExchangeSuMoney := systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64)
@@ -1780,28 +2067,57 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1780,28 +2067,57 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1780 2067
1781 // 更新现金池 2068 // 更新现金池
1782 if err := cashPoolsFound[0].Update(tool_funs.SimpleStructToMap(updateCashPoolCommand)); err != nil { 2069 if err := cashPoolsFound[0].Update(tool_funs.SimpleStructToMap(updateCashPoolCommand)); err != nil {
1783 - return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 2070 + row := []interface{}{
  2071 + createExchangeCashPersonCommand.PersonName,
  2072 + createExchangeCashPersonCommand.PersonAccount,
  2073 + createExchangeCashPersonCommand.ExchangedSuMoney,
  2074 + "内部业务错误" + err.Error(),
  2075 + }
  2076 + failureDataList = append(failureDataList, row)
  2077 + continue
1784 } 2078 }
1785 2079
1786 // 保存现金池更新 2080 // 保存现金池更新
1787 cashPoolUpdated, err := cashPoolRepository.Save(cashPoolsFound[0]) 2081 cashPoolUpdated, err := cashPoolRepository.Save(cashPoolsFound[0])
1788 if err != nil { 2082 if err != nil {
1789 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 2083 + row := []interface{}{
  2084 + createExchangeCashPersonCommand.PersonName,
  2085 + createExchangeCashPersonCommand.PersonAccount,
  2086 + createExchangeCashPersonCommand.ExchangedSuMoney,
  2087 + "内部业务错误" + err.Error(),
  2088 + }
  2089 + failureDataList = append(failureDataList, row)
  2090 + continue
1790 } 2091 }
1791 if cashPoolUpdated == nil { 2092 if cashPoolUpdated == nil {
1792 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 2093 + row := []interface{}{
  2094 + createExchangeCashPersonCommand.PersonName,
  2095 + createExchangeCashPersonCommand.PersonAccount,
  2096 + createExchangeCashPersonCommand.ExchangedSuMoney,
  2097 + "内部业务错误" + err.Error(),
1793 } 2098 }
1794 -  
1795 - if err := transactionContext.CommitTransaction(); err != nil {  
1796 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 2099 + failureDataList = append(failureDataList, row)
  2100 + continue
1797 } 2101 }
1798 - return personSaved, nil  
1799 } else { // 未知情况 2102 } else { // 未知情况
  2103 + row := []interface{}{
  2104 + createExchangeCashPersonCommand.PersonName,
  2105 + createExchangeCashPersonCommand.PersonAccount,
  2106 + createExchangeCashPersonCommand.ExchangedSuMoney,
  2107 + "未知错误",
  2108 + }
  2109 + failureDataList = append(failureDataList, row)
  2110 + continue
  2111 + }
  2112 + }
  2113 +
  2114 + if len(failureDataList) == 0 {
1800 if err := transactionContext.CommitTransaction(); err != nil { 2115 if err := transactionContext.CommitTransaction(); err != nil {
1801 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 2116 + return failureDataList, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
1802 } 2117 }
1803 - return nil, nil 2118 + return failureDataList, nil
1804 } 2119 }
  2120 + return failureDataList, nil
1805 } 2121 }
1806 2122
1807 // 页面新增兑换素币清单 2123 // 页面新增兑换素币清单
@@ -460,7 +460,7 @@ func (controller *SuMoneyController) ImportExchangeList () { @@ -460,7 +460,7 @@ func (controller *SuMoneyController) ImportExchangeList () {
460 if i > 2 { 460 if i > 2 {
461 if len(row) != 3 { 461 if len(row) != 3 {
462 for j, cell := range row { 462 for j, cell := range row {
463 - if cell == "" { 463 + if cell == " " {
464 utils_tool.InsertSlice(j, row, newstr) 464 utils_tool.InsertSlice(j, row, newstr)
465 } 465 }
466 } 466 }
@@ -490,6 +490,8 @@ func (controller *SuMoneyController) ImportExchangeList () { @@ -490,6 +490,8 @@ func (controller *SuMoneyController) ImportExchangeList () {
490 // 新增成功计数 490 // 新增成功计数
491 var successDataCount int64 491 var successDataCount int64
492 492
  493 + var createExchangeCashPersonCommands []*command.CreateExchangeCashPersonCommand
  494 +
493 for i, row := range rows { 495 for i, row := range rows {
494 if i > 2 && len(row) > 1 { 496 if i > 2 && len(row) > 1 {
495 // 创建兑换清单命令 497 // 创建兑换清单命令
@@ -500,18 +502,22 @@ func (controller *SuMoneyController) ImportExchangeList () { @@ -500,18 +502,22 @@ func (controller *SuMoneyController) ImportExchangeList () {
500 createExchangeCashPersonCommand.PersonAccount = row[1] 502 createExchangeCashPersonCommand.PersonAccount = row[1]
501 r2, _ := strconv.ParseFloat(row[2], 64) 503 r2, _ := strconv.ParseFloat(row[2], 64)
502 createExchangeCashPersonCommand.ExchangedSuMoney = r2 504 createExchangeCashPersonCommand.ExchangedSuMoney = r2
  505 + createExchangeCashPersonCommands = append(createExchangeCashPersonCommands, createExchangeCashPersonCommand)
  506 + }
  507 + }
503 508
504 // 创建兑换素币清单 509 // 创建兑换素币清单
505 - _, err := cashPoolService.ImportCreateExchangeCashPerson(createExchangeCashPersonCommand) 510 + failureDataList, err = cashPoolService.ImportCreateExchangeCashPerson(createExchangeCashPersonCommands, failureDataList)
506 if err != nil { // 导入失败处理 511 if err != nil { // 导入失败处理
507 - rows[i] = append(rows[i], err.Error())  
508 - failureDataList = append(failureDataList, rows[i]) // 导入失败的记录  
509 - } else { // 导入成功处理  
510 - successDataCount += 1  
511 - }  
512 - } 512 + response = utils.ResponseError(controller.Ctx, err)
  513 + controller.Data["json"] = response
  514 + controller.ServeJSON()
  515 + return
  516 + } else {
  517 + successDataCount = int64(len(rows) - 3 - len(failureDataList))
513 } 518 }
514 519
  520 + // 导入失败返回
515 ret = map[string]interface{}{ 521 ret = map[string]interface{}{
516 "successCount": successDataCount, 522 "successCount": successDataCount,
517 "fail": map[string]interface{}{ 523 "fail": map[string]interface{}{
@@ -520,6 +526,7 @@ func (controller *SuMoneyController) ImportExchangeList () { @@ -520,6 +526,7 @@ func (controller *SuMoneyController) ImportExchangeList () {
520 }, 526 },
521 } 527 }
522 528
  529 + // 导入成功返回
523 if successDataCount == int64(len(rows) - 3) { 530 if successDataCount == int64(len(rows) - 3) {
524 ret = map[string]interface{}{ 531 ret = map[string]interface{}{
525 "successCount": successDataCount, 532 "successCount": successDataCount,