|
@@ -16,6 +16,8 @@ import ( |
|
@@ -16,6 +16,8 @@ import ( |
16
|
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/suMoney/command"
|
16
|
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/suMoney/command"
|
17
|
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/suMoney/query"
|
17
|
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/suMoney/query"
|
18
|
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
|
18
|
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
|
|
|
19
|
+
|
|
|
20
|
+ "github.com/shopspring/decimal"
|
19
|
)
|
21
|
)
|
20
|
|
22
|
|
21
|
// 现金池服务
|
23
|
// 现金池服务
|
|
@@ -27,6 +29,7 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co |
|
@@ -27,6 +29,7 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co |
27
|
if err := createCashPoolCommand.ValidateCommand(); err != nil {
|
29
|
if err := createCashPoolCommand.ValidateCommand(); err != nil {
|
28
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
30
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
29
|
}
|
31
|
}
|
|
|
32
|
+
|
30
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
33
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
31
|
if err != nil {
|
34
|
if err != nil {
|
32
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
35
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
@@ -116,7 +119,7 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co |
|
@@ -116,7 +119,7 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co |
116
|
if systemExchangedSuMoney == 0 {
|
119
|
if systemExchangedSuMoney == 0 {
|
117
|
newRate = 0
|
120
|
newRate = 0
|
118
|
} else {
|
121
|
} else {
|
119
|
- newRate = cashPoolExchangeCash / systemExchangedSuMoney
|
122
|
+ newRate, _ = decimal.NewFromFloat(cashPoolExchangeCash).Div(decimal.NewFromFloat(systemExchangedSuMoney)).Float64()
|
120
|
}
|
123
|
}
|
121
|
|
124
|
|
122
|
// 获取上次兑换活动兑换汇率查询
|
125
|
// 获取上次兑换活动兑换汇率查询
|
|
@@ -137,12 +140,15 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co |
|
@@ -137,12 +140,15 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co |
137
|
}
|
140
|
}
|
138
|
}
|
141
|
}
|
139
|
|
142
|
|
|
|
143
|
+ unExchangeCash, _ := decimal.NewFromFloat(cashPoolUnExchangeCash).Add(decimal.NewFromFloat(createCashPoolCommand.Cash).Sub(decimal.NewFromFloat(cashPoolCash))).Float64()
|
|
|
144
|
+
|
140
|
// 更新现金池命令
|
145
|
// 更新现金池命令
|
141
|
updateCashPoolCommand := &command.UpdateCashPoolCommand{
|
146
|
updateCashPoolCommand := &command.UpdateCashPoolCommand{
|
142
|
CashPoolId: cashPools[0].CashPoolId,
|
147
|
CashPoolId: cashPools[0].CashPoolId,
|
143
|
Cash: createCashPoolCommand.Cash,
|
148
|
Cash: createCashPoolCommand.Cash,
|
144
|
ExchangedCash: cashPoolExchangeCash,
|
149
|
ExchangedCash: cashPoolExchangeCash,
|
145
|
- UnExchangeCash: cashPoolUnExchangeCash + (createCashPoolCommand.Cash - cashPoolCash),
|
150
|
+ //UnExchangeCash: cashPoolUnExchangeCash + (createCashPoolCommand.Cash - cashPoolCash),
|
|
|
151
|
+ UnExchangeCash: unExchangeCash,
|
146
|
ExchangedSuMoney: systemExchangedSuMoney,
|
152
|
ExchangedSuMoney: systemExchangedSuMoney,
|
147
|
UnExchangeSuMoney: systemUnExchangeSuMoney,
|
153
|
UnExchangeSuMoney: systemUnExchangeSuMoney,
|
148
|
Rate: newRate,
|
154
|
Rate: newRate,
|
|
@@ -161,15 +167,40 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co |
|
@@ -161,15 +167,40 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co |
161
|
if err := transactionContext.CommitTransaction(); err != nil {
|
167
|
if err := transactionContext.CommitTransaction(); err != nil {
|
162
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
168
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
163
|
}
|
169
|
}
|
164
|
- cashPool.Rate, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", cashPool.Rate), 64)
|
|
|
165
|
- cashPool.UnExchangeCash, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", cashPool.UnExchangeCash), 64)
|
|
|
166
|
- cashPool.ExchangedSuMoney, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", cashPool.ExchangedSuMoney), 64)
|
|
|
167
|
- cashPool.UnExchangeSuMoney, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", cashPool.UnExchangeSuMoney), 64)
|
|
|
168
|
- cashPool.ExchangedCash, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", cashPool.ExchangedCash), 64)
|
|
|
169
|
- cashPool.LastRate, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", cashPool.LastRate), 64)
|
170
|
+ //cashPool.Rate, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", cashPool.Rate), 64)
|
|
|
171
|
+ //cashPool.UnExchangeCash, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", cashPool.UnExchangeCash), 64)
|
|
|
172
|
+ //cashPool.ExchangedSuMoney, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", cashPool.ExchangedSuMoney), 64)
|
|
|
173
|
+ //cashPool.UnExchangeSuMoney, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", cashPool.UnExchangeSuMoney), 64)
|
|
|
174
|
+ //cashPool.ExchangedCash, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", cashPool.ExchangedCash), 64)
|
|
|
175
|
+ //cashPool.LastRate, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", cashPool.LastRate), 64)
|
|
|
176
|
+ cashPool.Rate, _ = decimal.NewFromFloatWithExponent(cashPool.Rate, -2).Float64()
|
|
|
177
|
+ cashPool.UnExchangeCash, _ = decimal.NewFromFloatWithExponent(cashPool.UnExchangeCash, -2).Float64()
|
|
|
178
|
+ cashPool.ExchangedSuMoney, _ = decimal.NewFromFloatWithExponent(cashPool.ExchangedSuMoney, -2).Float64()
|
|
|
179
|
+ cashPool.UnExchangeSuMoney, _ = decimal.NewFromFloatWithExponent(cashPool.UnExchangeSuMoney, -2).Float64()
|
|
|
180
|
+ cashPool.ExchangedCash, _ = decimal.NewFromFloatWithExponent(cashPool.ExchangedCash, -2).Float64()
|
|
|
181
|
+ cashPool.LastRate, _ = decimal.NewFromFloatWithExponent(cashPool.LastRate, -2).Float64()
|
170
|
return cashPool, nil
|
182
|
return cashPool, nil
|
171
|
}
|
183
|
}
|
172
|
} else { // 新增现金池
|
184
|
} else { // 新增现金池
|
|
|
185
|
+ // 获取上次兑换活动兑换汇率查询
|
|
|
186
|
+ var lastActivityRate float64
|
|
|
187
|
+ listExchangeCashActivityQuery := map[string]interface{}{
|
|
|
188
|
+ "companyId": createCashPoolCommand.CompanyId,
|
|
|
189
|
+ "order": "deadline DESC",
|
|
|
190
|
+ "nearest": true,
|
|
|
191
|
+ "limit": 1,
|
|
|
192
|
+ }
|
|
|
193
|
+ if _, activities, err := exchangeActivityRepository.Find(listExchangeCashActivityQuery); err != nil {
|
|
|
194
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
195
|
+ } else {
|
|
|
196
|
+ if len(activities) > 0 {
|
|
|
197
|
+ lastActivityRate = activities[0].Rate
|
|
|
198
|
+ } else { // 未查询到相关兑换活动
|
|
|
199
|
+ lastActivityRate = 0
|
|
|
200
|
+ }
|
|
|
201
|
+ }
|
|
|
202
|
+
|
|
|
203
|
+ // 更新现金池
|
173
|
newCashPool := &domain.CashPool{
|
204
|
newCashPool := &domain.CashPool{
|
174
|
CompanyId: createCashPoolCommand.CompanyId,
|
205
|
CompanyId: createCashPoolCommand.CompanyId,
|
175
|
Cash: createCashPoolCommand.Cash,
|
206
|
Cash: createCashPoolCommand.Cash,
|
|
@@ -177,7 +208,7 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co |
|
@@ -177,7 +208,7 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co |
177
|
UnExchangeCash: createCashPoolCommand.Cash,
|
208
|
UnExchangeCash: createCashPoolCommand.Cash,
|
178
|
ExchangedSuMoney: systemExchangedSuMoney,
|
209
|
ExchangedSuMoney: systemExchangedSuMoney,
|
179
|
UnExchangeSuMoney: systemUnExchangeSuMoney,
|
210
|
UnExchangeSuMoney: systemUnExchangeSuMoney,
|
180
|
- LastRate: 0,
|
211
|
+ LastRate: lastActivityRate,
|
181
|
Rate: 0,
|
212
|
Rate: 0,
|
182
|
CreateTime: time.Now().Local(),
|
213
|
CreateTime: time.Now().Local(),
|
183
|
}
|
214
|
}
|
|
@@ -187,11 +218,16 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co |
|
@@ -187,11 +218,16 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co |
187
|
if err := transactionContext.CommitTransaction(); err != nil {
|
218
|
if err := transactionContext.CommitTransaction(); err != nil {
|
188
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
219
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
189
|
}
|
220
|
}
|
190
|
- cashPool.Rate, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", cashPool.Rate), 64)
|
|
|
191
|
- cashPool.UnExchangeCash, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", cashPool.UnExchangeCash), 64)
|
|
|
192
|
- cashPool.ExchangedSuMoney, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", cashPool.ExchangedSuMoney), 64)
|
|
|
193
|
- cashPool.UnExchangeSuMoney, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", cashPool.UnExchangeSuMoney), 64)
|
|
|
194
|
- cashPool.ExchangedCash, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", cashPool.ExchangedCash), 64)
|
221
|
+ //cashPool.Rate, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", cashPool.Rate), 64)
|
|
|
222
|
+ //cashPool.UnExchangeCash, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", cashPool.UnExchangeCash), 64)
|
|
|
223
|
+ //cashPool.ExchangedSuMoney, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", cashPool.ExchangedSuMoney), 64)
|
|
|
224
|
+ //cashPool.UnExchangeSuMoney, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", cashPool.UnExchangeSuMoney), 64)
|
|
|
225
|
+ //cashPool.ExchangedCash, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", cashPool.ExchangedCash), 64)
|
|
|
226
|
+ cashPool.Rate, _ = decimal.NewFromFloatWithExponent(cashPool.Rate, -2).Float64()
|
|
|
227
|
+ cashPool.UnExchangeCash, _ = decimal.NewFromFloatWithExponent(cashPool.UnExchangeCash, -2).Float64()
|
|
|
228
|
+ cashPool.ExchangedSuMoney, _ = decimal.NewFromFloatWithExponent(cashPool.ExchangedSuMoney, -2).Float64()
|
|
|
229
|
+ cashPool.UnExchangeSuMoney, _ = decimal.NewFromFloatWithExponent(cashPool.UnExchangeSuMoney, -2).Float64()
|
|
|
230
|
+ cashPool.ExchangedCash, _ = decimal.NewFromFloatWithExponent(cashPool.ExchangedCash, -2).Float64()
|
195
|
return cashPool, nil
|
231
|
return cashPool, nil
|
196
|
}
|
232
|
}
|
197
|
}
|
233
|
}
|
|
@@ -202,6 +238,7 @@ func (cashPoolService *CashPoolService) GetCashPool(getCashPoolQuery *query.GetC |
|
@@ -202,6 +238,7 @@ func (cashPoolService *CashPoolService) GetCashPool(getCashPoolQuery *query.GetC |
202
|
if err := getCashPoolQuery.ValidateQuery(); err != nil {
|
238
|
if err := getCashPoolQuery.ValidateQuery(); err != nil {
|
203
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
239
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
204
|
}
|
240
|
}
|
|
|
241
|
+
|
205
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
242
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
206
|
if err != nil {
|
243
|
if err != nil {
|
207
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
244
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
@@ -272,10 +309,10 @@ func (cashPoolService *CashPoolService) GetCashPool(getCashPoolQuery *query.GetC |
|
@@ -272,10 +309,10 @@ func (cashPoolService *CashPoolService) GetCashPool(getCashPoolQuery *query.GetC |
272
|
"nearest": true,
|
309
|
"nearest": true,
|
273
|
"limit": 1,
|
310
|
"limit": 1,
|
274
|
}
|
311
|
}
|
275
|
- if count, activities, err := exchangeActivityRepository.Find(listExchangeCashActivityQuery); err != nil {
|
312
|
+ if _, activities, err := exchangeActivityRepository.Find(listExchangeCashActivityQuery); err != nil {
|
276
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
313
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
277
|
} else {
|
314
|
} else {
|
278
|
- if count >= 0 {
|
315
|
+ if len(activities) > 0 {
|
279
|
lastActivityRate = activities[0].Rate
|
316
|
lastActivityRate = activities[0].Rate
|
280
|
} else { // 未查询到相关兑换活动
|
317
|
} else { // 未查询到相关兑换活动
|
281
|
lastActivityRate = 0
|
318
|
lastActivityRate = 0
|
|
@@ -290,7 +327,8 @@ func (cashPoolService *CashPoolService) GetCashPool(getCashPoolQuery *query.GetC |
|
@@ -290,7 +327,8 @@ func (cashPoolService *CashPoolService) GetCashPool(getCashPoolQuery *query.GetC |
290
|
if systemSuMoneyStatistics == nil {
|
327
|
if systemSuMoneyStatistics == nil {
|
291
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的公司")
|
328
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的公司")
|
292
|
}
|
329
|
}
|
293
|
- systemUnExchangeSuMoney, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64)), 64) // 平台未兑换素币
|
330
|
+ //systemUnExchangeSuMoney, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64)), 64) // 平台未兑换素币
|
|
|
331
|
+ systemUnExchangeSuMoney, _ := decimal.NewFromFloatWithExponent(systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64), -2).Float64() // 平台未兑换素币
|
294
|
|
332
|
|
295
|
// 查找当前公司现金池
|
333
|
// 查找当前公司现金池
|
296
|
if count, cashPools, err := cashPoolRepository.Find(tool_funs.SimpleStructToMap(getCashPoolQuery)); err != nil {
|
334
|
if count, cashPools, err := cashPoolRepository.Find(tool_funs.SimpleStructToMap(getCashPoolQuery)); err != nil {
|
|
@@ -314,12 +352,18 @@ func (cashPoolService *CashPoolService) GetCashPool(getCashPoolQuery *query.GetC |
|
@@ -314,12 +352,18 @@ func (cashPoolService *CashPoolService) GetCashPool(getCashPoolQuery *query.GetC |
314
|
"createTime": time.Now().Local(),
|
352
|
"createTime": time.Now().Local(),
|
315
|
}, nil
|
353
|
}, nil
|
316
|
} else {
|
354
|
} else {
|
317
|
- cashPools[0].Rate, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", cashPools[0].Rate), 64)
|
|
|
318
|
- cashPools[0].LastRate = lastActivityRate
|
|
|
319
|
- cashPools[0].UnExchangeCash, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", cashPools[0].UnExchangeCash), 64)
|
|
|
320
|
- cashPools[0].ExchangedCash, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", cashPools[0].ExchangedCash), 64)
|
|
|
321
|
- cashPools[0].ExchangedSuMoney, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", cashPools[0].ExchangedSuMoney), 64)
|
|
|
322
|
- cashPools[0].UnExchangeSuMoney, _= strconv.ParseFloat(fmt.Sprintf("%.2f", systemUnExchangeSuMoney), 64)
|
355
|
+ //cashPools[0].Rate, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", cashPools[0].Rate), 64)
|
|
|
356
|
+ //cashPools[0].LastRate = lastActivityRate
|
|
|
357
|
+ //cashPools[0].UnExchangeCash, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", cashPools[0].UnExchangeCash), 64)
|
|
|
358
|
+ //cashPools[0].ExchangedCash, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", cashPools[0].ExchangedCash), 64)
|
|
|
359
|
+ //cashPools[0].ExchangedSuMoney, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", cashPools[0].ExchangedSuMoney), 64)
|
|
|
360
|
+ //cashPools[0].UnExchangeSuMoney, _= strconv.ParseFloat(fmt.Sprintf("%.2f", systemUnExchangeSuMoney), 64)
|
|
|
361
|
+ cashPools[0].Rate, _ = decimal.NewFromFloatWithExponent(cashPools[0].Rate, -2).Float64()
|
|
|
362
|
+ cashPools[0].LastRate, _ = decimal.NewFromFloatWithExponent(lastActivityRate, -2).Float64()
|
|
|
363
|
+ cashPools[0].UnExchangeCash, _ = decimal.NewFromFloatWithExponent(cashPools[0].UnExchangeCash, -2).Float64()
|
|
|
364
|
+ cashPools[0].ExchangedCash, _ = decimal.NewFromFloatWithExponent(cashPools[0].ExchangedCash, -2).Float64()
|
|
|
365
|
+ cashPools[0].ExchangedSuMoney, _ = decimal.NewFromFloatWithExponent(cashPools[0].ExchangedSuMoney, -2).Float64()
|
|
|
366
|
+ cashPools[0].UnExchangeSuMoney, _ = decimal.NewFromFloatWithExponent(systemUnExchangeSuMoney, -2).Float64()
|
323
|
return cashPools[0], nil
|
367
|
return cashPools[0], nil
|
324
|
}
|
368
|
}
|
325
|
}
|
369
|
}
|
|
@@ -330,6 +374,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashActivity(createExchang |
|
@@ -330,6 +374,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashActivity(createExchang |
330
|
if err := createExchangeCashActivityCommand.ValidateCommand(); err != nil {
|
374
|
if err := createExchangeCashActivityCommand.ValidateCommand(); err != nil {
|
331
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
375
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
332
|
}
|
376
|
}
|
|
|
377
|
+
|
333
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
378
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
334
|
if err != nil {
|
379
|
if err != nil {
|
335
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
380
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
@@ -403,8 +448,10 @@ func (cashPoolService *CashPoolService) CreateExchangeCashActivity(createExchang |
|
@@ -403,8 +448,10 @@ func (cashPoolService *CashPoolService) CreateExchangeCashActivity(createExchang |
403
|
if err := transactionContext.CommitTransaction(); err != nil {
|
448
|
if err := transactionContext.CommitTransaction(); err != nil {
|
404
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
449
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
405
|
}
|
450
|
}
|
406
|
- activity.ExchangedCash, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", activity.ExchangedCash), 64)
|
|
|
407
|
- activity.ExchangedSuMoney, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", activity.ExchangedSuMoney), 64)
|
451
|
+ //activity.ExchangedCash, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", activity.ExchangedCash), 64)
|
|
|
452
|
+ //activity.ExchangedSuMoney, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", activity.ExchangedSuMoney), 64)
|
|
|
453
|
+ activity.ExchangedCash, _ = decimal.NewFromFloatWithExponent(activity.ExchangedCash, -2).Float64()
|
|
|
454
|
+ activity.ExchangedSuMoney, _ = decimal.NewFromFloatWithExponent(activity.ExchangedSuMoney, -2).Float64()
|
408
|
return activity, nil
|
455
|
return activity, nil
|
409
|
}
|
456
|
}
|
410
|
}
|
457
|
}
|
|
@@ -414,6 +461,7 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivityDeadline(listExc |
|
@@ -414,6 +461,7 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivityDeadline(listExc |
414
|
if err := listExchangeCashActivityDeadlineQuery.ValidateQuery(); err != nil {
|
461
|
if err := listExchangeCashActivityDeadlineQuery.ValidateQuery(); err != nil {
|
415
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
462
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
416
|
}
|
463
|
}
|
|
|
464
|
+
|
417
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
465
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
418
|
if err != nil {
|
466
|
if err != nil {
|
419
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
467
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
@@ -465,6 +513,7 @@ func (cashPoolService *CashPoolService) SearchExchangeCashActivity(activityComma |
|
@@ -465,6 +513,7 @@ func (cashPoolService *CashPoolService) SearchExchangeCashActivity(activityComma |
465
|
if err := activityCommand.ValidateCommand(); err != nil {
|
513
|
if err := activityCommand.ValidateCommand(); err != nil {
|
466
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
514
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
467
|
}
|
515
|
}
|
|
|
516
|
+
|
468
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
517
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
469
|
if err != nil {
|
518
|
if err != nil {
|
470
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
519
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
@@ -527,8 +576,10 @@ func (cashPoolService *CashPoolService) SearchExchangeCashActivity(activityComma |
|
@@ -527,8 +576,10 @@ func (cashPoolService *CashPoolService) SearchExchangeCashActivity(activityComma |
527
|
|
576
|
|
528
|
var activitiesFormat []interface{}
|
577
|
var activitiesFormat []interface{}
|
529
|
for _, activity := range activities {
|
578
|
for _, activity := range activities {
|
530
|
- cash, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", activity.ExchangedCash), 64)
|
|
|
531
|
- suMoney, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", activity.ExchangedSuMoney), 64)
|
579
|
+ //cash, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", activity.ExchangedCash), 64)
|
|
|
580
|
+ //suMoney, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", activity.ExchangedSuMoney), 64)
|
|
|
581
|
+ cash, _ := decimal.NewFromFloatWithExponent(activity.ExchangedCash, -2).Float64()
|
|
|
582
|
+ suMoney, _ := decimal.NewFromFloatWithExponent(activity.ExchangedSuMoney, -2).Float64()
|
532
|
activityFormat := map[string]interface{} {
|
583
|
activityFormat := map[string]interface{} {
|
533
|
"activityId": activity.ActivityId,
|
584
|
"activityId": activity.ActivityId,
|
534
|
"exchangeActivityName": activity.ExchangeActivityName,
|
585
|
"exchangeActivityName": activity.ExchangeActivityName,
|
|
@@ -559,6 +610,7 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas |
|
@@ -559,6 +610,7 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas |
559
|
if err := listExchangeCashActivityQuery.ValidateQuery(); err != nil {
|
610
|
if err := listExchangeCashActivityQuery.ValidateQuery(); err != nil {
|
560
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
611
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
561
|
}
|
612
|
}
|
|
|
613
|
+
|
562
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
614
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
563
|
if err != nil {
|
615
|
if err != nil {
|
564
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
616
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
@@ -581,7 +633,7 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas |
|
@@ -581,7 +633,7 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas |
581
|
}
|
633
|
}
|
582
|
|
634
|
|
583
|
// 查找兑换现金活动
|
635
|
// 查找兑换现金活动
|
584
|
- if count, activities, err := exchangeActivityRepository.Find(map[string]interface{}{
|
636
|
+ if count, activitiesFound, err := exchangeActivityRepository.Find(map[string]interface{}{
|
585
|
"companyId": listExchangeCashActivityQuery.CompanyId,
|
637
|
"companyId": listExchangeCashActivityQuery.CompanyId,
|
586
|
"activityNameMatch": listExchangeCashActivityQuery.ActivityNameMatch,
|
638
|
"activityNameMatch": listExchangeCashActivityQuery.ActivityNameMatch,
|
587
|
"offset": listExchangeCashActivityQuery.Offset,
|
639
|
"offset": listExchangeCashActivityQuery.Offset,
|
|
@@ -591,18 +643,18 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas |
|
@@ -591,18 +643,18 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas |
591
|
}); err != nil {
|
643
|
}); err != nil {
|
592
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
644
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
593
|
} else {
|
645
|
} else {
|
594
|
- for _, activity := range activities {
|
646
|
+ for _, activityFound := range activitiesFound {
|
595
|
var t1 = time.Now().Local()
|
647
|
var t1 = time.Now().Local()
|
596
|
- var t2 = activity.Deadline.Local()
|
648
|
+ var t2 = activityFound.Deadline.Local()
|
597
|
|
649
|
|
598
|
// 更新兑换现金活动倒计时命令
|
650
|
// 更新兑换现金活动倒计时命令
|
599
|
updateExchangeCashActivity := &command.UpdateExchangeCashActivityCommand {
|
651
|
updateExchangeCashActivity := &command.UpdateExchangeCashActivityCommand {
|
600
|
- ExchangeCashActivityId: activity.ActivityId,
|
652
|
+ ExchangeCashActivityId: activityFound.ActivityId,
|
601
|
CountDown: int64(math.Ceil(t2.Sub(t1).Hours() / 24)),
|
653
|
CountDown: int64(math.Ceil(t2.Sub(t1).Hours() / 24)),
|
602
|
- Deadline: activity.Deadline.Local(),
|
|
|
603
|
- ExchangedSuMoney: activity.ExchangedSuMoney,
|
|
|
604
|
- ExchangedCash: activity.ExchangedCash,
|
|
|
605
|
- ExchangeRate: activity.Rate,
|
654
|
+ Deadline: activityFound.Deadline.Local(),
|
|
|
655
|
+ ExchangedSuMoney: activityFound.ExchangedSuMoney,
|
|
|
656
|
+ ExchangedCash: activityFound.ExchangedCash,
|
|
|
657
|
+ ExchangeRate: activityFound.Rate,
|
606
|
}
|
658
|
}
|
607
|
|
659
|
|
608
|
// 倒计时结束处理
|
660
|
// 倒计时结束处理
|
|
@@ -611,12 +663,12 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas |
|
@@ -611,12 +663,12 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas |
611
|
}
|
663
|
}
|
612
|
|
664
|
|
613
|
// 更新兑换现金活动倒计时
|
665
|
// 更新兑换现金活动倒计时
|
614
|
- if err := activity.Update(tool_funs.SimpleStructToMap(updateExchangeCashActivity)); err != nil {
|
666
|
+ if err := activityFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashActivity)); err != nil {
|
615
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
667
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
616
|
}
|
668
|
}
|
617
|
|
669
|
|
618
|
// 保存兑换现金活动倒计时更新
|
670
|
// 保存兑换现金活动倒计时更新
|
619
|
- _, err := exchangeActivityRepository.Save(activity)
|
671
|
+ _, err := exchangeActivityRepository.Save(activityFound)
|
620
|
if err != nil {
|
672
|
if err != nil {
|
621
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
673
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
622
|
}
|
674
|
}
|
|
@@ -628,19 +680,21 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas |
|
@@ -628,19 +680,21 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas |
628
|
|
680
|
|
629
|
// 兑换现金活动返回截止时间处理
|
681
|
// 兑换现金活动返回截止时间处理
|
630
|
var activitiesWithTs []interface{}
|
682
|
var activitiesWithTs []interface{}
|
631
|
- for _, activity := range activities {
|
|
|
632
|
- cash, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", activity.ExchangedCash), 64)
|
|
|
633
|
- suMoney, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", activity.ExchangedSuMoney), 64)
|
683
|
+ for _, activityFound := range activitiesFound {
|
|
|
684
|
+ //cash, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", activityFound.ExchangedCash), 64)
|
|
|
685
|
+ //suMoney, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", activityFound.ExchangedSuMoney), 64)
|
|
|
686
|
+ cash, _ := decimal.NewFromFloatWithExponent(activityFound.ExchangedCash, -2).Float64()
|
|
|
687
|
+ suMoney, _ := decimal.NewFromFloatWithExponent(activityFound.ExchangedSuMoney, -2).Float64()
|
634
|
activityWithTs := map[string]interface{} {
|
688
|
activityWithTs := map[string]interface{} {
|
635
|
- "activityId": activity.ActivityId,
|
|
|
636
|
- "exchangeActivityName": activity.ExchangeActivityName,
|
|
|
637
|
- "companyId": activity.CompanyId,
|
689
|
+ "activityId": activityFound.ActivityId,
|
|
|
690
|
+ "exchangeActivityName": activityFound.ExchangeActivityName,
|
|
|
691
|
+ "companyId": activityFound.CompanyId,
|
638
|
"exchangedCash": cash,
|
692
|
"exchangedCash": cash,
|
639
|
"exchangedSuMoney": suMoney,
|
693
|
"exchangedSuMoney": suMoney,
|
640
|
- "deadline": activity.Deadline.Local().UnixNano() / 1e6, // 秒级时间戳转换
|
|
|
641
|
- "countDown": activity.CountDown,
|
|
|
642
|
- "rate": activity.Rate,
|
|
|
643
|
- "createTime": activity.CreateTime.Local(),
|
694
|
+ "deadline": activityFound.Deadline.Local().UnixNano() / 1e6, // 秒级时间戳转换
|
|
|
695
|
+ "countDown": activityFound.CountDown,
|
|
|
696
|
+ "rate": activityFound.Rate,
|
|
|
697
|
+ "createTime": activityFound.CreateTime.Local(),
|
644
|
}
|
698
|
}
|
645
|
activitiesWithTs = append(activitiesWithTs, activityWithTs)
|
699
|
activitiesWithTs = append(activitiesWithTs, activityWithTs)
|
646
|
}
|
700
|
}
|
|
@@ -661,6 +715,7 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashActivity(removeExchang |
|
@@ -661,6 +715,7 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashActivity(removeExchang |
661
|
if err := removeExchangeCashActivityCommand.ValidateCommand(); err != nil {
|
715
|
if err := removeExchangeCashActivityCommand.ValidateCommand(); err != nil {
|
662
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
716
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
663
|
}
|
717
|
}
|
|
|
718
|
+
|
664
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
719
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
665
|
if err != nil {
|
720
|
if err != nil {
|
666
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
721
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
@@ -709,6 +764,7 @@ func (cashPoolService *CashPoolService) GetExchangeCashActivity(getExchangeCashA |
|
@@ -709,6 +764,7 @@ func (cashPoolService *CashPoolService) GetExchangeCashActivity(getExchangeCashA |
709
|
if err := getExchangeCashActivityQuery.ValidateQuery(); err != nil {
|
764
|
if err := getExchangeCashActivityQuery.ValidateQuery(); err != nil {
|
710
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
765
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
711
|
}
|
766
|
}
|
|
|
767
|
+
|
712
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
768
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
713
|
if err != nil {
|
769
|
if err != nil {
|
714
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
770
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
@@ -773,8 +829,10 @@ func (cashPoolService *CashPoolService) GetExchangeCashActivity(getExchangeCashA |
|
@@ -773,8 +829,10 @@ func (cashPoolService *CashPoolService) GetExchangeCashActivity(getExchangeCashA |
773
|
if err := transactionContext.CommitTransaction(); err != nil {
|
829
|
if err := transactionContext.CommitTransaction(); err != nil {
|
774
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
830
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
775
|
}
|
831
|
}
|
776
|
- activityUpdated.ExchangedSuMoney, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", activityUpdated.ExchangedSuMoney), 64)
|
|
|
777
|
- activityUpdated.ExchangedCash, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", activityUpdated.ExchangedCash), 64)
|
832
|
+ //activityUpdated.ExchangedSuMoney, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", activityUpdated.ExchangedSuMoney), 64)
|
|
|
833
|
+ //activityUpdated.ExchangedCash, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", activityUpdated.ExchangedCash), 64)
|
|
|
834
|
+ activityUpdated.ExchangedSuMoney, _ = decimal.NewFromFloatWithExponent(activityUpdated.ExchangedSuMoney, -2).Float64()
|
|
|
835
|
+ activityUpdated.ExchangedCash, _ = decimal.NewFromFloatWithExponent(activityUpdated.ExchangedCash, -2).Float64()
|
778
|
activityUpdated.Deadline = activityUpdated.Deadline.Local()
|
836
|
activityUpdated.Deadline = activityUpdated.Deadline.Local()
|
779
|
activityUpdated.CreateTime = activityUpdated.CreateTime.Local()
|
837
|
activityUpdated.CreateTime = activityUpdated.CreateTime.Local()
|
780
|
return activityUpdated, nil
|
838
|
return activityUpdated, nil
|
|
@@ -846,18 +904,17 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
|
@@ -846,18 +904,17 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
846
|
if activityFound == nil {
|
904
|
if activityFound == nil {
|
847
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateExchangeCashActivityCommand.ExchangeCashActivityId)))
|
905
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateExchangeCashActivityCommand.ExchangeCashActivityId)))
|
848
|
}
|
906
|
}
|
849
|
-
|
|
|
850
|
- activityFoundExchangedSuMoney := activityFound.ExchangedSuMoney
|
|
|
851
|
- activityFoundExchangedCash := activityFound.ExchangedCash
|
907
|
+ activityFoundExchangedSuMoney := activityFound.ExchangedSuMoney // 当前活动已兑换素币
|
|
|
908
|
+ activityFoundExchangedCash := activityFound.ExchangedCash // 当前活动已兑换现金
|
852
|
|
909
|
|
853
|
// 获取当前公司现金池
|
910
|
// 获取当前公司现金池
|
854
|
- _, cashPoolsFound, err := cashPoolRepository.Find(map[string]interface{}{
|
911
|
+ cashPoolFound, err := cashPoolRepository.FindOne(map[string]interface{}{
|
855
|
"companyId": activityFound.CompanyId,
|
912
|
"companyId": activityFound.CompanyId,
|
856
|
})
|
913
|
})
|
857
|
if err != nil {
|
914
|
if err != nil {
|
858
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
915
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
859
|
}
|
916
|
}
|
860
|
- if len(cashPoolsFound) == 0 { // 现金池不存在
|
917
|
+ if cashPoolFound != nil { // 现金池不存在
|
861
|
var t1 = time.Now().Local()
|
918
|
var t1 = time.Now().Local()
|
862
|
var t2 = updateExchangeCashActivityCommand.Deadline.Local()
|
919
|
var t2 = updateExchangeCashActivityCommand.Deadline.Local()
|
863
|
|
920
|
|
|
@@ -896,16 +953,18 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
|
@@ -896,16 +953,18 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
896
|
if err := transactionContext.CommitTransaction(); err != nil {
|
953
|
if err := transactionContext.CommitTransaction(); err != nil {
|
897
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
954
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
898
|
}
|
955
|
}
|
899
|
- activityUpdated.ExchangedSuMoney, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", activityUpdated.ExchangedSuMoney), 64)
|
|
|
900
|
- activityUpdated.ExchangedCash, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", activityUpdated.ExchangedCash), 64)
|
956
|
+ //activityUpdated.ExchangedSuMoney, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", activityUpdated.ExchangedSuMoney), 64)
|
|
|
957
|
+ //activityUpdated.ExchangedCash, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", activityUpdated.ExchangedCash), 64)
|
|
|
958
|
+ activityUpdated.ExchangedSuMoney, _ = decimal.NewFromFloatWithExponent(activityUpdated.ExchangedSuMoney, -2).Float64()
|
|
|
959
|
+ activityUpdated.ExchangedCash, _ = decimal.NewFromFloatWithExponent(activityUpdated.ExchangedCash, -2).Float64()
|
901
|
activityUpdated.Deadline = activityUpdated.Deadline.Local()
|
960
|
activityUpdated.Deadline = activityUpdated.Deadline.Local()
|
902
|
activityUpdated.CreateTime = activityUpdated.CreateTime.Local()
|
961
|
activityUpdated.CreateTime = activityUpdated.CreateTime.Local()
|
903
|
return activityUpdated, nil
|
962
|
return activityUpdated, nil
|
904
|
}
|
963
|
}
|
905
|
}
|
964
|
}
|
906
|
|
965
|
|
907
|
- cashPoolFoundUnExchangeCash := cashPoolsFound[0].UnExchangeCash
|
|
|
908
|
- cashPoolFoundExchangedCash := cashPoolsFound[0].ExchangedCash
|
966
|
+ cashPoolFoundUnExchangeCash := cashPoolFound.UnExchangeCash
|
|
|
967
|
+ cashPoolFoundExchangedCash := cashPoolFound.ExchangedCash
|
909
|
|
968
|
|
910
|
// 获取当前兑换活动汇率
|
969
|
// 获取当前兑换活动汇率
|
911
|
activityFoundRate := activityFound.Rate
|
970
|
activityFoundRate := activityFound.Rate
|
|
@@ -929,8 +988,10 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
|
@@ -929,8 +988,10 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
929
|
personFoundExchangedSuMoney := personFound.ExchangedSuMoney
|
988
|
personFoundExchangedSuMoney := personFound.ExchangedSuMoney
|
930
|
|
989
|
|
931
|
// 更新兑换清单命令
|
990
|
// 更新兑换清单命令
|
|
|
991
|
+ exchangeCash, _ := decimal.NewFromFloat(updateExchangeCashActivityCommand.ExchangeRate).Mul(decimal.NewFromFloat(personFoundExchangedSuMoney)).Float64()
|
932
|
updateExchangeCashPerson := &command.UpdateExchangeCashPersonCommand {
|
992
|
updateExchangeCashPerson := &command.UpdateExchangeCashPersonCommand {
|
933
|
- ExchangedCash: updateExchangeCashActivityCommand.ExchangeRate * personFoundExchangedSuMoney,
|
993
|
+ //ExchangedCash: updateExchangeCashActivityCommand.ExchangeRate * personFoundExchangedSuMoney,
|
|
|
994
|
+ ExchangedCash: exchangeCash,
|
934
|
ExchangedSuMoney: personFoundExchangedSuMoney,
|
995
|
ExchangedSuMoney: personFoundExchangedSuMoney,
|
935
|
}
|
996
|
}
|
936
|
|
997
|
|
|
@@ -966,28 +1027,33 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
|
@@ -966,28 +1027,33 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
966
|
if systemExchangedSuMoney == 0 {
|
1027
|
if systemExchangedSuMoney == 0 {
|
967
|
rate = 0
|
1028
|
rate = 0
|
968
|
} else {
|
1029
|
} else {
|
969
|
- rate = (cashPoolFoundExchangedCash + (updateExchangeCashActivityCommand.ExchangedCash - activityFoundExchangedCash)) / systemExchangedSuMoney
|
1030
|
+ //rate = (cashPoolFoundExchangedCash + (updateExchangeCashActivityCommand.ExchangedCash - activityFoundExchangedCash)) / systemExchangedSuMoney
|
|
|
1031
|
+ rate, _ = decimal.NewFromFloat(cashPoolFoundExchangedCash).Add(decimal.NewFromFloat(updateExchangeCashActivityCommand.ExchangedCash).Sub(decimal.NewFromFloat(activityFoundExchangedCash))).Div(decimal.NewFromFloat(systemExchangedSuMoney)).Float64()
|
970
|
}
|
1032
|
}
|
971
|
|
1033
|
|
972
|
// 更新现金池命令
|
1034
|
// 更新现金池命令
|
|
|
1035
|
+ exchangedCash, _ := decimal.NewFromFloat(cashPoolFoundExchangedCash).Add(decimal.NewFromFloat(updateExchangeCashActivityCommand.ExchangedCash).Sub(decimal.NewFromFloat(activityFoundExchangedCash))).Float64()
|
|
|
1036
|
+ unExchangeCash, _ := decimal.NewFromFloat(cashPoolFoundUnExchangeCash).Sub(decimal.NewFromFloat(updateExchangeCashActivityCommand.ExchangedCash).Sub(decimal.NewFromFloat(activityFoundExchangedCash))).Float64()
|
973
|
updateCashPoolCommand := &command.UpdateCashPoolCommand{
|
1037
|
updateCashPoolCommand := &command.UpdateCashPoolCommand{
|
974
|
- CashPoolId: cashPoolsFound[0].CashPoolId,
|
|
|
975
|
- ExchangedCash: cashPoolFoundExchangedCash + (updateExchangeCashActivityCommand.ExchangedCash - activityFoundExchangedCash),
|
|
|
976
|
- UnExchangeCash: cashPoolFoundUnExchangeCash - (updateExchangeCashActivityCommand.ExchangedCash - activityFoundExchangedCash) ,
|
1038
|
+ CashPoolId: cashPoolFound.CashPoolId,
|
|
|
1039
|
+ //ExchangedCash: cashPoolFoundExchangedCash + (updateExchangeCashActivityCommand.ExchangedCash - activityFoundExchangedCash),
|
|
|
1040
|
+ //UnExchangeCash: cashPoolFoundUnExchangeCash - (updateExchangeCashActivityCommand.ExchangedCash - activityFoundExchangedCash),
|
|
|
1041
|
+ ExchangedCash: exchangedCash,
|
|
|
1042
|
+ UnExchangeCash: unExchangeCash,
|
977
|
ExchangedSuMoney: systemExchangedSuMoney,
|
1043
|
ExchangedSuMoney: systemExchangedSuMoney,
|
978
|
UnExchangeSuMoney: systemUnExchangeSuMoney,
|
1044
|
UnExchangeSuMoney: systemUnExchangeSuMoney,
|
979
|
Rate: rate,
|
1045
|
Rate: rate,
|
980
|
- LastRate: cashPoolsFound[0].LastRate,
|
|
|
981
|
- Cash: cashPoolsFound[0].Cash,
|
1046
|
+ LastRate: cashPoolFound.LastRate,
|
|
|
1047
|
+ Cash: cashPoolFound.Cash,
|
982
|
}
|
1048
|
}
|
983
|
|
1049
|
|
984
|
// 更新现金池
|
1050
|
// 更新现金池
|
985
|
- if err := cashPoolsFound[0].Update(tool_funs.SimpleStructToMap(updateCashPoolCommand)); err != nil {
|
1051
|
+ if err := cashPoolFound.Update(tool_funs.SimpleStructToMap(updateCashPoolCommand)); err != nil {
|
986
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
1052
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
987
|
}
|
1053
|
}
|
988
|
|
1054
|
|
989
|
// 保存现金池更新
|
1055
|
// 保存现金池更新
|
990
|
- cashPoolUpdated, err := cashPoolRepository.Save(cashPoolsFound[0])
|
1056
|
+ cashPoolUpdated, err := cashPoolRepository.Save(cashPoolFound)
|
991
|
if err != nil {
|
1057
|
if err != nil {
|
992
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
1058
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
993
|
}
|
1059
|
}
|
|
@@ -1002,7 +1068,6 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
|
@@ -1002,7 +1068,6 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
1002
|
|
1068
|
|
1003
|
// 更新兑换活动倒计时
|
1069
|
// 更新兑换活动倒计时
|
1004
|
t1 := time.Now().Local()
|
1070
|
t1 := time.Now().Local()
|
1005
|
- //var t2 = activityFound.Deadline.Local()
|
|
|
1006
|
t2 := updateExchangeCashActivityCommand.Deadline.Local()
|
1071
|
t2 := updateExchangeCashActivityCommand.Deadline.Local()
|
1007
|
updateExchangeCashActivityCommand.CountDown = int64(math.Ceil(t2.Sub(t1).Hours() / 24))
|
1072
|
updateExchangeCashActivityCommand.CountDown = int64(math.Ceil(t2.Sub(t1).Hours() / 24))
|
1008
|
|
1073
|
|
|
@@ -1046,8 +1111,10 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
|
@@ -1046,8 +1111,10 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
1046
|
if err := transactionContext.CommitTransaction(); err != nil {
|
1111
|
if err := transactionContext.CommitTransaction(); err != nil {
|
1047
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
1112
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
1048
|
}
|
1113
|
}
|
1049
|
- activityUpdated.ExchangedSuMoney, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", activityUpdated.ExchangedSuMoney), 64)
|
|
|
1050
|
- activityUpdated.ExchangedCash, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", activityUpdated.ExchangedCash), 64)
|
1114
|
+ //activityUpdated.ExchangedSuMoney, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", activityUpdated.ExchangedSuMoney), 64)
|
|
|
1115
|
+ //activityUpdated.ExchangedCash, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", activityUpdated.ExchangedCash), 64)
|
|
|
1116
|
+ activityUpdated.ExchangedSuMoney, _ = decimal.NewFromFloatWithExponent(activityUpdated.ExchangedSuMoney, -2).Float64()
|
|
|
1117
|
+ activityUpdated.ExchangedCash, _ = decimal.NewFromFloatWithExponent(activityUpdated.ExchangedCash, -2).Float64()
|
1051
|
activityUpdated.Deadline = activityUpdated.Deadline.Local()
|
1118
|
activityUpdated.Deadline = activityUpdated.Deadline.Local()
|
1052
|
activityUpdated.CreateTime = activityUpdated.CreateTime.Local()
|
1119
|
activityUpdated.CreateTime = activityUpdated.CreateTime.Local()
|
1053
|
return activityUpdated, nil
|
1120
|
return activityUpdated, nil
|
|
@@ -1059,6 +1126,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
|
@@ -1059,6 +1126,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
1059
|
if err := updateExchangeCashPersonCommand.ValidateCommand(); err != nil {
|
1126
|
if err := updateExchangeCashPersonCommand.ValidateCommand(); err != nil {
|
1060
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
1127
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
1061
|
}
|
1128
|
}
|
|
|
1129
|
+
|
1062
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
1130
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
1063
|
if err != nil {
|
1131
|
if err != nil {
|
1064
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
1132
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
@@ -1151,13 +1219,11 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
|
@@ -1151,13 +1219,11 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
1151
|
activityFoundExchangedSuMoney := activityFound.ExchangedSuMoney
|
1219
|
activityFoundExchangedSuMoney := activityFound.ExchangedSuMoney
|
1152
|
activityFoundExchangedCash := activityFound.ExchangedCash
|
1220
|
activityFoundExchangedCash := activityFound.ExchangedCash
|
1153
|
|
1221
|
|
1154
|
- // 获取员工查询条件
|
1222
|
+ // 判断当前员工是否有效
|
1155
|
getEmployee := map[string]interface{}{
|
1223
|
getEmployee := map[string]interface{}{
|
1156
|
"account": personFound.EmployeeInfo.EmployeeAccount,
|
1224
|
"account": personFound.EmployeeInfo.EmployeeAccount,
|
1157
|
"companyId": activityFound.CompanyId,
|
1225
|
"companyId": activityFound.CompanyId,
|
1158
|
}
|
1226
|
}
|
1159
|
-
|
|
|
1160
|
- // 判断当前员工是否有效
|
|
|
1161
|
employeeFound, err := employeeRepository.FindOne(getEmployee)
|
1227
|
employeeFound, err := employeeRepository.FindOne(getEmployee)
|
1162
|
if err != nil {
|
1228
|
if err != nil {
|
1163
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
1229
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
@@ -1175,7 +1241,8 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
|
@@ -1175,7 +1241,8 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
1175
|
}
|
1241
|
}
|
1176
|
|
1242
|
|
1177
|
// 更新兑换清单,个人已兑换现金计算
|
1243
|
// 更新兑换清单,个人已兑换现金计算
|
1178
|
- updateExchangeCashPersonCommand.ExchangedCash = updateExchangeCashPersonCommand.ExchangedSuMoney * activityFound.Rate
|
1244
|
+ //updateExchangeCashPersonCommand.ExchangedCash = updateExchangeCashPersonCommand.ExchangedSuMoney * activityFound.Rate
|
|
|
1245
|
+ updateExchangeCashPersonCommand.ExchangedCash, _ = decimal.NewFromFloat(updateExchangeCashPersonCommand.ExchangedSuMoney).Mul(decimal.NewFromFloat(activityFound.Rate)).Float64()
|
1179
|
|
1246
|
|
1180
|
// 更新兑换素币清单
|
1247
|
// 更新兑换素币清单
|
1181
|
if err := personFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashPersonCommand)); err != nil {
|
1248
|
if err := personFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashPersonCommand)); err != nil {
|
|
@@ -1189,10 +1256,14 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
|
@@ -1189,10 +1256,14 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
1189
|
}
|
1256
|
}
|
1190
|
|
1257
|
|
1191
|
// 更新素币兑换活动命令
|
1258
|
// 更新素币兑换活动命令
|
|
|
1259
|
+ exchangedSuMoney, _ := decimal.NewFromFloat(activityFoundExchangedSuMoney).Add(decimal.NewFromFloat(updateExchangeCashPersonCommand.ExchangedSuMoney).Sub(decimal.NewFromFloat(personFoundExchangedSuMoney))).Float64()
|
|
|
1260
|
+ exchangedCash, _ := decimal.NewFromFloat(activityFoundExchangedCash).Add(decimal.NewFromFloat(updateExchangeCashPersonCommand.ExchangedSuMoney).Sub(decimal.NewFromFloat(personFoundExchangedSuMoney))).Mul(decimal.NewFromFloat(activityFound.Rate)).Float64()
|
1192
|
updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{
|
1261
|
updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{
|
1193
|
ExchangeCashActivityId: personFound.ExchangeCashActivityId,
|
1262
|
ExchangeCashActivityId: personFound.ExchangeCashActivityId,
|
1194
|
- ExchangedSuMoney: activityFoundExchangedSuMoney + (updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney),
|
|
|
1195
|
- ExchangedCash: activityFoundExchangedCash + (updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney) * activityFound.Rate,
|
1263
|
+ //ExchangedSuMoney: activityFoundExchangedSuMoney + (updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney),
|
|
|
1264
|
+ //ExchangedCash: activityFoundExchangedCash + (updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney) * activityFound.Rate,
|
|
|
1265
|
+ ExchangedSuMoney: exchangedSuMoney,
|
|
|
1266
|
+ ExchangedCash: exchangedCash,
|
1196
|
Deadline: activityFound.Deadline,
|
1267
|
Deadline: activityFound.Deadline,
|
1197
|
CountDown: activityFound.CountDown,
|
1268
|
CountDown: activityFound.CountDown,
|
1198
|
ExchangeRate: activityFound.Rate,
|
1269
|
ExchangeRate: activityFound.Rate,
|
|
@@ -1209,10 +1280,12 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
|
@@ -1209,10 +1280,12 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
1209
|
|
1280
|
|
1210
|
// 判断操作素币类型
|
1281
|
// 判断操作素币类型
|
1211
|
if updateExchangeCashPersonCommand.ExchangedSuMoney > personFoundExchangedSuMoney { // 追加素币兑换
|
1282
|
if updateExchangeCashPersonCommand.ExchangedSuMoney > personFoundExchangedSuMoney { // 追加素币兑换
|
1212
|
- operationSuMoneyCommand.SuMoney = math.Abs(updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney)
|
1283
|
+ //operationSuMoneyCommand.SuMoney = math.Abs(updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney)
|
|
|
1284
|
+ operationSuMoneyCommand.SuMoney, _ = decimal.NewFromFloat(updateExchangeCashPersonCommand.ExchangedSuMoney).Sub(decimal.NewFromFloat(personFoundExchangedSuMoney)).Abs().Float64()
|
1213
|
operationSuMoneyCommand.OperationType = 4
|
1285
|
operationSuMoneyCommand.OperationType = 4
|
1214
|
} else { // 撤回素币兑换
|
1286
|
} else { // 撤回素币兑换
|
1215
|
- operationSuMoneyCommand.SuMoney = math.Abs(updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney)
|
1287
|
+ //operationSuMoneyCommand.SuMoney = math.Abs(updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney)
|
|
|
1288
|
+ operationSuMoneyCommand.SuMoney, _ = decimal.NewFromFloat(updateExchangeCashPersonCommand.ExchangedSuMoney).Sub(decimal.NewFromFloat(personFoundExchangedSuMoney)).Abs().Float64()
|
1216
|
operationSuMoneyCommand.OperationType = 41
|
1289
|
operationSuMoneyCommand.OperationType = 41
|
1217
|
}
|
1290
|
}
|
1218
|
|
1291
|
|
|
@@ -1251,18 +1324,18 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
|
@@ -1251,18 +1324,18 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
1251
|
systemUnExchangeSuMoney := systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64)
|
1324
|
systemUnExchangeSuMoney := systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64)
|
1252
|
|
1325
|
|
1253
|
// 获取当前现金池
|
1326
|
// 获取当前现金池
|
1254
|
- _, cashPoolsFound, err := cashPoolRepository.Find(map[string]interface{}{
|
1327
|
+ cashPoolFound, err := cashPoolRepository.FindOne(map[string]interface{}{
|
1255
|
"companyId": activityUpdated.CompanyId,
|
1328
|
"companyId": activityUpdated.CompanyId,
|
1256
|
})
|
1329
|
})
|
1257
|
if err != nil {
|
1330
|
if err != nil {
|
1258
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
1331
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
1259
|
}
|
1332
|
}
|
1260
|
- if cashPoolsFound == nil {
|
1333
|
+ if cashPoolFound == nil {
|
1261
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(activityFound.CompanyId)))
|
1334
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(activityFound.CompanyId)))
|
1262
|
}
|
1335
|
}
|
1263
|
|
1336
|
|
1264
|
- cashPoolFoundUnExchangeCash := cashPoolsFound[0].UnExchangeCash
|
|
|
1265
|
- cashPoolFoundExchangedCash := cashPoolsFound[0].ExchangedCash
|
1337
|
+ cashPoolFoundUnExchangeCash := cashPoolFound.UnExchangeCash
|
|
|
1338
|
+ cashPoolFoundExchangedCash := cashPoolFound.ExchangedCash
|
1266
|
|
1339
|
|
1267
|
// 判断是否超过平台未兑换现金
|
1340
|
// 判断是否超过平台未兑换现金
|
1268
|
if activityUpdated.ExchangedSuMoney > activityFoundExchangedSuMoney {
|
1341
|
if activityUpdated.ExchangedSuMoney > activityFoundExchangedSuMoney {
|
|
@@ -1271,7 +1344,8 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
|
@@ -1271,7 +1344,8 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
1271
|
}
|
1344
|
}
|
1272
|
}
|
1345
|
}
|
1273
|
|
1346
|
|
1274
|
- systemExchangedCash := cashPoolFoundExchangedCash + (updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney) * activityUpdated.Rate
|
1347
|
+ //systemExchangedCash := cashPoolFoundExchangedCash + (updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney) * activityUpdated.Rate
|
|
|
1348
|
+ systemExchangedCash, _ := decimal.NewFromFloat(cashPoolFoundExchangedCash).Add(decimal.NewFromFloat(updateExchangeCashPersonCommand.ExchangedSuMoney).Sub(decimal.NewFromFloat(personFoundExchangedSuMoney))).Mul(decimal.NewFromFloat(activityUpdated.Rate)).Float64()
|
1275
|
//systemExchangedSuMoney := cashPoolsFound[0].ExchangedSuMoney + (updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney)
|
1349
|
//systemExchangedSuMoney := cashPoolsFound[0].ExchangedSuMoney + (updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney)
|
1276
|
|
1350
|
|
1277
|
// 计算现金池平均兑换汇率
|
1351
|
// 计算现金池平均兑换汇率
|
|
@@ -1279,28 +1353,31 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
|
@@ -1279,28 +1353,31 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
1279
|
if systemExchangedSuMoney == 0 {
|
1353
|
if systemExchangedSuMoney == 0 {
|
1280
|
newRate = 0
|
1354
|
newRate = 0
|
1281
|
} else {
|
1355
|
} else {
|
1282
|
- newRate = systemExchangedCash / systemExchangedSuMoney
|
1356
|
+ //newRate = systemExchangedCash / systemExchangedSuMoney
|
|
|
1357
|
+ newRate, _ = decimal.NewFromFloat(systemExchangedCash).Div(decimal.NewFromFloat(systemExchangedSuMoney)).Float64()
|
1283
|
}
|
1358
|
}
|
1284
|
|
1359
|
|
1285
|
// 更新现金池命令
|
1360
|
// 更新现金池命令
|
|
|
1361
|
+ unExchangeCash, _ := decimal.NewFromFloat(cashPoolFoundUnExchangeCash).Sub((decimal.NewFromFloat(updateExchangeCashPersonCommand.ExchangedSuMoney).Sub(decimal.NewFromFloat(personFoundExchangedSuMoney))).Mul(decimal.NewFromFloat(activityUpdated.Rate))).Float64()
|
1286
|
updateCashPoolCommand := &command.UpdateCashPoolCommand{
|
1362
|
updateCashPoolCommand := &command.UpdateCashPoolCommand{
|
1287
|
- CashPoolId: cashPoolsFound[0].CashPoolId,
|
|
|
1288
|
- Cash: cashPoolsFound[0].Cash,
|
1363
|
+ CashPoolId: cashPoolFound.CashPoolId,
|
|
|
1364
|
+ Cash: cashPoolFound.Cash,
|
1289
|
ExchangedCash: systemExchangedCash,
|
1365
|
ExchangedCash: systemExchangedCash,
|
1290
|
- UnExchangeCash: cashPoolFoundUnExchangeCash - (updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney) * activityUpdated.Rate,
|
1366
|
+ //UnExchangeCash: cashPoolFoundUnExchangeCash - (updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney) * activityUpdated.Rate,
|
|
|
1367
|
+ UnExchangeCash: unExchangeCash,
|
1291
|
Rate: newRate,
|
1368
|
Rate: newRate,
|
1292
|
ExchangedSuMoney: systemExchangedSuMoney,
|
1369
|
ExchangedSuMoney: systemExchangedSuMoney,
|
1293
|
UnExchangeSuMoney: systemUnExchangeSuMoney,
|
1370
|
UnExchangeSuMoney: systemUnExchangeSuMoney,
|
1294
|
- LastRate: cashPoolsFound[0].LastRate,
|
1371
|
+ LastRate: cashPoolFound.LastRate,
|
1295
|
}
|
1372
|
}
|
1296
|
|
1373
|
|
1297
|
// 更新现金池
|
1374
|
// 更新现金池
|
1298
|
- if err := cashPoolsFound[0].Update(tool_funs.SimpleStructToMap(updateCashPoolCommand)); err != nil {
|
1375
|
+ if err := cashPoolFound.Update(tool_funs.SimpleStructToMap(updateCashPoolCommand)); err != nil {
|
1299
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
1376
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
1300
|
}
|
1377
|
}
|
1301
|
|
1378
|
|
1302
|
// 保存现金池更新
|
1379
|
// 保存现金池更新
|
1303
|
- cashPoolUpdated, err := cashPoolRepository.Save(cashPoolsFound[0])
|
1380
|
+ cashPoolUpdated, err := cashPoolRepository.Save(cashPoolFound)
|
1304
|
if err != nil {
|
1381
|
if err != nil {
|
1305
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
1382
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
1306
|
}
|
1383
|
}
|
|
@@ -1570,11 +1647,15 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
|
@@ -1570,11 +1647,15 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
1570
|
}
|
1647
|
}
|
1571
|
|
1648
|
|
1572
|
// 更新兑换活动
|
1649
|
// 更新兑换活动
|
|
|
1650
|
+ exchangedSuMoney, _ := decimal.NewFromFloat(activityFoundExchangedSuMoney).Add(decimal.NewFromFloat(createExchangeCashPersonCommand.ExchangedSuMoney)).Float64()
|
|
|
1651
|
+ exchangedCash, _ := decimal.NewFromFloat(activityFoundExchangedCash).Add(decimal.NewFromFloat(createExchangeCashPersonCommand.ExchangedSuMoney).Mul(decimal.NewFromFloat(activityFound.Rate))).Float64()
|
1573
|
updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{
|
1652
|
updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{
|
1574
|
ExchangeCashActivityId: personSaved.ExchangeCashActivityId,
|
1653
|
ExchangeCashActivityId: personSaved.ExchangeCashActivityId,
|
1575
|
ExchangeActivityName: activityFound.ExchangeActivityName,
|
1654
|
ExchangeActivityName: activityFound.ExchangeActivityName,
|
1576
|
- ExchangedSuMoney: activityFoundExchangedSuMoney + createExchangeCashPersonCommand.ExchangedSuMoney,
|
|
|
1577
|
- ExchangedCash: activityFoundExchangedCash + createExchangeCashPersonCommand.ExchangedSuMoney * activityFound.Rate,
|
1655
|
+ //ExchangedSuMoney: activityFoundExchangedSuMoney + createExchangeCashPersonCommand.ExchangedSuMoney,
|
|
|
1656
|
+ //ExchangedCash: activityFoundExchangedCash + createExchangeCashPersonCommand.ExchangedSuMoney * activityFound.Rate,
|
|
|
1657
|
+ ExchangedSuMoney: exchangedSuMoney,
|
|
|
1658
|
+ ExchangedCash: exchangedCash,
|
1578
|
Deadline: activityFound.Deadline,
|
1659
|
Deadline: activityFound.Deadline,
|
1579
|
CountDown: activityFound.CountDown,
|
1660
|
CountDown: activityFound.CountDown,
|
1580
|
ExchangeRate: activityFound.Rate,
|
1661
|
ExchangeRate: activityFound.Rate,
|
|
@@ -1653,13 +1734,18 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
|
@@ -1653,13 +1734,18 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
1653
|
if systemExchangedSuMoney == 0 {
|
1734
|
if systemExchangedSuMoney == 0 {
|
1654
|
newRate = 0
|
1735
|
newRate = 0
|
1655
|
} else {
|
1736
|
} else {
|
1656
|
- newRate = (cashPoolFoundExchangedCash + personSaved.ExchangedCash) / systemExchangedSuMoney
|
1737
|
+ //newRate = (cashPoolFoundExchangedCash + personSaved.ExchangedCash) / systemExchangedSuMoney
|
|
|
1738
|
+ newRate, _ = decimal.NewFromFloat(cashPoolFoundExchangedCash).Add(decimal.NewFromFloat(personSaved.ExchangedCash)).Div(decimal.NewFromFloat(systemExchangedSuMoney)).Float64()
|
1657
|
}
|
1739
|
}
|
|
|
1740
|
+ newExchangedCash, _ := decimal.NewFromFloat(cashPoolFoundExchangedCash).Add(decimal.NewFromFloat(personSaved.ExchangedCash)).Float64()
|
|
|
1741
|
+ unExchangeCash, _ := decimal.NewFromFloat(cashPoolFoundUnExchangeCash).Sub(decimal.NewFromFloat(personSaved.ExchangedCash)).Float64()
|
1658
|
updateCashPoolCommand := &command.UpdateCashPoolCommand{
|
1742
|
updateCashPoolCommand := &command.UpdateCashPoolCommand{
|
1659
|
CashPoolId: cashPoolFound.CashPoolId,
|
1743
|
CashPoolId: cashPoolFound.CashPoolId,
|
1660
|
Cash: cashPoolFound.Cash,
|
1744
|
Cash: cashPoolFound.Cash,
|
1661
|
- ExchangedCash: cashPoolFoundExchangedCash + personSaved.ExchangedCash,
|
|
|
1662
|
- UnExchangeCash: cashPoolFoundUnExchangeCash - personSaved.ExchangedCash,
|
1745
|
+ //ExchangedCash: cashPoolFoundExchangedCash + personSaved.ExchangedCash,
|
|
|
1746
|
+ //UnExchangeCash: cashPoolFoundUnExchangeCash - personSaved.ExchangedCash,
|
|
|
1747
|
+ ExchangedCash: newExchangedCash,
|
|
|
1748
|
+ UnExchangeCash: unExchangeCash,
|
1663
|
ExchangedSuMoney: systemExchangedSuMoney,
|
1749
|
ExchangedSuMoney: systemExchangedSuMoney,
|
1664
|
UnExchangeSuMoney: systemUnExchangeSuMoney,
|
1750
|
UnExchangeSuMoney: systemUnExchangeSuMoney,
|
1665
|
Rate: newRate,
|
1751
|
Rate: newRate,
|
|
@@ -1701,15 +1787,22 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
|
@@ -1701,15 +1787,22 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
1701
|
personFoundExchangedCash := personFound.ExchangedCash // 当前素币清单已兑换现金
|
1787
|
personFoundExchangedCash := personFound.ExchangedCash // 当前素币清单已兑换现金
|
1702
|
if createExchangeCashPersonCommand.ExchangedSuMoney < personFoundExchangedSuMoney { // 当前兑换的素币小于本人已兑换素币,撤回兑换素币
|
1788
|
if createExchangeCashPersonCommand.ExchangedSuMoney < personFoundExchangedSuMoney { // 当前兑换的素币小于本人已兑换素币,撤回兑换素币
|
1703
|
// 素币减量
|
1789
|
// 素币减量
|
1704
|
- suMoneyDecrement := personFoundExchangedSuMoney - createExchangeCashPersonCommand.ExchangedSuMoney
|
1790
|
+ //suMoneyDecrement := personFoundExchangedSuMoney - createExchangeCashPersonCommand.ExchangedSuMoney
|
|
|
1791
|
+ suMoneyDecrement, _ := decimal.NewFromFloat(personFoundExchangedSuMoney).Sub(decimal.NewFromFloat(createExchangeCashPersonCommand.ExchangedSuMoney)).Float64()
|
|
|
1792
|
+
|
1705
|
// 现金减量
|
1793
|
// 现金减量
|
1706
|
- cashDecrement := suMoneyDecrement * activityFound.Rate
|
1794
|
+ //cashDecrement := suMoneyDecrement * activityFound.Rate
|
|
|
1795
|
+ cashDecrement, _ := decimal.NewFromFloat(suMoneyDecrement).Mul(decimal.NewFromFloat(activityFound.Rate)).Float64()
|
1707
|
|
1796
|
|
1708
|
// 更新兑换素币清单
|
1797
|
// 更新兑换素币清单
|
|
|
1798
|
+ exchangedSuMoney, _ := decimal.NewFromFloat(personFoundExchangedSuMoney).Sub(decimal.NewFromFloat(suMoneyDecrement)).Float64()
|
|
|
1799
|
+ exchangedCash, _ := decimal.NewFromFloat(personFoundExchangedCash).Sub(decimal.NewFromFloat(cashDecrement)).Float64()
|
1709
|
updateExchangeCashPersonCommand := &command.UpdateExchangeCashPersonCommand{
|
1800
|
updateExchangeCashPersonCommand := &command.UpdateExchangeCashPersonCommand{
|
1710
|
ListId: personFound.ListId,
|
1801
|
ListId: personFound.ListId,
|
1711
|
- ExchangedSuMoney: personFoundExchangedSuMoney - suMoneyDecrement,
|
|
|
1712
|
- ExchangedCash: personFoundExchangedCash - cashDecrement,
|
1802
|
+ //ExchangedSuMoney: personFoundExchangedSuMoney - suMoneyDecrement,
|
|
|
1803
|
+ //ExchangedCash: personFoundExchangedCash - cashDecrement,
|
|
|
1804
|
+ ExchangedSuMoney: exchangedSuMoney,
|
|
|
1805
|
+ ExchangedCash: exchangedCash,
|
1713
|
Operator: createExchangeCashPersonCommand.Operator,
|
1806
|
Operator: createExchangeCashPersonCommand.Operator,
|
1714
|
}
|
1807
|
}
|
1715
|
if err := personFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashPersonCommand)); err != nil {
|
1808
|
if err := personFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashPersonCommand)); err != nil {
|
|
@@ -1745,10 +1838,14 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
|
@@ -1745,10 +1838,14 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
1745
|
}
|
1838
|
}
|
1746
|
|
1839
|
|
1747
|
// 更新素币兑换活动
|
1840
|
// 更新素币兑换活动
|
|
|
1841
|
+ newExchangedSuMoney, _ := decimal.NewFromFloat(activityFoundExchangedSuMoney).Sub(decimal.NewFromFloat(suMoneyDecrement)).Float64()
|
|
|
1842
|
+ newExchangedCash, _ := decimal.NewFromFloat(activityFoundExchangedCash).Sub(decimal.NewFromFloat(cashDecrement)).Float64()
|
1748
|
updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{
|
1843
|
updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{
|
1749
|
ExchangeCashActivityId: personFound.ExchangeCashActivityId,
|
1844
|
ExchangeCashActivityId: personFound.ExchangeCashActivityId,
|
1750
|
- ExchangedSuMoney: activityFoundExchangedSuMoney - suMoneyDecrement,
|
|
|
1751
|
- ExchangedCash: activityFoundExchangedCash - cashDecrement,
|
1845
|
+ //ExchangedSuMoney: activityFoundExchangedSuMoney - suMoneyDecrement,
|
|
|
1846
|
+ //ExchangedCash: activityFoundExchangedCash - cashDecrement,
|
|
|
1847
|
+ ExchangedSuMoney: newExchangedSuMoney,
|
|
|
1848
|
+ ExchangedCash: newExchangedCash,
|
1752
|
Deadline: activityFound.Deadline,
|
1849
|
Deadline: activityFound.Deadline,
|
1753
|
CountDown: activityFound.CountDown,
|
1850
|
CountDown: activityFound.CountDown,
|
1754
|
ExchangeRate: activityFound.Rate,
|
1851
|
ExchangeRate: activityFound.Rate,
|
|
@@ -1845,13 +1942,18 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
|
@@ -1845,13 +1942,18 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
1845
|
if systemExchangedSuMoney == 0 {
|
1942
|
if systemExchangedSuMoney == 0 {
|
1846
|
newRate = 0
|
1943
|
newRate = 0
|
1847
|
} else {
|
1944
|
} else {
|
1848
|
- newRate = (cashPoolFoundExchangedCash - cashDecrement) / systemExchangedSuMoney
|
1945
|
+ //newRate = (cashPoolFoundExchangedCash - cashDecrement) / systemExchangedSuMoney
|
|
|
1946
|
+ newRate, _ = decimal.NewFromFloat(cashPoolFoundExchangedCash).Sub(decimal.NewFromFloat(cashDecrement)).Div(decimal.NewFromFloat(systemExchangedSuMoney)).Float64()
|
1849
|
}
|
1947
|
}
|
|
|
1948
|
+ cashPoolExchangedCash, _ := decimal.NewFromFloat(cashPoolFoundExchangedCash).Sub(decimal.NewFromFloat(cashDecrement)).Float64()
|
|
|
1949
|
+ unExchangeCash, _ := decimal.NewFromFloat(cashPoolFoundUnExchangeCash).Add(decimal.NewFromFloat(cashDecrement)).Float64()
|
1850
|
updateCashPoolCommand := &command.UpdateCashPoolCommand{
|
1950
|
updateCashPoolCommand := &command.UpdateCashPoolCommand{
|
1851
|
CashPoolId: cashPoolFound.CashPoolId,
|
1951
|
CashPoolId: cashPoolFound.CashPoolId,
|
1852
|
Cash: cashPoolFound.Cash,
|
1952
|
Cash: cashPoolFound.Cash,
|
1853
|
- ExchangedCash: cashPoolFoundExchangedCash - cashDecrement,
|
|
|
1854
|
- UnExchangeCash: cashPoolFoundUnExchangeCash + cashDecrement,
|
1953
|
+ //ExchangedCash: cashPoolFoundExchangedCash - cashDecrement,
|
|
|
1954
|
+ //UnExchangeCash: cashPoolFoundUnExchangeCash + cashDecrement,
|
|
|
1955
|
+ ExchangedCash: cashPoolExchangedCash,
|
|
|
1956
|
+ UnExchangeCash: unExchangeCash,
|
1855
|
ExchangedSuMoney: systemExchangedSuMoney,
|
1957
|
ExchangedSuMoney: systemExchangedSuMoney,
|
1856
|
UnExchangeSuMoney: systemUnExchangeSuMoney,
|
1958
|
UnExchangeSuMoney: systemUnExchangeSuMoney,
|
1857
|
Rate: newRate,
|
1959
|
Rate: newRate,
|
|
@@ -1890,9 +1992,11 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
|
@@ -1890,9 +1992,11 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
1890
|
}
|
1992
|
}
|
1891
|
} else { // 当前兑换素币大于等于已兑换素币,追加兑换素币
|
1993
|
} else { // 当前兑换素币大于等于已兑换素币,追加兑换素币
|
1892
|
// 素币增量
|
1994
|
// 素币增量
|
1893
|
- suMoneyIncrement := createExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney
|
1995
|
+ //suMoneyIncrement := createExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney
|
|
|
1996
|
+ suMoneyIncrement, _ := decimal.NewFromFloat(createExchangeCashPersonCommand.ExchangedSuMoney).Sub(decimal.NewFromFloat(personFoundExchangedSuMoney)).Float64()
|
1894
|
// 现金增量
|
1997
|
// 现金增量
|
1895
|
- cashIncrement := suMoneyIncrement * activityFound.Rate
|
1998
|
+ //cashIncrement := suMoneyIncrement * activityFound.Rate
|
|
|
1999
|
+ cashIncrement, _ := decimal.NewFromFloat(suMoneyIncrement).Mul(decimal.NewFromFloat(activityFound.Rate)).Float64()
|
1896
|
|
2000
|
|
1897
|
// 判断该员工兑换的素币是否超过本人持有的素币
|
2001
|
// 判断该员工兑换的素币是否超过本人持有的素币
|
1898
|
if suMoneyIncrement > employeeFoundSuMoney {
|
2002
|
if suMoneyIncrement > employeeFoundSuMoney {
|
|
@@ -1907,10 +2011,14 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
|
@@ -1907,10 +2011,14 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
1907
|
}
|
2011
|
}
|
1908
|
|
2012
|
|
1909
|
// 更新兑换素币清单
|
2013
|
// 更新兑换素币清单
|
|
|
2014
|
+ exchangedSuMoney, _ := decimal.NewFromFloat(personFoundExchangedSuMoney).Add(decimal.NewFromFloat(suMoneyIncrement)).Float64()
|
|
|
2015
|
+ exchangedCash, _ := decimal.NewFromFloat(personFoundExchangedCash).Add(decimal.NewFromFloat(cashIncrement)).Float64()
|
1910
|
updateExchangeCashPersonCommand := &command.UpdateExchangeCashPersonCommand{
|
2016
|
updateExchangeCashPersonCommand := &command.UpdateExchangeCashPersonCommand{
|
1911
|
ListId: personFound.ListId,
|
2017
|
ListId: personFound.ListId,
|
1912
|
- ExchangedSuMoney: personFoundExchangedSuMoney + suMoneyIncrement,
|
|
|
1913
|
- ExchangedCash: personFoundExchangedCash + cashIncrement,
|
2018
|
+ //ExchangedSuMoney: personFoundExchangedSuMoney + suMoneyIncrement,
|
|
|
2019
|
+ //ExchangedCash: personFoundExchangedCash + cashIncrement,
|
|
|
2020
|
+ ExchangedSuMoney: exchangedSuMoney,
|
|
|
2021
|
+ ExchangedCash: exchangedCash,
|
1914
|
Operator: createExchangeCashPersonCommand.Operator,
|
2022
|
Operator: createExchangeCashPersonCommand.Operator,
|
1915
|
}
|
2023
|
}
|
1916
|
if err := personFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashPersonCommand)); err != nil {
|
2024
|
if err := personFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashPersonCommand)); err != nil {
|
|
@@ -1946,10 +2054,14 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
|
@@ -1946,10 +2054,14 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
1946
|
}
|
2054
|
}
|
1947
|
|
2055
|
|
1948
|
// 更新兑换活动
|
2056
|
// 更新兑换活动
|
|
|
2057
|
+ newExchangedSuMoney, _ := decimal.NewFromFloat(activityFoundExchangedSuMoney).Add(decimal.NewFromFloat(suMoneyIncrement)).Float64()
|
|
|
2058
|
+ newExchangedCash, _ := decimal.NewFromFloat(activityFoundExchangedCash).Add(decimal.NewFromFloat(cashIncrement)).Float64()
|
1949
|
updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{
|
2059
|
updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{
|
1950
|
ExchangeCashActivityId: personFound.ExchangeCashActivityId,
|
2060
|
ExchangeCashActivityId: personFound.ExchangeCashActivityId,
|
1951
|
- ExchangedSuMoney: activityFoundExchangedSuMoney + suMoneyIncrement,
|
|
|
1952
|
- ExchangedCash: activityFoundExchangedCash + cashIncrement,
|
2061
|
+ //ExchangedSuMoney: activityFoundExchangedSuMoney + suMoneyIncrement,
|
|
|
2062
|
+ //ExchangedCash: activityFoundExchangedCash + cashIncrement,
|
|
|
2063
|
+ ExchangedSuMoney: newExchangedSuMoney,
|
|
|
2064
|
+ ExchangedCash: newExchangedCash,
|
1953
|
Deadline: activityFound.Deadline,
|
2065
|
Deadline: activityFound.Deadline,
|
1954
|
CountDown: activityFound.CountDown,
|
2066
|
CountDown: activityFound.CountDown,
|
1955
|
ExchangeRate: activityFound.Rate,
|
2067
|
ExchangeRate: activityFound.Rate,
|
|
@@ -2058,13 +2170,18 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
|
@@ -2058,13 +2170,18 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
2058
|
if systemExchangedSuMoney == 0 {
|
2170
|
if systemExchangedSuMoney == 0 {
|
2059
|
newRate = 0
|
2171
|
newRate = 0
|
2060
|
} else {
|
2172
|
} else {
|
2061
|
- newRate = (cashPoolFoundExchangedCash + cashIncrement) / systemExchangedSuMoney
|
2173
|
+ //newRate = (cashPoolFoundExchangedCash + cashIncrement) / systemExchangedSuMoney
|
|
|
2174
|
+ newRate, _ = decimal.NewFromFloat(cashPoolFoundExchangedCash).Add(decimal.NewFromFloat(cashIncrement)).Div(decimal.NewFromFloat(systemExchangedSuMoney)).Float64()
|
2062
|
}
|
2175
|
}
|
|
|
2176
|
+ newCashPoolExchangedCash, _ := decimal.NewFromFloat(cashPoolFoundExchangedCash).Add(decimal.NewFromFloat(cashIncrement)).Float64()
|
|
|
2177
|
+ unExchangeCash, _ := decimal.NewFromFloat(cashPoolFoundUnExchangeCash).Sub(decimal.NewFromFloat(cashIncrement)).Float64()
|
2063
|
updateCashPoolCommand := &command.UpdateCashPoolCommand{
|
2178
|
updateCashPoolCommand := &command.UpdateCashPoolCommand{
|
2064
|
CashPoolId: cashPoolFound.CashPoolId,
|
2179
|
CashPoolId: cashPoolFound.CashPoolId,
|
2065
|
Cash: cashPoolFound.Cash,
|
2180
|
Cash: cashPoolFound.Cash,
|
2066
|
- ExchangedCash: cashPoolFoundExchangedCash + cashIncrement,
|
|
|
2067
|
- UnExchangeCash: cashPoolFoundUnExchangeCash - cashIncrement,
|
2181
|
+ //ExchangedCash: cashPoolFoundExchangedCash + cashIncrement,
|
|
|
2182
|
+ //UnExchangeCash: cashPoolFoundUnExchangeCash - cashIncrement,
|
|
|
2183
|
+ ExchangedCash: newCashPoolExchangedCash,
|
|
|
2184
|
+ UnExchangeCash: unExchangeCash,
|
2068
|
ExchangedSuMoney: systemExchangedSuMoney,
|
2185
|
ExchangedSuMoney: systemExchangedSuMoney,
|
2069
|
UnExchangeSuMoney: systemUnExchangeSuMoney,
|
2186
|
UnExchangeSuMoney: systemUnExchangeSuMoney,
|
2070
|
Rate: newRate,
|
2187
|
Rate: newRate,
|
|
@@ -2269,11 +2386,15 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC |
|
@@ -2269,11 +2386,15 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC |
2269
|
}
|
2386
|
}
|
2270
|
|
2387
|
|
2271
|
// 更新兑换活动命令
|
2388
|
// 更新兑换活动命令
|
|
|
2389
|
+ exchangedSuMoney, _ := decimal.NewFromFloat(activityFoundExchangedSuMoney).Add(decimal.NewFromFloat(createExchangeCashPersonCommand.ExchangedSuMoney)).Float64()
|
|
|
2390
|
+ exchangedCash, _ := decimal.NewFromFloat(activityFoundExchangedCash).Add(decimal.NewFromFloat(createExchangeCashPersonCommand.ExchangedSuMoney)).Mul(decimal.NewFromFloat(activityFound.Rate)).Float64()
|
2272
|
updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{
|
2391
|
updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{
|
2273
|
ExchangeCashActivityId: personSaved.ExchangeCashActivityId,
|
2392
|
ExchangeCashActivityId: personSaved.ExchangeCashActivityId,
|
2274
|
ExchangeActivityName: activityFound.ExchangeActivityName,
|
2393
|
ExchangeActivityName: activityFound.ExchangeActivityName,
|
2275
|
- ExchangedSuMoney: activityFoundExchangedSuMoney + createExchangeCashPersonCommand.ExchangedSuMoney,
|
|
|
2276
|
- ExchangedCash: activityFoundExchangedCash + createExchangeCashPersonCommand.ExchangedSuMoney * activityFound.Rate,
|
2394
|
+ //ExchangedSuMoney: activityFoundExchangedSuMoney + createExchangeCashPersonCommand.ExchangedSuMoney,
|
|
|
2395
|
+ //ExchangedCash: activityFoundExchangedCash + createExchangeCashPersonCommand.ExchangedSuMoney * activityFound.Rate,
|
|
|
2396
|
+ ExchangedSuMoney: exchangedSuMoney,
|
|
|
2397
|
+ ExchangedCash: exchangedCash,
|
2277
|
Deadline: activityFound.Deadline,
|
2398
|
Deadline: activityFound.Deadline,
|
2278
|
CountDown: activityFound.CountDown,
|
2399
|
CountDown: activityFound.CountDown,
|
2279
|
ExchangeRate: activityFound.Rate,
|
2400
|
ExchangeRate: activityFound.Rate,
|
|
@@ -2327,15 +2448,20 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC |
|
@@ -2327,15 +2448,20 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC |
2327
|
if systemExchangedSuMoney == 0 {
|
2448
|
if systemExchangedSuMoney == 0 {
|
2328
|
newRate = 0
|
2449
|
newRate = 0
|
2329
|
} else {
|
2450
|
} else {
|
2330
|
- newRate = (cashPoolFoundExchangedCash + personSaved.ExchangedCash) / systemExchangedSuMoney
|
2451
|
+ //newRate = (cashPoolFoundExchangedCash + personSaved.ExchangedCash) / systemExchangedSuMoney
|
|
|
2452
|
+ newRate, _ = decimal.NewFromFloat(cashPoolFoundExchangedCash).Add(decimal.NewFromFloat(personSaved.ExchangedCash)).Div(decimal.NewFromFloat(systemExchangedSuMoney)).Float64()
|
2331
|
}
|
2453
|
}
|
2332
|
|
2454
|
|
2333
|
// 更新现金池命令
|
2455
|
// 更新现金池命令
|
|
|
2456
|
+ newCashPoolExchangedCash, _ := decimal.NewFromFloat(cashPoolFoundExchangedCash).Add(decimal.NewFromFloat(personSaved.ExchangedCash)).Float64()
|
|
|
2457
|
+ unExchangeCash, _ := decimal.NewFromFloat(cashPoolFoundUnExchangeCash).Sub(decimal.NewFromFloat(personSaved.ExchangedCash)).Float64()
|
2334
|
updateCashPoolCommand := &command.UpdateCashPoolCommand{
|
2458
|
updateCashPoolCommand := &command.UpdateCashPoolCommand{
|
2335
|
CashPoolId: cashPoolsFound[0].CashPoolId,
|
2459
|
CashPoolId: cashPoolsFound[0].CashPoolId,
|
2336
|
Cash: cashPoolsFound[0].Cash,
|
2460
|
Cash: cashPoolsFound[0].Cash,
|
2337
|
- ExchangedCash: cashPoolFoundExchangedCash + personSaved.ExchangedCash,
|
|
|
2338
|
- UnExchangeCash: cashPoolFoundUnExchangeCash - personSaved.ExchangedCash,
|
2461
|
+ //ExchangedCash: cashPoolFoundExchangedCash + personSaved.ExchangedCash,
|
|
|
2462
|
+ //UnExchangeCash: cashPoolFoundUnExchangeCash - personSaved.ExchangedCash,
|
|
|
2463
|
+ ExchangedCash: newCashPoolExchangedCash,
|
|
|
2464
|
+ UnExchangeCash: unExchangeCash,
|
2339
|
ExchangedSuMoney: systemExchangedSuMoney,
|
2465
|
ExchangedSuMoney: systemExchangedSuMoney,
|
2340
|
UnExchangeSuMoney: systemUnExchangeSuMoney,
|
2466
|
UnExchangeSuMoney: systemUnExchangeSuMoney,
|
2341
|
Rate: newRate,
|
2467
|
Rate: newRate,
|
|
@@ -2606,10 +2732,14 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC |
|
@@ -2606,10 +2732,14 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC |
2606
|
}
|
2732
|
}
|
2607
|
|
2733
|
|
2608
|
// 更新兑换素币活动命令
|
2734
|
// 更新兑换素币活动命令
|
|
|
2735
|
+ exchangedSuMoney, _ := decimal.NewFromFloat(activityFoundExchangedSuMoney).Sub(decimal.NewFromFloat(personFoundExchangedSuMoney)).Float64()
|
|
|
2736
|
+ exchangedCash, _ := decimal.NewFromFloat(activityFoundExchangedCash).Sub(decimal.NewFromFloat(personFoundExchangedCash)).Float64()
|
2609
|
updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{
|
2737
|
updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{
|
2610
|
ExchangeCashActivityId: personFound.ExchangeCashActivityId,
|
2738
|
ExchangeCashActivityId: personFound.ExchangeCashActivityId,
|
2611
|
- ExchangedSuMoney: activityFoundExchangedSuMoney - personFoundExchangedSuMoney,
|
|
|
2612
|
- ExchangedCash: activityFoundExchangedCash - personFoundExchangedCash,
|
2739
|
+ //ExchangedSuMoney: activityFoundExchangedSuMoney - personFoundExchangedSuMoney,
|
|
|
2740
|
+ //ExchangedCash: activityFoundExchangedCash - personFoundExchangedCash,
|
|
|
2741
|
+ ExchangedSuMoney: exchangedSuMoney,
|
|
|
2742
|
+ ExchangedCash: exchangedCash,
|
2613
|
Deadline: activityFound.Deadline,
|
2743
|
Deadline: activityFound.Deadline,
|
2614
|
CountDown: activityFound.CountDown,
|
2744
|
CountDown: activityFound.CountDown,
|
2615
|
ExchangeRate: activityFound.Rate,
|
2745
|
ExchangeRate: activityFound.Rate,
|
|
@@ -2677,16 +2807,21 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC |
|
@@ -2677,16 +2807,21 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC |
2677
|
if systemExchangedSuMoney == 0 {
|
2807
|
if systemExchangedSuMoney == 0 {
|
2678
|
newRate = 0
|
2808
|
newRate = 0
|
2679
|
} else {
|
2809
|
} else {
|
2680
|
- newRate = (cashPoolFoundExchangedCash - personFoundExchangedCash) / systemExchangedSuMoney
|
2810
|
+ //newRate = (cashPoolFoundExchangedCash - personFoundExchangedCash) / systemExchangedSuMoney
|
|
|
2811
|
+ newRate, _ = decimal.NewFromFloat(cashPoolFoundExchangedCash).Sub(decimal.NewFromFloat(personFoundExchangedCash)).Div(decimal.NewFromFloat(systemExchangedSuMoney)).Float64()
|
2681
|
}
|
2812
|
}
|
2682
|
|
2813
|
|
2683
|
// 更新现金池命令
|
2814
|
// 更新现金池命令
|
|
|
2815
|
+ newExchangedCash, _ := decimal.NewFromFloat(cashPoolFoundExchangedCash).Sub(decimal.NewFromFloat(personFoundExchangedCash)).Float64()
|
|
|
2816
|
+ UnExchangeCash, _ := decimal.NewFromFloat(cashPoolFoundUnExchangeCash).Add(decimal.NewFromFloat(personFoundExchangedCash)).Float64()
|
2684
|
updateCashPoolCommand := &command.UpdateCashPoolCommand{
|
2817
|
updateCashPoolCommand := &command.UpdateCashPoolCommand{
|
2685
|
CashPoolId: cashPoolsFound[0].CashPoolId,
|
2818
|
CashPoolId: cashPoolsFound[0].CashPoolId,
|
2686
|
Cash: cashPoolsFound[0].Cash,
|
2819
|
Cash: cashPoolsFound[0].Cash,
|
2687
|
LastRate: cashPoolsFound[0].LastRate,
|
2820
|
LastRate: cashPoolsFound[0].LastRate,
|
2688
|
- ExchangedCash: cashPoolFoundExchangedCash - personFoundExchangedCash,
|
|
|
2689
|
- UnExchangeCash: cashPoolFoundUnExchangeCash + personFoundExchangedCash,
|
2821
|
+ //ExchangedCash: cashPoolFoundExchangedCash - personFoundExchangedCash,
|
|
|
2822
|
+ //UnExchangeCash: cashPoolFoundUnExchangeCash + personFoundExchangedCash,
|
|
|
2823
|
+ ExchangedCash: newExchangedCash,
|
|
|
2824
|
+ UnExchangeCash: UnExchangeCash,
|
2690
|
Rate: newRate,
|
2825
|
Rate: newRate,
|
2691
|
ExchangedSuMoney: systemExchangedSuMoney,
|
2826
|
ExchangedSuMoney: systemExchangedSuMoney,
|
2692
|
UnExchangeSuMoney: systemUnExchangeSuMoney,
|
2827
|
UnExchangeSuMoney: systemUnExchangeSuMoney,
|