作者 陈志颖

test:测试现金池流程,修复问题

@@ -284,7 +284,6 @@ func (cashPoolService *CashPoolService) CreateExchangeCashActivity(createExchang @@ -284,7 +284,6 @@ func (cashPoolService *CashPoolService) CreateExchangeCashActivity(createExchang
284 CompanyId: createExchangeCashActivityCommand.CompanyId, 284 CompanyId: createExchangeCashActivityCommand.CompanyId,
285 ExchangedCash: 0, 285 ExchangedCash: 0,
286 ExchangedSuMoney: 0, 286 ExchangedSuMoney: 0,
287 - //Deadline: time.Date(deadline.Year(), deadline.Month(), deadline.Day(), deadline.Hour(), deadline.Minute(), deadline.Second(), 0, time.Local),  
288 Deadline: t2, 287 Deadline: t2,
289 CountDown: int64(t2.Sub(t1).Hours() / 24), // 计算活动截止倒计时 288 CountDown: int64(t2.Sub(t1).Hours() / 24), // 计算活动截止倒计时
290 Rate: createExchangeCashActivityCommand.ExchangeRate, 289 Rate: createExchangeCashActivityCommand.ExchangeRate,
@@ -398,6 +397,9 @@ func (cashPoolService *CashPoolService) SearchExchangeCashActivity(activityComma @@ -398,6 +397,9 @@ func (cashPoolService *CashPoolService) SearchExchangeCashActivity(activityComma
398 ExchangeCashActivityId: activity.ActivityId, 397 ExchangeCashActivityId: activity.ActivityId,
399 CountDown: int64(t2.Sub(t1).Hours() / 24), 398 CountDown: int64(t2.Sub(t1).Hours() / 24),
400 Deadline: activity.Deadline, 399 Deadline: activity.Deadline,
  400 + ExchangedSuMoney: activity.ExchangedSuMoney,
  401 + ExchangedCash: activity.ExchangedCash,
  402 + ExchangeRate: activity.Rate,
401 } 403 }
402 404
403 // 倒计时结束 405 // 倒计时结束
@@ -463,6 +465,9 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas @@ -463,6 +465,9 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas
463 ExchangeCashActivityId: activity.ActivityId, 465 ExchangeCashActivityId: activity.ActivityId,
464 CountDown: int64(t2.Sub(t1).Hours() / 24), 466 CountDown: int64(t2.Sub(t1).Hours() / 24),
465 Deadline: activity.Deadline, 467 Deadline: activity.Deadline,
  468 + ExchangedSuMoney: activity.ExchangedSuMoney,
  469 + ExchangedCash: activity.ExchangedCash,
  470 + ExchangeRate: activity.Rate,
466 } 471 }
467 472
468 // 倒计时结束 473 // 倒计时结束
@@ -594,6 +599,9 @@ func (cashPoolService *CashPoolService) GetExchangeCashActivity(getExchangeCashA @@ -594,6 +599,9 @@ func (cashPoolService *CashPoolService) GetExchangeCashActivity(getExchangeCashA
594 ExchangeCashActivityId: activity.ActivityId, 599 ExchangeCashActivityId: activity.ActivityId,
595 CountDown: int64(t2.Sub(t1).Hours() / 24), 600 CountDown: int64(t2.Sub(t1).Hours() / 24),
596 Deadline: activity.Deadline, 601 Deadline: activity.Deadline,
  602 + ExchangedSuMoney: activity.ExchangedSuMoney,
  603 + ExchangedCash: activity.ExchangedCash,
  604 + ExchangeRate: activity.Rate,
597 } 605 }
598 606
599 // 倒计时结束 607 // 倒计时结束
@@ -796,6 +804,8 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang @@ -796,6 +804,8 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang
796 804
797 // 更新兑换活动已兑换现金 805 // 更新兑换活动已兑换现金
798 updateExchangeCashActivityCommand.ExchangedCash = updateExchangeCashActivityCommand.ExchangeRate * activity.ExchangedSuMoney 806 updateExchangeCashActivityCommand.ExchangedCash = updateExchangeCashActivityCommand.ExchangeRate * activity.ExchangedSuMoney
  807 + } else {
  808 + updateExchangeCashActivityCommand.ExchangedCash = activity.ExchangedCash
799 } 809 }
800 810
801 var timeNow = time.Now() 811 var timeNow = time.Now()
@@ -805,13 +815,15 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang @@ -805,13 +815,15 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang
805 815
806 // 计算倒计时 816 // 计算倒计时
807 updateExchangeCashActivityCommand.CountDown = int64(t2.Sub(t1).Hours() / 24) 817 updateExchangeCashActivityCommand.CountDown = int64(t2.Sub(t1).Hours() / 24)
  818 + //updateExchangeCashActivityCommand.Deadline = deadline
