|
@@ -175,6 +175,31 @@ func (cashPoolService *CashPoolService) GetCashPool(getCashPoolQuery *query.GetC |
|
@@ -175,6 +175,31 @@ func (cashPoolService *CashPoolService) GetCashPool(getCashPoolQuery *query.GetC |
175
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的公司id")
|
175
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的公司id")
|
176
|
}
|
176
|
}
|
177
|
|
177
|
|
|
|
178
|
+ // 获取上次兑换活动兑换汇率
|
|
|
179
|
+ var exchangeActivityRepository domain.ExchangeActivityRepository
|
|
|
180
|
+ if value, err := factory.CreateExchangeCashActivityRepository(map[string]interface{}{
|
|
|
181
|
+ "transactionContext": transactionContext,
|
|
|
182
|
+ }); err != nil {
|
|
|
183
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
184
|
+ } else {
|
|
|
185
|
+ exchangeActivityRepository = value
|
|
|
186
|
+ }
|
|
|
187
|
+
|
|
|
188
|
+ listExchangeCashActivityQuery := map[string]interface{}{
|
|
|
189
|
+ "companyId": getCashPoolQuery.CompanyId,
|
|
|
190
|
+ }
|
|
|
191
|
+
|
|
|
192
|
+ var lastActivityRate float64
|
|
|
193
|
+ if count, activities, err := exchangeActivityRepository.Find(listExchangeCashActivityQuery); err != nil {
|
|
|
194
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
195
|
+ } else {
|
|
|
196
|
+ if count > 1 {
|
|
|
197
|
+ lastActivityRate = activities[1].Rate
|
|
|
198
|
+ } else { // 未查询到相关兑换活动
|
|
|
199
|
+ lastActivityRate = 0
|
|
|
200
|
+ }
|
|
|
201
|
+ }
|
|
|
202
|
+
|
178
|
var employeeDao *dao.EmployeeDao
|
203
|
var employeeDao *dao.EmployeeDao
|
179
|
if value, err := factory.CreateEmployeeDao(map[string]interface{}{
|
204
|
if value, err := factory.CreateEmployeeDao(map[string]interface{}{
|
180
|
"transactionContext": transactionContext,
|
205
|
"transactionContext": transactionContext,
|
|
@@ -211,7 +236,7 @@ func (cashPoolService *CashPoolService) GetCashPool(getCashPoolQuery *query.GetC |
|
@@ -211,7 +236,7 @@ func (cashPoolService *CashPoolService) GetCashPool(getCashPoolQuery *query.GetC |
211
|
if err := transactionContext.CommitTransaction(); err != nil {
|
236
|
if err := transactionContext.CommitTransaction(); err != nil {
|
212
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
237
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
213
|
}
|
238
|
}
|
214
|
-
|
239
|
+ // 现金池为空时处理
|
215
|
if count == 0 {
|
240
|
if count == 0 {
|
216
|
return map[string] interface{} {
|
241
|
return map[string] interface{} {
|
217
|
"cashPoolId": 0,
|
242
|
"cashPoolId": 0,
|
|
@@ -221,10 +246,12 @@ func (cashPoolService *CashPoolService) GetCashPool(getCashPoolQuery *query.GetC |
|
@@ -221,10 +246,12 @@ func (cashPoolService *CashPoolService) GetCashPool(getCashPoolQuery *query.GetC |
221
|
"unExchangeCash": 0,
|
246
|
"unExchangeCash": 0,
|
222
|
"exchangedSuMoney": systemExchangedSuMoney,
|
247
|
"exchangedSuMoney": systemExchangedSuMoney,
|
223
|
"unExchangeSuMoney": systemUnExchangeSuMoney,
|
248
|
"unExchangeSuMoney": systemUnExchangeSuMoney,
|
224
|
- "rate": 0,
|
249
|
+ "rate": 0, // 平均兑换汇率
|
|
|
250
|
+ "lastRate": 0, // 上期活动兑换汇率
|
225
|
"createTime": time.Now(),
|
251
|
"createTime": time.Now(),
|
226
|
}, nil
|
252
|
}, nil
|
227
|
} else {
|
253
|
} else {
|
|
|
254
|
+ cashPools[0].LastRate = lastActivityRate
|
228
|
return cashPools[0], nil
|
255
|
return cashPools[0], nil
|
229
|
}
|
256
|
}
|
230
|
}
|
257
|
}
|
|
@@ -264,7 +291,6 @@ func (cashPoolService *CashPoolService) CreateExchangeCashActivity(createExchang |
|
@@ -264,7 +291,6 @@ func (cashPoolService *CashPoolService) CreateExchangeCashActivity(createExchang |
264
|
CreateTime: time.Now(),
|
291
|
CreateTime: time.Now(),
|
265
|
}
|
292
|
}
|
266
|
|
293
|
|
267
|
-
|
|
|
268
|
// 倒计时结束
|
294
|
// 倒计时结束
|
269
|
if t2.Before(t1) {
|
295
|
if t2.Before(t1) {
|
270
|
newActivity.CountDown = 0
|
296
|
newActivity.CountDown = 0
|