作者 陈志颖

fix:导入素币兑换清单汇率计算问题

@@ -1401,7 +1401,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1401,7 +1401,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1401 createExchangeCashPersonCommand.PersonName, 1401 createExchangeCashPersonCommand.PersonName,
1402 createExchangeCashPersonCommand.PersonAccount, 1402 createExchangeCashPersonCommand.PersonAccount,
1403 createExchangeCashPersonCommand.ExchangedSuMoney, 1403 createExchangeCashPersonCommand.ExchangedSuMoney,
1404 - "当前未创建任务兑换活动", 1404 + "当前未创建素币兑换活动",
1405 } 1405 }
1406 failureDataList = append(failureDataList, row) 1406 failureDataList = append(failureDataList, row)
1407 continue 1407 continue
@@ -1461,7 +1461,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1461,7 +1461,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1461 createExchangeCashPersonCommand.PersonName, 1461 createExchangeCashPersonCommand.PersonName,
1462 createExchangeCashPersonCommand.PersonAccount, 1462 createExchangeCashPersonCommand.PersonAccount,
1463 createExchangeCashPersonCommand.ExchangedSuMoney, 1463 createExchangeCashPersonCommand.ExchangedSuMoney,
1464 - "无效的导入员工", 1464 + "无效的员工",
1465 } 1465 }
1466 failureDataList = append(failureDataList, row) 1466 failureDataList = append(failureDataList, row)
1467 continue 1467 continue
@@ -1484,25 +1484,25 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1484,25 +1484,25 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1484 } 1484 }
1485 failureDataList = append(failureDataList, row) 1485 failureDataList = append(failureDataList, row)
1486 continue 1486 continue
1487 - } else {  
1488 - if len(peopleFound) != 0 {  
1489 - peopleFoundExchangedSuMoney := peopleFound[0].ExchangedSuMoney  
1490 - // 判断该员工兑换的素币是否超过本人持有的素币  
1491 - if createExchangeCashPersonCommand.ExchangedSuMoney > peopleFoundExchangedSuMoney {  
1492 - if employeeFoundSuMoney < (createExchangeCashPersonCommand.ExchangedSuMoney - peopleFoundExchangedSuMoney) {  
1493 - row := []interface{}{  
1494 - createExchangeCashPersonCommand.PersonName,  
1495 - createExchangeCashPersonCommand.PersonAccount,  
1496 - createExchangeCashPersonCommand.ExchangedSuMoney,  
1497 - "当前兑换素币超过本人持有的素币值",  
1498 - }  
1499 - failureDataList = append(failureDataList, row)  
1500 - continue 1487 + }
  1488 + if len(peopleFound) != 0 {
  1489 + peopleFoundExchangedSuMoney := peopleFound[0].ExchangedSuMoney
  1490 + // 判断该员工兑换的素币是否超过本人持有的素币
  1491 + if createExchangeCashPersonCommand.ExchangedSuMoney > peopleFoundExchangedSuMoney {
  1492 + if employeeFoundSuMoney < (createExchangeCashPersonCommand.ExchangedSuMoney - peopleFoundExchangedSuMoney) {
  1493 + row := []interface{}{
  1494 + createExchangeCashPersonCommand.PersonName,
  1495 + createExchangeCashPersonCommand.PersonAccount,
  1496 + createExchangeCashPersonCommand.ExchangedSuMoney,
  1497 + "当前兑换素币超过本人持有的素币值",
1501 } 1498 }
  1499 + failureDataList = append(failureDataList, row)
  1500 + continue
1502 } 1501 }
1503 } 1502 }
1504 } 1503 }
1505 1504
  1505 +