808 819
809 // 倒计时结束 820 // 倒计时结束
810 if t2.Before(t1) { 821 if t2.Before(t1) {
811 updateExchangeCashActivityCommand.CountDown = 0 822 updateExchangeCashActivityCommand.CountDown = 0
812 - updateExchangeCashActivityCommand.Deadline = activity.Deadline  
813 } 823 }
814 824
  825 + updateExchangeCashActivityCommand.ExchangedSuMoney = activity.ExchangedSuMoney
  826 +
815 if err := activity.Update(tool_funs.SimpleStructToMap(updateExchangeCashActivityCommand)); err != nil { 827 if err := activity.Update(tool_funs.SimpleStructToMap(updateExchangeCashActivityCommand)); err != nil {
816 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 828 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
817 } 829 }
@@ -858,6 +870,8 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC @@ -858,6 +870,8 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC
858 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 870 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
859 } 871 }
860 872
  873 + fmt.Print(activity.Rate, "\n")
  874 +
861 rate := activity.Rate 875 rate := activity.Rate
862 876
863 // 根据uid/手机账号判断成员是否存在,素币是否超过本人持有的真实素币 877 // 根据uid/手机账号判断成员是否存在,素币是否超过本人持有的真实素币
@@ -870,6 +884,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC @@ -870,6 +884,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC
870 employeeRepository = value 884 employeeRepository = value
871 } 885 }
872 886
  887 + // 判断是excel导入还是页面增加
