...
|
...
|
@@ -786,6 +786,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
|
|
if err := updateExchangeCashActivityCommand.ValidateCommand(); err != nil {
|
|
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
...
|
...
|
@@ -856,13 +857,33 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
if len(cashPoolsFound) == 0 {
|
|
|
if len(cashPoolsFound) == 0 { // 现金池不存在
|
|
|
var t1 = time.Now().Local()
|
|
|
var t2 = updateExchangeCashActivityCommand.Deadline.Local()
|
|
|
|
|
|
updateExchangeCashActivityCommand.CountDown = int64(math.Ceil(t2.Sub(t1).Hours() / 24))
|
|
|
updateExchangeCashActivityCommand.Deadline = time.Date(t2.Year(), t2.Month(), t2.Day(), 23, 59, 59, 0, time.Local)
|
|
|
|
|
|
if _, activitiesFound, err := exchangeCashActivityRepository.FindAll(map[string]interface{}{
|
|
|
"companyId": activityFound.CompanyId,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
var currentExchangeCashActivityIndex int
|
|
|
for i, activity := range activitiesFound {
|
|
|
if activityFound.Deadline.Local().Equal(activity.Deadline.Local()) {
|
|
|
currentExchangeCashActivityIndex = i
|
|
|
}
|
|
|
}
|
|
|
for i, activity := range activitiesFound {
|
|
|
if i != currentExchangeCashActivityIndex {
|
|
|
if updateExchangeCashActivityCommand.Deadline.Local().Equal(activity.Deadline.Local()) {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "兑换活动截止时间不能重合")
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 更新兑换活动
|
|
|
if err := activityFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashActivityCommand)); err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
...
|
...
|
@@ -882,6 +903,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
|
|
return activityUpdated, nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
cashPoolFoundUnExchangeCash := cashPoolsFound[0].UnExchangeCash
|
|
|
cashPoolFoundExchangedCash := cashPoolsFound[0].ExchangedCash
|
|
|
|
...
|
...
|
|