...
|
...
|
@@ -97,8 +97,6 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co |
|
|
systemExchangedSuMoney := systemSuMoneyStatistics["systemExchangedSuMoney"].(float64) // 平台已兑换素币
|
|
|
systemUnExchangeSuMoney := systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64) // 平台未兑换素币
|
|
|
|
|
|
|
|
|
|
|
|
// 获取当前公司现金池
|
|
|
count, cashPools, err := cashPoolRepository.Find(tool_funs.SimpleStructToMap(createCashPoolCommand))
|
|
|
if err != nil {
|
...
|
...
|
@@ -363,13 +361,13 @@ func (cashPoolService *CashPoolService) CreateExchangeCashActivity(createExchang |
|
|
t2 := time.Date(deadline.Year(), deadline.Month(), deadline.Day(), 23, 59, 59, 0, time.Local)
|
|
|
|
|
|
// 获取该公司所有兑换现金活动
|
|
|
if _, activities, err := exchangeActivityRepository.FindAll(map[string]interface{}{
|
|
|
if _, activitiesFound, err := exchangeActivityRepository.FindAll(map[string]interface{}{
|
|
|
"companyId": createExchangeCashActivityCommand.CompanyId,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
for _, activity := range activities {
|
|
|
if t2.Format("2006-01-02") == activity.Deadline.Local().Format("2006-01-02") {
|
|
|
for _, activityFound := range activitiesFound {
|
|
|
if t2.Equal(activityFound.Deadline.Local()) {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "兑换活动截止时间不能重合")
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -930,10 +928,10 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
|
|
systemExchangedSuMoney := systemSuMoneyStatistics["systemExchangedSuMoney"].(float64)
|
|
|
systemUnExchangeSuMoney := systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64)
|
|
|
|
|
|
// 更新兑换活动命令已兑换现金
|
|
|
updateExchangeCashActivityCommand.ExchangedCash = updateExchangeCashActivityCommand.ExchangeRate * activityFoundExchangedSuMoney
|
|
|
deadline := updateExchangeCashActivityCommand.Deadline.Local()
|
|
|
updateExchangeCashActivityCommand.Deadline = time.Date(deadline.Year(), deadline.Month(), deadline.Day(), 23, 59, 59, 0, time.Local)
|
|
|
//// 更新兑换活动命令已兑换现金
|
|
|
//updateExchangeCashActivityCommand.ExchangedCash = updateExchangeCashActivityCommand.ExchangeRate * activityFoundExchangedSuMoney
|
|
|
//deadline := updateExchangeCashActivityCommand.Deadline.Local()
|
|
|
//updateExchangeCashActivityCommand.Deadline = time.Date(deadline.Year(), deadline.Month(), deadline.Day(), 23, 59, 59, 0, time.Local)
|
|
|
|
|
|
// 计算平均兑换汇率
|
|
|
var rate float64
|
...
|
...
|
@@ -968,12 +966,12 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
|
|
if cashPoolUpdated == nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
} else { // 更新兑换活动时间
|
|
|
updateExchangeCashActivityCommand.ExchangedCash = activityFoundExchangedCash
|
|
|
deadline := updateExchangeCashActivityCommand.Deadline.Local()
|
|
|
updateExchangeCashActivityCommand.Deadline = time.Date(deadline.Year(), deadline.Month(), deadline.Day(), 23, 59, 59, 0, time.Local)
|
|
|
}
|
|
|
|
|
|
updateExchangeCashActivityCommand.ExchangedCash = activityFoundExchangedCash
|
|
|
deadline := updateExchangeCashActivityCommand.Deadline.Local()
|
|
|
updateExchangeCashActivityCommand.Deadline = time.Date(deadline.Year(), deadline.Month(), deadline.Day(), 23, 59, 59, 0, time.Local)
|
|
|
|
|
|
// 更新兑换活动倒计时
|
|
|
t1 := time.Now().Local()
|
|
|
//var t2 = activityFound.Deadline.Local()
|
...
|
...
|
@@ -991,19 +989,19 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
|
|
var currentExchangeCashActivityIndex int
|
|
|
|
|
|
// 获取该公司所有兑换现金活动
|
|
|
if _, activities, err := exchangeCashActivityRepository.FindAll(map[string]interface{}{
|
|
|
if _, activitiesFound, err := exchangeCashActivityRepository.FindAll(map[string]interface{}{
|
|
|
"companyId": activityFound.CompanyId,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
for i, activity := range activities {
|
|
|
if activityFound.Deadline.Local().Format("2006-01-02") == activity.Deadline.Local().Format("2006-01-02") {
|
|
|
for i, activity := range activitiesFound {
|
|
|
if activityFound.Deadline.Local().Equal(activity.Deadline.Local()) {
|
|
|
currentExchangeCashActivityIndex = i
|
|
|
}
|
|
|
}
|
|
|
for i, activity := range activities {
|
|
|
for i, activity := range activitiesFound {
|
|
|
if i != currentExchangeCashActivityIndex {
|
|
|
if updateExchangeCashActivityCommand.Deadline.Local().Format("2006-01-02") == activity.Deadline.Local().Format("2006-01-02") {
|
|
|
if updateExchangeCashActivityCommand.Deadline.Local().Equal(activity.Deadline.Local()) {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "兑换活动截止时间不能重合")
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -2350,13 +2348,6 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC |
|
|
cashPoolFoundExchangedCash := cashPoolsFound[0].ExchangedCash
|
|
|
|
|
|
// 判断是否超过平台未兑换现金
|
|
|
//if activityUpdated.ExchangedSuMoney > activityFoundExchangedSuMoney {
|
|
|
// if (activityUpdated.ExchangedSuMoney - activityFoundExchangedSuMoney) * activityUpdated.Rate > cashPoolFoundUnExchangeCash {
|
|
|
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "已超过投入现金池的未兑换现金")
|
|
|
// }
|
|
|
//}
|
|
|
|
|
|
// 判断是否超过平台未兑换现金
|
|
|
if createExchangeCashPersonCommand.ExchangedSuMoney * activityFound.Rate > cashPoolFoundUnExchangeCash {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "已超过投入现金池的未兑换现金")
|
|
|
}
|
...
|
...
|
@@ -2646,7 +2637,6 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC |
|
|
getEmployee := map[string]interface{}{
|
|
|
"uid": personFound.EmployeeInfo.Uid,
|
|
|
"companyId": activityFound.CompanyId,
|
|
|
"status": 1,
|
|
|
}
|
|
|
|
|
|
// 判断当前员工是否有效
|
...
|
...
|
|