873 getEmployee := map[string]interface{}{} 888 getEmployee := map[string]interface{}{}
874 if createExchangeCashPersonCommand.PersonAccount == "" { 889 if createExchangeCashPersonCommand.PersonAccount == "" {
875 getEmployee = map[string]interface{}{ 890 getEmployee = map[string]interface{}{
@@ -937,8 +952,6 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC @@ -937,8 +952,6 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC
937 OperationDescription: "素币兑换现金", 952 OperationDescription: "素币兑换现金",
938 } 953 }
939 954
940 - fmt.Print(operationSuMoneyCommand, "\n")  
941 -  
942 task, err := operationSuMoneyService.Operation(operationSuMoneyCommand.Uid, operationSuMoneyCommand.Operator, operationSuMoneyCommand.SuMoney, operationSuMoneyCommand.OperationType, operationSuMoneyCommand.OperationDescription) 955 task, err := operationSuMoneyService.Operation(operationSuMoneyCommand.Uid, operationSuMoneyCommand.Operator, operationSuMoneyCommand.SuMoney, operationSuMoneyCommand.OperationType, operationSuMoneyCommand.OperationDescription)
943 if err != nil { 956 if err != nil {
944 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 957 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
@@ -967,7 +980,10 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC @@ -967,7 +980,10 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC
967 updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{ 980 updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{
968 ExchangeCashActivityId: person.ExchangeCashActivityId, 981 ExchangeCashActivityId: person.ExchangeCashActivityId,
969 ExchangedSuMoney: activityFound.ExchangedSuMoney + person.ExchangedSuMoney, 982 ExchangedSuMoney: activityFound.ExchangedSuMoney + person.ExchangedSuMoney,
970 - ExchangedCash: activityFound.ExchangedCash - person.ExchangedCash, 983 + ExchangedCash: activityFound.ExchangedCash + person.ExchangedCash,
  984 + Deadline: activityFound.Deadline,
  985 + CountDown: activityFound.CountDown,
  986 + ExchangeRate: activityFound.Rate,
971 } 987 }
972 988
973 // 更新兑换活动 989 // 更新兑换活动
@@ -1023,12 +1039,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC @@ -1023,12 +1039,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC
1023 } 1039 }
1024 1040
1025 systemExchangedCash := systemCashStatistics["systemExchangedCash"].(float64) 1041 systemExchangedCash := systemCashStatistics["systemExchangedCash"].(float64)
1026 - systemUnExchangeCash := systemCashStatistics["systemUnExchangeCash"].(float64)  
1027 -  
1028 - // 判断兑换的现金是否超过现金池未兑换现金  
1029 - if activitySuMoney * updateExchangeCashActivityCommand.ExchangeRate > systemUnExchangeCash {  
1030 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "已超过投入现金池的未兑换现金")  
1031 - } 1042 + //systemUnExchangeCash := systemCashStatistics["systemUnExchangeCash"].(float64)
1032 1043
1033 // 获取平台素币状况 1044 // 获取平台素币状况
1034 systemSuMoneyStatistics, err := employeeDao.CalculateSystemSuMoney(activity.CompanyId) 1045 systemSuMoneyStatistics, err := employeeDao.CalculateSystemSuMoney(activity.CompanyId)
@@ -1040,6 +1051,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC @@ -1040,6 +1051,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC
1040 } 1051 }
1041 1052
1042 systemExchangedSuMoney := systemSuMoneyStatistics["systemExchangedSuMoney"].(float64) 1053 systemExchangedSuMoney := systemSuMoneyStatistics["systemExchangedSuMoney"].(float64)
  1054 + systemUnExchangeSuMoney := systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64)
1043 1055
1044 var cashPoolRepository domain.CashPoolRepository 1056 var cashPoolRepository domain.CashPoolRepository
1045 if value, err := factory.CreateCashPoolRepository(map[string] interface{} { 1057 if value, err := factory.CreateCashPoolRepository(map[string] interface{} {
@@ -1061,6 +1073,11 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC @@ -1061,6 +1073,11 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC
1061 return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(activity.CompanyId))) 1073 return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(activity.CompanyId)))
1062 } 1074 }
1063 1075
  1076 + // 判断兑换的现金是否超过现金池未兑换现金
  1077 + if activitySuMoney * updateExchangeCashActivityCommand.ExchangeRate > cashPools[0].UnExchangeCash {
  1078 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "已超过投入现金池的未兑换现金")
  1079 + }
  1080 +