1506 if len(peopleFound) > 0 { // 当前导入员工在素币兑换清单中,判断追加素币兑换或撤回素币兑换 1506 if len(peopleFound) > 0 { // 当前导入员工在素币兑换清单中,判断追加素币兑换或撤回素币兑换
1507 // 获取当前员工已兑换素币 1507 // 获取当前员工已兑换素币
1508 personFoundExchangedSuMoney := peopleFound[0].ExchangedSuMoney 1508 personFoundExchangedSuMoney := peopleFound[0].ExchangedSuMoney
@@ -1538,7 +1538,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1538,7 +1538,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1538 } 1538 }
1539 1539
1540 // 保存兑换素币清单更新 1540 // 保存兑换素币清单更新
1541 - personUpdated, err := exchangeCashPersonListRepository.Save(peopleFound[0]) 1541 + _, err := exchangeCashPersonListRepository.Save(peopleFound[0])
1542 if err != nil { 1542 if err != nil {
1543 row := []interface{}{ 1543 row := []interface{}{
1544 createExchangeCashPersonCommand.PersonName, 1544 createExchangeCashPersonCommand.PersonName,
@@ -1671,7 +1671,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1671,7 +1671,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1671 if systemExchangedSuMoney == 0 { 1671 if systemExchangedSuMoney == 0 {
1672 newRate = 0 1672 newRate = 0
1673 } else { 1673 } else {
1674 - newRate = (cashPoolFoundExchangedCash + personUpdated.ExchangedCash) / systemExchangedSuMoney 1674 + newRate = (cashPoolFoundExchangedCash - cashDecrement) / systemExchangedSuMoney
1675 } 1675 }
1676 1676
1677 // 更新现金池命令 1677 // 更新现金池命令
@@ -1748,7 +1748,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1748,7 +1748,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1748 } 1748 }
1749 1749
1750 // 保存兑换素币清单更新 1750 // 保存兑换素币清单更新
1751 - personUpdated, err := exchangeCashPersonListRepository.Save(peopleFound[0]) 1751 + _, err := exchangeCashPersonListRepository.Save(peopleFound[0])
1752 if err != nil { 1752 if err != nil {
1753 row := []interface{}{ 1753 row := []interface{}{
1754 createExchangeCashPersonCommand.PersonName, 1754 createExchangeCashPersonCommand.PersonName,
@@ -1881,7 +1881,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1881,7 +1881,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1881 if systemExchangedSuMoney == 0 { 1881 if systemExchangedSuMoney == 0 {
1882 newRate = 0 1882 newRate = 0
1883 } else { 1883 } else {
1884 - newRate = (cashPoolFoundExchangedCash + personUpdated.ExchangedCash) / systemExchangedSuMoney 1884 + newRate = (cashPoolFoundExchangedCash + cashIncrement) / systemExchangedSuMoney
1885 } 1885 }
1886 1886
1887 // 更新现金池命令 1887 // 更新现金池命令
@@ -2345,13 +2345,6 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC @@ -2345,13 +2345,6 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC
2345 cashPoolFoundUnExchangeCash := cashPoolsFound[0].UnExchangeCash 2345 cashPoolFoundUnExchangeCash := cashPoolsFound[0].UnExchangeCash
2346 cashPoolFoundExchangedCash := cashPoolsFound[0].ExchangedCash 2346 cashPoolFoundExchangedCash := cashPoolsFound[0].ExchangedCash
2347 2347
2348 - // 判断兑换活动的现金是否超过现金池未兑换现金  
2349 - //if activityUpdated.ExchangedSuMoney * updateExchangeCashActivityCommand.ExchangeRate > cashPoolFoundUnExchangeCash {  
2350 - // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "已超过投入现金池未兑换现金")  
2351 - //}  
2352 -  
2353 - // TODO  
2354 -  
2355 // 判断是否超过平台未兑换现金 2348 // 判断是否超过平台未兑换现金
2356 if activityUpdated.ExchangedSuMoney > activityFoundExchangedSuMoney { 2349 if activityUpdated.ExchangedSuMoney > activityFoundExchangedSuMoney {
2357 if (activityUpdated.ExchangedSuMoney - activityFoundExchangedSuMoney) * activityUpdated.Rate > cashPoolFoundUnExchangeCash { 2350 if (activityUpdated.ExchangedSuMoney - activityFoundExchangedSuMoney) * activityUpdated.Rate > cashPoolFoundUnExchangeCash {
@@ -2359,7 +2352,6 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC @@ -2359,7 +2352,6 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC
2359 } 2352 }
2360 } 2353 }
2361 2354
2362 -  
2363 // 获取平台素币兑换情况 2355 // 获取平台素币兑换情况
2364 systemSuMoneyStatistics, err := employeeDao.CalculateSystemSuMoney(activityFound.CompanyId) 2356 systemSuMoneyStatistics, err := employeeDao.CalculateSystemSuMoney(activityFound.CompanyId)
2365 if err != nil { 2357 if err != nil {