作者 陈志颖

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

... ... @@ -1401,7 +1401,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
createExchangeCashPersonCommand.PersonName,
createExchangeCashPersonCommand.PersonAccount,
createExchangeCashPersonCommand.ExchangedSuMoney,
"当前未创建任务兑换活动",
"当前未创建素币兑换活动",
}
failureDataList = append(failureDataList, row)
continue
... ... @@ -1461,7 +1461,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
createExchangeCashPersonCommand.PersonName,
createExchangeCashPersonCommand.PersonAccount,
createExchangeCashPersonCommand.ExchangedSuMoney,
"无效的导入员工",
"无效的员工",
}
failureDataList = append(failureDataList, row)
continue
... ... @@ -1484,25 +1484,25 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
}
failureDataList = append(failureDataList, row)
continue
} else {
if len(peopleFound) != 0 {
peopleFoundExchangedSuMoney := peopleFound[0].ExchangedSuMoney
// 判断该员工兑换的素币是否超过本人持有的素币
if createExchangeCashPersonCommand.ExchangedSuMoney > peopleFoundExchangedSuMoney {
if employeeFoundSuMoney < (createExchangeCashPersonCommand.ExchangedSuMoney - peopleFoundExchangedSuMoney) {
row := []interface{}{
createExchangeCashPersonCommand.PersonName,
createExchangeCashPersonCommand.PersonAccount,
createExchangeCashPersonCommand.ExchangedSuMoney,
"当前兑换素币超过本人持有的素币值",
}
failureDataList = append(failureDataList, row)
continue
}
if len(peopleFound) != 0 {
peopleFoundExchangedSuMoney := peopleFound[0].ExchangedSuMoney
// 判断该员工兑换的素币是否超过本人持有的素币
if createExchangeCashPersonCommand.ExchangedSuMoney > peopleFoundExchangedSuMoney {
if employeeFoundSuMoney < (createExchangeCashPersonCommand.ExchangedSuMoney - peopleFoundExchangedSuMoney) {
row := []interface{}{
createExchangeCashPersonCommand.PersonName,
createExchangeCashPersonCommand.PersonAccount,
createExchangeCashPersonCommand.ExchangedSuMoney,
"当前兑换素币超过本人持有的素币值",
}
failureDataList = append(failureDataList, row)
continue
}
}
}
if len(peopleFound) > 0 { // 当前导入员工在素币兑换清单中,判断追加素币兑换或撤回素币兑换
// 获取当前员工已兑换素币
personFoundExchangedSuMoney := peopleFound[0].ExchangedSuMoney
... ... @@ -1538,7 +1538,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
}
// 保存兑换素币清单更新
personUpdated, err := exchangeCashPersonListRepository.Save(peopleFound[0])
_, err := exchangeCashPersonListRepository.Save(peopleFound[0])
if err != nil {
row := []interface{}{
createExchangeCashPersonCommand.PersonName,
... ... @@ -1671,7 +1671,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
if systemExchangedSuMoney == 0 {
newRate = 0
} else {
newRate = (cashPoolFoundExchangedCash + personUpdated.ExchangedCash) / systemExchangedSuMoney
newRate = (cashPoolFoundExchangedCash - cashDecrement) / systemExchangedSuMoney
}
// 更新现金池命令
... ... @@ -1748,7 +1748,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
}
// 保存兑换素币清单更新
personUpdated, err := exchangeCashPersonListRepository.Save(peopleFound[0])
_, err := exchangeCashPersonListRepository.Save(peopleFound[0])
if err != nil {
row := []interface{}{
createExchangeCashPersonCommand.PersonName,
... ... @@ -1881,7 +1881,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
if systemExchangedSuMoney == 0 {
newRate = 0
} else {
newRate = (cashPoolFoundExchangedCash + personUpdated.ExchangedCash) / systemExchangedSuMoney
newRate = (cashPoolFoundExchangedCash + cashIncrement) / systemExchangedSuMoney
}
// 更新现金池命令
... ... @@ -2345,13 +2345,6 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC
cashPoolFoundUnExchangeCash := cashPoolsFound[0].UnExchangeCash
cashPoolFoundExchangedCash := cashPoolsFound[0].ExchangedCash
// 判断兑换活动的现金是否超过现金池未兑换现金
//if activityUpdated.ExchangedSuMoney * updateExchangeCashActivityCommand.ExchangeRate > cashPoolFoundUnExchangeCash {
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "已超过投入现金池未兑换现金")
//}
// TODO
// 判断是否超过平台未兑换现金
if activityUpdated.ExchangedSuMoney > activityFoundExchangedSuMoney {
if (activityUpdated.ExchangedSuMoney - activityFoundExchangedSuMoney) * activityUpdated.Rate > cashPoolFoundUnExchangeCash {
... ... @@ -2359,7 +2352,6 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC
}
}
// 获取平台素币兑换情况
systemSuMoneyStatistics, err := employeeDao.CalculateSystemSuMoney(activityFound.CompanyId)
if err != nil {
... ...