1064 // 计算平均兑换汇率 1081 // 计算平均兑换汇率
1065 var newRate float64 1082 var newRate float64
1066 if systemExchangedSuMoney == 0 { 1083 if systemExchangedSuMoney == 0 {
@@ -1071,8 +1088,10 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC @@ -1071,8 +1088,10 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC
1071 1088
1072 updateCashPoolCommand := &command.UpdateCashPoolCommand{ 1089 updateCashPoolCommand := &command.UpdateCashPoolCommand{
1073 CashPoolId: cashPools[0].CashPoolId, 1090 CashPoolId: cashPools[0].CashPoolId,
1074 - ExchangedCash: systemUnExchangeCash,  
1075 - UnExchangeCash: systemUnExchangeCash, 1091 + ExchangedCash: cashPools[0].ExchangedCash + person.ExchangedCash,
  1092 + ExchangedSuMoney: systemExchangedSuMoney,
  1093 + UnExchangeCash: cashPools[0].UnExchangeCash - person.ExchangedCash,
  1094 + UnExchangeSuMoney: systemUnExchangeSuMoney,
1076 Rate: newRate, 1095 Rate: newRate,
1077 } 1096 }
1078 1097
@@ -1270,7 +1289,10 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC @@ -1270,7 +1289,10 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC
1270 updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{ 1289 updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{
1271 ExchangeCashActivityId: person.ExchangeCashActivityId, 1290 ExchangeCashActivityId: person.ExchangeCashActivityId,
1272 ExchangedSuMoney: activityFound.ExchangedSuMoney - person.ExchangedSuMoney, 1291 ExchangedSuMoney: activityFound.ExchangedSuMoney - person.ExchangedSuMoney,
1273 - ExchangedCash: activityFound.ExchangedCash + person.ExchangedCash, 1292 + ExchangedCash: activityFound.ExchangedCash - person.ExchangedCash,
  1293 + Deadline: activityFound.Deadline,
  1294 + CountDown: activityFound.CountDown,
  1295 + ExchangeRate: activityFound.Rate,
1274 } 1296 }
1275 1297
1276 // 更新兑换活动 1298 // 更新兑换活动
@@ -1300,12 +1322,10 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC @@ -1300,12 +1322,10 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC
1300 Uid: person.EmployeeInfo.Uid, 1322 Uid: person.EmployeeInfo.Uid,
1301 Operator: removeExchangeCashPersonCommand.Operator, 1323 Operator: removeExchangeCashPersonCommand.Operator,
1302 SuMoney: person.ExchangedSuMoney, 1324 SuMoney: person.ExchangedSuMoney,
1303 - OperationType: 1,  
1304 - OperationDescription: activityFound.ExchangeActivityName + "现金调整", 1325 + OperationType: 1, // 增加素币
  1326 + OperationDescription: activityFound.ExchangeActivityName + "素币调整",
1305 } 1327 }
1306 1328
1307 - fmt.Print(removeExchangeCashPersonCommand.Operator, "\n")  
1308 -  
1309 task, err := operationSuMoneyService.Operation(operationSuMoneyCommand.Uid, operationSuMoneyCommand.Operator, operationSuMoneyCommand.SuMoney, operationSuMoneyCommand.OperationType, operationSuMoneyCommand.OperationDescription) 1329 task, err := operationSuMoneyService.Operation(operationSuMoneyCommand.Uid, operationSuMoneyCommand.Operator, operationSuMoneyCommand.SuMoney, operationSuMoneyCommand.OperationType, operationSuMoneyCommand.OperationDescription)
1310 if err != nil { 1330 if err != nil {
1311 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1331 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
@@ -1346,6 +1366,7 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC @@ -1346,6 +1366,7 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC
1346 } 1366 }
1347 1367
1348 systemExchangedSuMoney := systemSuMoneyStatistics["systemExchangedSuMoney"].(float64) 1368 systemExchangedSuMoney := systemSuMoneyStatistics["systemExchangedSuMoney"].(float64)
  1369 + systemUnExchangeSuMoney := systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64)
1349 1370
1350 var cashPoolRepository domain.CashPoolRepository 1371 var cashPoolRepository domain.CashPoolRepository
1351 if value, err := factory.CreateCashPoolRepository(map[string] interface{} { 1372 if value, err := factory.CreateCashPoolRepository(map[string] interface{} {
@@ -1377,9 +1398,11 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC @@ -1377,9 +1398,11 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC
1377 1398
1378 updateCashPoolCommand := &command.UpdateCashPoolCommand{ 1399 updateCashPoolCommand := &command.UpdateCashPoolCommand{
1379 CashPoolId: cashPools[0].CashPoolId, 1400 CashPoolId: cashPools[0].CashPoolId,
1380 - ExchangedCash: systemUnExchangeCash,  
1381 - UnExchangeCash: systemUnExchangeCash, 1401 + ExchangedCash: systemExchangedCash - person.ExchangedCash,
  1402 + UnExchangeCash: systemUnExchangeCash + person.ExchangedCash,
1382 Rate: newRate, 1403 Rate: newRate,
  1404 + ExchangedSuMoney: systemExchangedSuMoney - person.ExchangedSuMoney,
  1405 + UnExchangeSuMoney: systemUnExchangeSuMoney,
1383 } 1406 }
1384 1407
1385 // 更新现金池 1408 // 更新现金池
@@ -1402,14 +1425,12 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC @@ -1402,14 +1425,12 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC
1402 if err := transactionContext.CommitTransaction(); err != nil { 1425 if err := transactionContext.CommitTransaction(); err != nil {
1403 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 1426 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
1404 } 1427 }
1405 -  
1406 return personDeleted, nil 1428 return personDeleted, nil
1407 } 1429 }
1408 } 1430 }
1409 1431
1410 // 更新兑换清单 1432 // 更新兑换清单
1411 func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeCashPersonCommand *command.UpdateExchangeCashPersonCommand) (interface{}, error) { 1433 func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeCashPersonCommand *command.UpdateExchangeCashPersonCommand) (interface{}, error) {
1412 - fmt.Print(updateExchangeCashPersonCommand, "\n")  
1413 if err := updateExchangeCashPersonCommand.ValidateCommand(); err != nil { 1434 if err := updateExchangeCashPersonCommand.ValidateCommand(); err != nil {
1414 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 1435 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
1415 } 1436 }
@@ -1463,6 +1484,8 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC @@ -1463,6 +1484,8 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC
1463 // 更新兑换清单,个人已兑换现金计算 1484 // 更新兑换清单,个人已兑换现金计算
1464 updateExchangeCashPersonCommand.ExchangedCash = updateExchangeCashPersonCommand.ExchangedSuMoney * activityFound.Rate 1485 updateExchangeCashPersonCommand.ExchangedCash = updateExchangeCashPersonCommand.ExchangedSuMoney * activityFound.Rate
1465 1486
  1487 + fmt.Print(updateExchangeCashPersonCommand.ExchangedCash, "\n")
  1488 +
1466 if err := person.Update(tool_funs.SimpleStructToMap(updateExchangeCashPersonCommand)); err != nil { 1489 if err := person.Update(tool_funs.SimpleStructToMap(updateExchangeCashPersonCommand)); err != nil {
1467 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 1490 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
1468 } 1491 }
@@ -1471,6 +1494,9 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC @@ -1471,6 +1494,9 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC
1471 ExchangeCashActivityId: person.ExchangeCashActivityId, 1494 ExchangeCashActivityId: person.ExchangeCashActivityId,
1472 ExchangedSuMoney: activityFound.ExchangedSuMoney + (updateExchangeCashPersonCommand.ExchangedSuMoney - person.ExchangedSuMoney), 1495 ExchangedSuMoney: activityFound.ExchangedSuMoney + (updateExchangeCashPersonCommand.ExchangedSuMoney - person.ExchangedSuMoney),
1473 ExchangedCash: activityFound.ExchangedCash + (updateExchangeCashPersonCommand.ExchangedSuMoney - person.ExchangedSuMoney) * activityFound.Rate, 1496 ExchangedCash: activityFound.ExchangedCash + (updateExchangeCashPersonCommand.ExchangedSuMoney - person.ExchangedSuMoney) * activityFound.Rate,
  1497 + Deadline: activityFound.Deadline,
  1498 + CountDown: activityFound.CountDown,
  1499 + ExchangeRate: activityFound.Rate,
1474 } 1500 }
1475 1501
1476 // 更新兑换活动 1502 // 更新兑换活动
@@ -1533,7 +1559,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC @@ -1533,7 +1559,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC
1533 1559
1534 if updateExchangeCashActivityCommand.ExchangedSuMoney - person.ExchangedSuMoney > 0 { 1560 if updateExchangeCashActivityCommand.ExchangedSuMoney - person.ExchangedSuMoney > 0 {
1535 operationSuMoneyCommand.SuMoney = math.Abs(updateExchangeCashActivityCommand.ExchangedSuMoney - person.ExchangedSuMoney) 1561 operationSuMoneyCommand.SuMoney = math.Abs(updateExchangeCashActivityCommand.ExchangedSuMoney - person.ExchangedSuMoney)
1536 - operationSuMoneyCommand.OperationType = 5 1562 + operationSuMoneyCommand.OperationType = 1
1537 } else { 1563 } else {
1538 operationSuMoneyCommand.SuMoney = math.Abs(updateExchangeCashActivityCommand.ExchangedSuMoney - person.ExchangedSuMoney) 1564 operationSuMoneyCommand.SuMoney = math.Abs(updateExchangeCashActivityCommand.ExchangedSuMoney - person.ExchangedSuMoney)
1539 operationSuMoneyCommand.OperationType = 3 1565 operationSuMoneyCommand.OperationType = 3
@@ -1579,6 +1605,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC @@ -1579,6 +1605,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC
1579 } 1605 }
1580 1606
1581 systemExchangedSuMoney := systemSuMoneyStatistics["systemExchangedSuMoney"].(float64) 1607 systemExchangedSuMoney := systemSuMoneyStatistics["systemExchangedSuMoney"].(float64)
  1608 + systemUnExchangeSuMoney := systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64)
1582 1609
1583 var cashPoolRepository domain.CashPoolRepository 1610 var cashPoolRepository domain.CashPoolRepository
1584 if value, err := factory.CreateCashPoolRepository(map[string] interface{} { 1611 if value, err := factory.CreateCashPoolRepository(map[string] interface{} {
@@ -1613,6 +1640,8 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC @@ -1613,6 +1640,8 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC
1613 ExchangedCash: systemUnExchangeCash, 1640 ExchangedCash: systemUnExchangeCash,
1614 UnExchangeCash: systemUnExchangeCash, 1641 UnExchangeCash: systemUnExchangeCash,
1615 Rate: newRate, 1642 Rate: newRate,
  1643 + ExchangedSuMoney: systemExchangedSuMoney,
  1644 + UnExchangeSuMoney: systemUnExchangeSuMoney,
1616 } 1645 }
1617 1646
1618 // 更新现金池 1647 // 更新现金池
@@ -1634,7 +1663,6 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC @@ -1634,7 +1663,6 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC
1634 if err := transactionContext.CommitTransaction(); err != nil { 1663 if err := transactionContext.CommitTransaction(); err != nil {
1635 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 1664 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
1636 } 1665 }
1637 -  
1638 return personUpdated, nil 1666 return personUpdated, nil
1639 } 1667 }
1640 } 1668 }
@@ -160,7 +160,7 @@ func (dao *EmployeeDao) CalculateSystemSuMoney(companyId int64) (map[string] int @@ -160,7 +160,7 @@ func (dao *EmployeeDao) CalculateSystemSuMoney(companyId int64) (map[string] int
160 ColumnExpr("sum(su_money_transaction_record.su_money) AS system_changed_su_money"). 160 ColumnExpr("sum(su_money_transaction_record.su_money) AS system_changed_su_money").
161 Where("e.company_id = ?", companyId). 161 Where("e.company_id = ?", companyId).
162 Where("e.status = ?", 1). 162 Where("e.status = ?", 1).
163 - Where(`su_money_transaction_record.record_type = ?`, 5). 163 + Where(`su_money_transaction_record.record_type = ?`, 1).
164 Select(&systemExchangedSuMoney); err != nil { 164 Select(&systemExchangedSuMoney); err != nil {
165 return nil, err 165 return nil, err
166 } 166 }
@@ -441,11 +441,11 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter @@ -441,11 +441,11 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter
441 queryContributions = queryContributions.ColumnExpr("su_money_transaction_records.employee->>'employeeName' AS employee_name") 441 queryContributions = queryContributions.ColumnExpr("su_money_transaction_records.employee->>'employeeName' AS employee_name")
442 queryContributions = queryContributions.ColumnExpr(`(sum(su_money_transaction_records.su_money) - t.employee_contributions_decrease) AS employees_contributions`) 442 queryContributions = queryContributions.ColumnExpr(`(sum(su_money_transaction_records.su_money) - t.employee_contributions_decrease) AS employees_contributions`)
443 queryContributions = queryContributions.ColumnExpr("ROW_NUMBER() OVER (ORDER BY sum(su_money_transaction_records.su_money) - t.employee_contributions_decrease DESC) AS ranking") 443 queryContributions = queryContributions.ColumnExpr("ROW_NUMBER() OVER (ORDER BY sum(su_money_transaction_records.su_money) - t.employee_contributions_decrease DESC) AS ranking")
  444 + queryContributions = queryContributions.Where(`e.status = ?`, 1)
  445 + queryContributions = queryContributions.Where(`su_money_transaction_records.record_type IN (?)`, pg.In([]int{2, 3}))
444 if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) { 446 if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
445 queryContributions = queryContributions.Where("e.company_id = ?", companyId) 447 queryContributions = queryContributions.Where("e.company_id = ?", companyId)
446 } 448 }
447 - queryContributions = queryContributions.Where(`e.status = ?`, 1)  
448 - queryContributions = queryContributions.Where(`su_money_transaction_records.record_type IN (?)`, pg.In([]int{2, 3}))  
449 if startTime, ok := queryOptions["startTime"]; ok { 449 if startTime, ok := queryOptions["startTime"]; ok {
450 queryContributions = queryContributions.Where(`su_money_transaction_records.create_time > ?`, startTime) 450 queryContributions = queryContributions.Where(`su_money_transaction_records.create_time > ?`, startTime)
451 } 451 }
@@ -25,8 +25,8 @@ func (repository *ExchangeCashPersonListRepository) Save(exchangeCashList *domai @@ -25,8 +25,8 @@ func (repository *ExchangeCashPersonListRepository) Save(exchangeCashList *domai
25 } else { 25 } else {
26 if _, err := tx.QueryOne( 26 if _, err := tx.QueryOne(
27 pg.Scan(&exchangeCashList.ListId, &exchangeCashList.ExchangeCashActivityId, &exchangeCashList.EmployeeInfo.Uid, &exchangeCashList.EmployeeInfo.EmployeeName, &exchangeCashList.EmployeeInfo.EmployeeAccount, &exchangeCashList.ExchangedSuMoney, &exchangeCashList.ExchangedCash), 27 pg.Scan(&exchangeCashList.ListId, &exchangeCashList.ExchangeCashActivityId, &exchangeCashList.EmployeeInfo.Uid, &exchangeCashList.EmployeeInfo.EmployeeName, &exchangeCashList.EmployeeInfo.EmployeeAccount, &exchangeCashList.ExchangedSuMoney, &exchangeCashList.ExchangedCash),
28 - "UPDATE exchange_cash_person_lists SET exchanged_su_money=? WHERE id=? RETURNING id, activity_id, uid, employee_name, employee_account, exchanged_su_money, exchanged_cash",  
29 - exchangeCashList.ExchangedSuMoney, exchangeCashList.ListId); err != nil { 28 + "UPDATE exchange_cash_person_lists SET exchanged_su_money=?, exchanged_cash=? WHERE id=? RETURNING id, activity_id, uid, employee_name, employee_account, exchanged_su_money, exchanged_cash",
  29 + exchangeCashList.ExchangedSuMoney, exchangeCashList.ExchangedCash, exchangeCashList.ListId); err != nil {
30 return exchangeCashList, err 30 return exchangeCashList, err
31 } 31 }
32 } 32 }