|
@@ -62,7 +62,7 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co |
|
@@ -62,7 +62,7 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co |
62
|
|
62
|
|
63
|
// 现金池仓储初始化
|
63
|
// 现金池仓储初始化
|
64
|
var cashPoolRepository domain.CashPoolRepository
|
64
|
var cashPoolRepository domain.CashPoolRepository
|
65
|
- if value, err := factory.CreateCashPoolRepository(map[string] interface{} {
|
65
|
+ if value, err := factory.CreateCashPoolRepository(map[string]interface{}{
|
66
|
"transactionContext": transactionContext,
|
66
|
"transactionContext": transactionContext,
|
67
|
}); err != nil {
|
67
|
}); err != nil {
|
68
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
68
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
@@ -97,19 +97,19 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co |
|
@@ -97,19 +97,19 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co |
97
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
97
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
98
|
}
|
98
|
}
|
99
|
systemExchangedSuMoney := systemSuMoneyStatistics["systemExchangedSuMoney"].(float64) // 平台已兑换素币
|
99
|
systemExchangedSuMoney := systemSuMoneyStatistics["systemExchangedSuMoney"].(float64) // 平台已兑换素币
|
100
|
- systemUnExchangeSuMoney := systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64) // 平台未兑换素币
|
100
|
+ systemUnExchangeSuMoney := systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64) // 平台未兑换素币
|
101
|
|
101
|
|
102
|
// 获取当前公司现金池
|
102
|
// 获取当前公司现金池
|
103
|
count, cashPools, err := cashPoolRepository.Find(tool_funs.SimpleStructToMap(createCashPoolCommand))
|
103
|
count, cashPools, err := cashPoolRepository.Find(tool_funs.SimpleStructToMap(createCashPoolCommand))
|
104
|
if err != nil {
|
104
|
if err != nil {
|
105
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
105
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
106
|
}
|
106
|
}
|
107
|
- if len(cashPools) > 0 { // 更新现金池
|
107
|
+ if len(cashPools) > 0 { // 更新现金池
|
108
|
cashPoolExchangeCash := cashPools[0].ExchangedCash
|
108
|
cashPoolExchangeCash := cashPools[0].ExchangedCash
|
109
|
cashPoolUnExchangeCash := cashPools[0].UnExchangeCash
|
109
|
cashPoolUnExchangeCash := cashPools[0].UnExchangeCash
|
110
|
cashPoolCash := cashPools[0].Cash
|
110
|
cashPoolCash := cashPools[0].Cash
|
111
|
|
111
|
|
112
|
- if createCashPoolCommand.Cash < cashPoolExchangeCash {
|
112
|
+ if createCashPoolCommand.Cash < cashPoolExchangeCash {
|
113
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "投入的现金值必须大于当前已兑换现金值")
|
113
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "投入的现金值必须大于当前已兑换现金值")
|
114
|
}
|
114
|
}
|
115
|
|
115
|
|
|
@@ -125,16 +125,16 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co |
|
@@ -125,16 +125,16 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co |
125
|
var lastActivityRate float64
|
125
|
var lastActivityRate float64
|
126
|
listExchangeCashActivityQuery := map[string]interface{}{
|
126
|
listExchangeCashActivityQuery := map[string]interface{}{
|
127
|
"companyId": createCashPoolCommand.CompanyId,
|
127
|
"companyId": createCashPoolCommand.CompanyId,
|
128
|
- "order": "deadline DESC",
|
|
|
129
|
- "nearest": true,
|
|
|
130
|
- "limit": 1,
|
128
|
+ "order": "deadline DESC",
|
|
|
129
|
+ "nearest": true,
|
|
|
130
|
+ "limit": 1,
|
131
|
}
|
131
|
}
|
132
|
if _, activities, err := exchangeActivityRepository.Find(listExchangeCashActivityQuery); err != nil {
|
132
|
if _, activities, err := exchangeActivityRepository.Find(listExchangeCashActivityQuery); err != nil {
|
133
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
133
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
134
|
} else {
|
134
|
} else {
|
135
|
if len(activities) > 0 {
|
135
|
if len(activities) > 0 {
|
136
|
lastActivityRate = activities[0].Rate
|
136
|
lastActivityRate = activities[0].Rate
|
137
|
- } else { // 未查询到相关兑换活动
|
137
|
+ } else { // 未查询到相关兑换活动
|
138
|
lastActivityRate = 0
|
138
|
lastActivityRate = 0
|
139
|
}
|
139
|
}
|
140
|
}
|
140
|
}
|
|
@@ -143,15 +143,15 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co |
|
@@ -143,15 +143,15 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co |
143
|
|
143
|
|
144
|
// 更新现金池命令
|
144
|
// 更新现金池命令
|
145
|
updateCashPoolCommand := &command.UpdateCashPoolCommand{
|
145
|
updateCashPoolCommand := &command.UpdateCashPoolCommand{
|
146
|
- CashPoolId: cashPools[0].CashPoolId,
|
|
|
147
|
- Cash: createCashPoolCommand.Cash,
|
146
|
+ CashPoolId: cashPools[0].CashPoolId,
|
|
|
147
|
+ Cash: createCashPoolCommand.Cash,
|
148
|
ExchangedCash: cashPoolExchangeCash,
|
148
|
ExchangedCash: cashPoolExchangeCash,
|
149
|
//UnExchangeCash: cashPoolUnExchangeCash + (createCashPoolCommand.Cash - cashPoolCash),
|
149
|
//UnExchangeCash: cashPoolUnExchangeCash + (createCashPoolCommand.Cash - cashPoolCash),
|
150
|
- UnExchangeCash: unExchangeCash,
|
|
|
151
|
- ExchangedSuMoney: systemExchangedSuMoney,
|
150
|
+ UnExchangeCash: unExchangeCash,
|
|
|
151
|
+ ExchangedSuMoney: systemExchangedSuMoney,
|
152
|
UnExchangeSuMoney: systemUnExchangeSuMoney,
|
152
|
UnExchangeSuMoney: systemUnExchangeSuMoney,
|
153
|
- Rate: newRate,
|
|
|
154
|
- LastRate: lastActivityRate,
|
153
|
+ Rate: newRate,
|
|
|
154
|
+ LastRate: lastActivityRate,
|
155
|
}
|
155
|
}
|
156
|
|
156
|
|
157
|
// 更新现金池
|
157
|
// 更新现金池
|
|
@@ -180,36 +180,36 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co |
|
@@ -180,36 +180,36 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co |
180
|
cashPool.LastRate, _ = decimal.NewFromFloatWithExponent(cashPool.LastRate, -2).Float64()
|
180
|
cashPool.LastRate, _ = decimal.NewFromFloatWithExponent(cashPool.LastRate, -2).Float64()
|
181
|
return cashPool, nil
|
181
|
return cashPool, nil
|
182
|
}
|
182
|
}
|
183
|
- } else { // 新增现金池
|
183
|
+ } else { // 新增现金池
|
184
|
// 获取上次兑换活动兑换汇率查询
|
184
|
// 获取上次兑换活动兑换汇率查询
|
185
|
var lastActivityRate float64
|
185
|
var lastActivityRate float64
|
186
|
listExchangeCashActivityQuery := map[string]interface{}{
|
186
|
listExchangeCashActivityQuery := map[string]interface{}{
|
187
|
"companyId": createCashPoolCommand.CompanyId,
|
187
|
"companyId": createCashPoolCommand.CompanyId,
|
188
|
- "order": "deadline DESC",
|
|
|
189
|
- "nearest": true,
|
|
|
190
|
- "limit": 1,
|
188
|
+ "order": "deadline DESC",
|
|
|
189
|
+ "nearest": true,
|
|
|
190
|
+ "limit": 1,
|
191
|
}
|
191
|
}
|
192
|
if _, activities, err := exchangeActivityRepository.Find(listExchangeCashActivityQuery); err != nil {
|
192
|
if _, activities, err := exchangeActivityRepository.Find(listExchangeCashActivityQuery); err != nil {
|
193
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
193
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
194
|
} else {
|
194
|
} else {
|
195
|
if len(activities) > 0 {
|
195
|
if len(activities) > 0 {
|
196
|
lastActivityRate = activities[0].Rate
|
196
|
lastActivityRate = activities[0].Rate
|
197
|
- } else { // 未查询到相关兑换活动
|
197
|
+ } else { // 未查询到相关兑换活动
|
198
|
lastActivityRate = 0
|
198
|
lastActivityRate = 0
|
199
|
}
|
199
|
}
|
200
|
}
|
200
|
}
|
201
|
|
201
|
|
202
|
// 更新现金池
|
202
|
// 更新现金池
|
203
|
newCashPool := &domain.CashPool{
|
203
|
newCashPool := &domain.CashPool{
|
204
|
- CompanyId: createCashPoolCommand.CompanyId,
|
|
|
205
|
- Cash: createCashPoolCommand.Cash,
|
|
|
206
|
- ExchangedCash: 0,
|
|
|
207
|
- UnExchangeCash: createCashPoolCommand.Cash,
|
|
|
208
|
- ExchangedSuMoney: systemExchangedSuMoney,
|
204
|
+ CompanyId: createCashPoolCommand.CompanyId,
|
|
|
205
|
+ Cash: createCashPoolCommand.Cash,
|
|
|
206
|
+ ExchangedCash: 0,
|
|
|
207
|
+ UnExchangeCash: createCashPoolCommand.Cash,
|
|
|
208
|
+ ExchangedSuMoney: systemExchangedSuMoney,
|
209
|
UnExchangeSuMoney: systemUnExchangeSuMoney,
|
209
|
UnExchangeSuMoney: systemUnExchangeSuMoney,
|
210
|
- LastRate: lastActivityRate,
|
|
|
211
|
- Rate: 0,
|
|
|
212
|
- CreateTime: time.Now().Local(),
|
210
|
+ LastRate: lastActivityRate,
|
|
|
211
|
+ Rate: 0,
|
|
|
212
|
+ CreateTime: time.Now().Local(),
|
213
|
}
|
213
|
}
|
214
|
if cashPool, err := cashPoolRepository.Save(newCashPool); err != nil {
|
214
|
if cashPool, err := cashPoolRepository.Save(newCashPool); err != nil {
|
215
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
215
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
@@ -271,7 +271,7 @@ func (cashPoolService *CashPoolService) GetCashPool(getCashPoolQuery *query.GetC |
|
@@ -271,7 +271,7 @@ func (cashPoolService *CashPoolService) GetCashPool(getCashPoolQuery *query.GetC |
271
|
|
271
|
|
272
|
// 现金池仓储初始化
|
272
|
// 现金池仓储初始化
|
273
|
var cashPoolRepository domain.CashPoolRepository
|
273
|
var cashPoolRepository domain.CashPoolRepository
|
274
|
- if value, err := factory.CreateCashPoolRepository(map[string] interface{} {
|
274
|
+ if value, err := factory.CreateCashPoolRepository(map[string]interface{}{
|
275
|
"transactionContext": transactionContext,
|
275
|
"transactionContext": transactionContext,
|
276
|
}); err != nil {
|
276
|
}); err != nil {
|
277
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
277
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
@@ -304,16 +304,16 @@ func (cashPoolService *CashPoolService) GetCashPool(getCashPoolQuery *query.GetC |
|
@@ -304,16 +304,16 @@ func (cashPoolService *CashPoolService) GetCashPool(getCashPoolQuery *query.GetC |
304
|
var lastActivityRate float64
|
304
|
var lastActivityRate float64
|
305
|
listExchangeCashActivityQuery := map[string]interface{}{
|
305
|
listExchangeCashActivityQuery := map[string]interface{}{
|
306
|
"companyId": getCashPoolQuery.CompanyId,
|
306
|
"companyId": getCashPoolQuery.CompanyId,
|
307
|
- "order": "deadline DESC",
|
|
|
308
|
- "nearest": true,
|
|
|
309
|
- "limit": 1,
|
307
|
+ "order": "deadline DESC",
|
|
|
308
|
+ "nearest": true,
|
|
|
309
|
+ "limit": 1,
|
310
|
}
|
310
|
}
|
311
|
if _, activities, err := exchangeActivityRepository.Find(listExchangeCashActivityQuery); err != nil {
|
311
|
if _, activities, err := exchangeActivityRepository.Find(listExchangeCashActivityQuery); err != nil {
|
312
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
312
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
313
|
} else {
|
313
|
} else {
|
314
|
if len(activities) > 0 {
|
314
|
if len(activities) > 0 {
|
315
|
lastActivityRate = activities[0].Rate
|
315
|
lastActivityRate = activities[0].Rate
|
316
|
- } else { // 未查询到相关兑换活动
|
316
|
+ } else { // 未查询到相关兑换活动
|
317
|
lastActivityRate = 0
|
317
|
lastActivityRate = 0
|
318
|
}
|
318
|
}
|
319
|
}
|
319
|
}
|
|
@@ -327,7 +327,7 @@ func (cashPoolService *CashPoolService) GetCashPool(getCashPoolQuery *query.GetC |
|
@@ -327,7 +327,7 @@ func (cashPoolService *CashPoolService) GetCashPool(getCashPoolQuery *query.GetC |
327
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的公司")
|
327
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的公司")
|
328
|
}
|
328
|
}
|
329
|
//systemUnExchangeSuMoney, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64)), 64) // 平台未兑换素币
|
329
|
//systemUnExchangeSuMoney, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64)), 64) // 平台未兑换素币
|
330
|
- systemUnExchangeSuMoney, _ := decimal.NewFromFloatWithExponent(systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64), -2).Float64() // 平台未兑换素币
|
330
|
+ systemUnExchangeSuMoney, _ := decimal.NewFromFloatWithExponent(systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64), -2).Float64() // 平台未兑换素币
|
331
|
|
331
|
|
332
|
// 查找当前公司现金池
|
332
|
// 查找当前公司现金池
|
333
|
if count, cashPools, err := cashPoolRepository.Find(tool_funs.SimpleStructToMap(getCashPoolQuery)); err != nil {
|
333
|
if count, cashPools, err := cashPoolRepository.Find(tool_funs.SimpleStructToMap(getCashPoolQuery)); err != nil {
|
|
@@ -338,17 +338,17 @@ func (cashPoolService *CashPoolService) GetCashPool(getCashPoolQuery *query.GetC |
|
@@ -338,17 +338,17 @@ func (cashPoolService *CashPoolService) GetCashPool(getCashPoolQuery *query.GetC |
338
|
}
|
338
|
}
|
339
|
// 现金池为空时处理
|
339
|
// 现金池为空时处理
|
340
|
if count == 0 {
|
340
|
if count == 0 {
|
341
|
- return map[string] interface{} {
|
|
|
342
|
- "cashPoolId": 0,
|
|
|
343
|
- "cash": 0,
|
|
|
344
|
- "companyId": getCashPoolQuery.CompanyId,
|
|
|
345
|
- "exchangedCash": 0,
|
|
|
346
|
- "unExchangeCash": 0,
|
|
|
347
|
- "exchangedSuMoney": 0,
|
341
|
+ return map[string]interface{}{
|
|
|
342
|
+ "cashPoolId": 0,
|
|
|
343
|
+ "cash": 0,
|
|
|
344
|
+ "companyId": getCashPoolQuery.CompanyId,
|
|
|
345
|
+ "exchangedCash": 0,
|
|
|
346
|
+ "unExchangeCash": 0,
|
|
|
347
|
+ "exchangedSuMoney": 0,
|
348
|
"unExchangeSuMoney": systemUnExchangeSuMoney,
|
348
|
"unExchangeSuMoney": systemUnExchangeSuMoney,
|
349
|
- "rate": 0, // 平均兑换汇率
|
|
|
350
|
- "lastRate": 0, // 上期活动兑换汇率
|
|
|
351
|
- "createTime": time.Now().Local(),
|
349
|
+ "rate": 0, // 平均兑换汇率
|
|
|
350
|
+ "lastRate": 0, // 上期活动兑换汇率
|
|
|
351
|
+ "createTime": time.Now().Local(),
|
352
|
}, nil
|
352
|
}, nil
|
353
|
} else {
|
353
|
} else {
|
354
|
//cashPools[0].Rate, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", cashPools[0].Rate), 64)
|
354
|
//cashPools[0].Rate, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", cashPools[0].Rate), 64)
|
|
@@ -426,13 +426,13 @@ func (cashPoolService *CashPoolService) CreateExchangeCashActivity(createExchang |
|
@@ -426,13 +426,13 @@ func (cashPoolService *CashPoolService) CreateExchangeCashActivity(createExchang |
426
|
// 创建兑换活动命令
|
426
|
// 创建兑换活动命令
|
427
|
newActivity := &domain.ExchangeCashActivity{
|
427
|
newActivity := &domain.ExchangeCashActivity{
|
428
|
ExchangeActivityName: createExchangeCashActivityCommand.ExchangeActivityName,
|
428
|
ExchangeActivityName: createExchangeCashActivityCommand.ExchangeActivityName,
|
429
|
- CompanyId: createExchangeCashActivityCommand.CompanyId,
|
|
|
430
|
- ExchangedCash: 0,
|
|
|
431
|
- ExchangedSuMoney: 0,
|
|
|
432
|
- Deadline: t2,
|
|
|
433
|
- CountDown: int64(math.Ceil(t2.Sub(t1).Hours() / 24)), // 计算活动截止倒计时
|
|
|
434
|
- Rate: createExchangeCashActivityCommand.ExchangeRate,
|
|
|
435
|
- CreateTime: time.Now().Local(),
|
429
|
+ CompanyId: createExchangeCashActivityCommand.CompanyId,
|
|
|
430
|
+ ExchangedCash: 0,
|
|
|
431
|
+ ExchangedSuMoney: 0,
|
|
|
432
|
+ Deadline: t2,
|
|
|
433
|
+ CountDown: int64(math.Ceil(t2.Sub(t1).Hours() / 24)), // 计算活动截止倒计时
|
|
|
434
|
+ Rate: createExchangeCashActivityCommand.ExchangeRate,
|
|
|
435
|
+ CreateTime: time.Now().Local(),
|
436
|
}
|
436
|
}
|
437
|
|
437
|
|
438
|
// 倒计时结束判断
|
438
|
// 倒计时结束判断
|
|
@@ -543,13 +543,13 @@ func (cashPoolService *CashPoolService) SearchExchangeCashActivity(activityComma |
|
@@ -543,13 +543,13 @@ func (cashPoolService *CashPoolService) SearchExchangeCashActivity(activityComma |
543
|
var t2 = activity.Deadline
|
543
|
var t2 = activity.Deadline
|
544
|
|
544
|
|
545
|
// 获取兑换活动前先更新兑换活动倒计时命令
|
545
|
// 获取兑换活动前先更新兑换活动倒计时命令
|
546
|
- updateExchangeCashActivity := &command.UpdateExchangeCashActivityCommand {
|
546
|
+ updateExchangeCashActivity := &command.UpdateExchangeCashActivityCommand{
|
547
|
ExchangeCashActivityId: activity.ActivityId,
|
547
|
ExchangeCashActivityId: activity.ActivityId,
|
548
|
- CountDown: int64(math.Ceil(t2.Sub(t1).Hours() / 24)), // 计算倒计时
|
|
|
549
|
- Deadline: activity.Deadline,
|
|
|
550
|
- ExchangedSuMoney: activity.ExchangedSuMoney,
|
|
|
551
|
- ExchangedCash: activity.ExchangedCash,
|
|
|
552
|
- ExchangeRate: activity.Rate,
|
548
|
+ CountDown: int64(math.Ceil(t2.Sub(t1).Hours() / 24)), // 计算倒计时
|
|
|
549
|
+ Deadline: activity.Deadline,
|
|
|
550
|
+ ExchangedSuMoney: activity.ExchangedSuMoney,
|
|
|
551
|
+ ExchangedCash: activity.ExchangedCash,
|
|
|
552
|
+ ExchangeRate: activity.Rate,
|
553
|
}
|
553
|
}
|
554
|
|
554
|
|
555
|
// 倒计时结束处理
|
555
|
// 倒计时结束处理
|
|
@@ -579,16 +579,16 @@ func (cashPoolService *CashPoolService) SearchExchangeCashActivity(activityComma |
|
@@ -579,16 +579,16 @@ func (cashPoolService *CashPoolService) SearchExchangeCashActivity(activityComma |
579
|
//suMoney, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", activity.ExchangedSuMoney), 64)
|
579
|
//suMoney, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", activity.ExchangedSuMoney), 64)
|
580
|
cash, _ := decimal.NewFromFloatWithExponent(activity.ExchangedCash, -2).Float64()
|
580
|
cash, _ := decimal.NewFromFloatWithExponent(activity.ExchangedCash, -2).Float64()
|
581
|
suMoney, _ := decimal.NewFromFloatWithExponent(activity.ExchangedSuMoney, -2).Float64()
|
581
|
suMoney, _ := decimal.NewFromFloatWithExponent(activity.ExchangedSuMoney, -2).Float64()
|
582
|
- activityFormat := map[string]interface{} {
|
|
|
583
|
- "activityId": activity.ActivityId,
|
582
|
+ activityFormat := map[string]interface{}{
|
|
|
583
|
+ "activityId": activity.ActivityId,
|
584
|
"exchangeActivityName": activity.ExchangeActivityName,
|
584
|
"exchangeActivityName": activity.ExchangeActivityName,
|
585
|
- "companyId": activity.CompanyId,
|
|
|
586
|
- "exchangedCash": cash,
|
|
|
587
|
- "exchangedSuMoney": suMoney,
|
|
|
588
|
- "deadline": activity.Deadline.Local(),
|
|
|
589
|
- "countDown": activity.CountDown,
|
|
|
590
|
- "rate": activity.Rate,
|
|
|
591
|
- "createTime": activity.CreateTime.Local(),
|
585
|
+ "companyId": activity.CompanyId,
|
|
|
586
|
+ "exchangedCash": cash,
|
|
|
587
|
+ "exchangedSuMoney": suMoney,
|
|
|
588
|
+ "deadline": activity.Deadline.Local(),
|
|
|
589
|
+ "countDown": activity.CountDown,
|
|
|
590
|
+ "rate": activity.Rate,
|
|
|
591
|
+ "createTime": activity.CreateTime.Local(),
|
592
|
}
|
592
|
}
|
593
|
activitiesFormat = append(activitiesFormat, activityFormat)
|
593
|
activitiesFormat = append(activitiesFormat, activityFormat)
|
594
|
}
|
594
|
}
|
|
@@ -598,7 +598,7 @@ func (cashPoolService *CashPoolService) SearchExchangeCashActivity(activityComma |
|
@@ -598,7 +598,7 @@ func (cashPoolService *CashPoolService) SearchExchangeCashActivity(activityComma |
598
|
}
|
598
|
}
|
599
|
|
599
|
|
600
|
return map[string]interface{}{
|
600
|
return map[string]interface{}{
|
601
|
- "count": count,
|
601
|
+ "count": count,
|
602
|
"activities": activitiesFormat,
|
602
|
"activities": activitiesFormat,
|
603
|
}, nil
|
603
|
}, nil
|
604
|
}
|
604
|
}
|
|
@@ -633,12 +633,12 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas |
|
@@ -633,12 +633,12 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas |
633
|
|
633
|
|
634
|
// 查找兑换现金活动
|
634
|
// 查找兑换现金活动
|
635
|
if count, activitiesFound, err := exchangeActivityRepository.Find(map[string]interface{}{
|
635
|
if count, activitiesFound, err := exchangeActivityRepository.Find(map[string]interface{}{
|
636
|
- "companyId": listExchangeCashActivityQuery.CompanyId,
|
636
|
+ "companyId": listExchangeCashActivityQuery.CompanyId,
|
637
|
"activityNameMatch": listExchangeCashActivityQuery.ActivityNameMatch,
|
637
|
"activityNameMatch": listExchangeCashActivityQuery.ActivityNameMatch,
|
638
|
- "offset": listExchangeCashActivityQuery.Offset,
|
|
|
639
|
- "limit": listExchangeCashActivityQuery.Limit,
|
|
|
640
|
- "countdown": 0,
|
|
|
641
|
- "isEnd": listExchangeCashActivityQuery.IsEnd,
|
638
|
+ "offset": listExchangeCashActivityQuery.Offset,
|
|
|
639
|
+ "limit": listExchangeCashActivityQuery.Limit,
|
|
|
640
|
+ "countdown": 0,
|
|
|
641
|
+ "isEnd": listExchangeCashActivityQuery.IsEnd,
|
642
|
}); err != nil {
|
642
|
}); err != nil {
|
643
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
643
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
644
|
} else {
|
644
|
} else {
|
|
@@ -647,13 +647,13 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas |
|
@@ -647,13 +647,13 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas |
647
|
var t2 = activityFound.Deadline.Local()
|
647
|
var t2 = activityFound.Deadline.Local()
|
648
|
|
648
|
|
649
|
// 更新兑换现金活动倒计时命令
|
649
|
// 更新兑换现金活动倒计时命令
|
650
|
- updateExchangeCashActivity := &command.UpdateExchangeCashActivityCommand {
|
650
|
+ updateExchangeCashActivity := &command.UpdateExchangeCashActivityCommand{
|
651
|
ExchangeCashActivityId: activityFound.ActivityId,
|
651
|
ExchangeCashActivityId: activityFound.ActivityId,
|
652
|
- CountDown: int64(math.Ceil(t2.Sub(t1).Hours() / 24)),
|
|
|
653
|
- Deadline: activityFound.Deadline.Local(),
|
|
|
654
|
- ExchangedSuMoney: activityFound.ExchangedSuMoney,
|
|
|
655
|
- ExchangedCash: activityFound.ExchangedCash,
|
|
|
656
|
- ExchangeRate: activityFound.Rate,
|
652
|
+ CountDown: int64(math.Ceil(t2.Sub(t1).Hours() / 24)),
|
|
|
653
|
+ Deadline: activityFound.Deadline.Local(),
|
|
|
654
|
+ ExchangedSuMoney: activityFound.ExchangedSuMoney,
|
|
|
655
|
+ ExchangedCash: activityFound.ExchangedCash,
|
|
|
656
|
+ ExchangeRate: activityFound.Rate,
|
657
|
}
|
657
|
}
|
658
|
|
658
|
|
659
|
// 倒计时结束处理
|
659
|
// 倒计时结束处理
|
|
@@ -684,16 +684,16 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas |
|
@@ -684,16 +684,16 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas |
684
|
//suMoney, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", activityFound.ExchangedSuMoney), 64)
|
684
|
//suMoney, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", activityFound.ExchangedSuMoney), 64)
|
685
|
cash, _ := decimal.NewFromFloatWithExponent(activityFound.ExchangedCash, -2).Float64()
|
685
|
cash, _ := decimal.NewFromFloatWithExponent(activityFound.ExchangedCash, -2).Float64()
|
686
|
suMoney, _ := decimal.NewFromFloatWithExponent(activityFound.ExchangedSuMoney, -2).Float64()
|
686
|
suMoney, _ := decimal.NewFromFloatWithExponent(activityFound.ExchangedSuMoney, -2).Float64()
|
687
|
- activityWithTs := map[string]interface{} {
|
|
|
688
|
- "activityId": activityFound.ActivityId,
|
687
|
+ activityWithTs := map[string]interface{}{
|
|
|
688
|
+ "activityId": activityFound.ActivityId,
|
689
|
"exchangeActivityName": activityFound.ExchangeActivityName,
|
689
|
"exchangeActivityName": activityFound.ExchangeActivityName,
|
690
|
- "companyId": activityFound.CompanyId,
|
|
|
691
|
- "exchangedCash": cash,
|
|
|
692
|
- "exchangedSuMoney": suMoney,
|
|
|
693
|
- "deadline": activityFound.Deadline.Local().UnixNano() / 1e6, // 秒级时间戳转换
|
|
|
694
|
- "countDown": activityFound.CountDown,
|
|
|
695
|
- "rate": activityFound.Rate,
|
|
|
696
|
- "createTime": activityFound.CreateTime.Local(),
|
690
|
+ "companyId": activityFound.CompanyId,
|
|
|
691
|
+ "exchangedCash": cash,
|
|
|
692
|
+ "exchangedSuMoney": suMoney,
|
|
|
693
|
+ "deadline": activityFound.Deadline.Local().UnixNano() / 1e6, // 秒级时间戳转换
|
|
|
694
|
+ "countDown": activityFound.CountDown,
|
|
|
695
|
+ "rate": activityFound.Rate,
|
|
|
696
|
+ "createTime": activityFound.CreateTime.Local(),
|
697
|
}
|
697
|
}
|
698
|
activitiesWithTs = append(activitiesWithTs, activityWithTs)
|
698
|
activitiesWithTs = append(activitiesWithTs, activityWithTs)
|
699
|
}
|
699
|
}
|
|
@@ -703,7 +703,7 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas |
|
@@ -703,7 +703,7 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas |
703
|
}
|
703
|
}
|
704
|
|
704
|
|
705
|
return map[string]interface{}{
|
705
|
return map[string]interface{}{
|
706
|
- "count": count,
|
706
|
+ "count": count,
|
707
|
"activities": activitiesWithTs,
|
707
|
"activities": activitiesWithTs,
|
708
|
}, nil
|
708
|
}, nil
|
709
|
}
|
709
|
}
|
|
@@ -798,13 +798,13 @@ func (cashPoolService *CashPoolService) GetExchangeCashActivity(getExchangeCashA |
|
@@ -798,13 +798,13 @@ func (cashPoolService *CashPoolService) GetExchangeCashActivity(getExchangeCashA |
798
|
var t2 = activityFound.Deadline
|
798
|
var t2 = activityFound.Deadline
|
799
|
|
799
|
|
800
|
// 更新兑换现金活动倒计时命令
|
800
|
// 更新兑换现金活动倒计时命令
|
801
|
- updateExchangeCashActivity := &command.UpdateExchangeCashActivityCommand {
|
801
|
+ updateExchangeCashActivity := &command.UpdateExchangeCashActivityCommand{
|
802
|
ExchangeCashActivityId: activityFound.ActivityId,
|
802
|
ExchangeCashActivityId: activityFound.ActivityId,
|
803
|
- CountDown: int64(math.Ceil(t2.Sub(t1).Hours() / 24)),
|
|
|
804
|
- Deadline: activityFound.Deadline,
|
|
|
805
|
- ExchangedSuMoney: activityFound.ExchangedSuMoney,
|
|
|
806
|
- ExchangedCash: activityFound.ExchangedCash,
|
|
|
807
|
- ExchangeRate: activityFound.Rate,
|
803
|
+ CountDown: int64(math.Ceil(t2.Sub(t1).Hours() / 24)),
|
|
|
804
|
+ Deadline: activityFound.Deadline,
|
|
|
805
|
+ ExchangedSuMoney: activityFound.ExchangedSuMoney,
|
|
|
806
|
+ ExchangedCash: activityFound.ExchangedCash,
|
|
|
807
|
+ ExchangeRate: activityFound.Rate,
|
808
|
}
|
808
|
}
|
809
|
|
809
|
|
810
|
// 倒计时结束处理
|
810
|
// 倒计时结束处理
|
|
@@ -877,7 +877,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
|
@@ -877,7 +877,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
877
|
|
877
|
|
878
|
// 现金池仓储初始化
|
878
|
// 现金池仓储初始化
|
879
|
var cashPoolRepository domain.CashPoolRepository
|
879
|
var cashPoolRepository domain.CashPoolRepository
|
880
|
- if value, err := factory.CreateCashPoolRepository(map[string] interface{} {
|
880
|
+ if value, err := factory.CreateCashPoolRepository(map[string]interface{}{
|
881
|
"transactionContext": transactionContext,
|
881
|
"transactionContext": transactionContext,
|
882
|
}); err != nil {
|
882
|
}); err != nil {
|
883
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
883
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
@@ -903,8 +903,8 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
|
@@ -903,8 +903,8 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
903
|
if activityFound == nil {
|
903
|
if activityFound == nil {
|
904
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateExchangeCashActivityCommand.ExchangeCashActivityId)))
|
904
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateExchangeCashActivityCommand.ExchangeCashActivityId)))
|
905
|
}
|
905
|
}
|
906
|
- activityFoundExchangedSuMoney := activityFound.ExchangedSuMoney // 当前活动已兑换素币
|
|
|
907
|
- activityFoundExchangedCash := activityFound.ExchangedCash // 当前活动已兑换现金
|
906
|
+ activityFoundExchangedSuMoney := activityFound.ExchangedSuMoney // 当前活动已兑换素币
|
|
|
907
|
+ activityFoundExchangedCash := activityFound.ExchangedCash // 当前活动已兑换现金
|
908
|
|
908
|
|
909
|
// 获取当前公司现金池
|
909
|
// 获取当前公司现金池
|
910
|
cashPoolFound, err := cashPoolRepository.FindOne(map[string]interface{}{
|
910
|
cashPoolFound, err := cashPoolRepository.FindOne(map[string]interface{}{
|
|
@@ -968,9 +968,9 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
|
@@ -968,9 +968,9 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
968
|
// 获取当前兑换活动汇率
|
968
|
// 获取当前兑换活动汇率
|
969
|
activityFoundRate := activityFound.Rate
|
969
|
activityFoundRate := activityFound.Rate
|
970
|
|
970
|
|
971
|
- if updateExchangeCashActivityCommand.ExchangeRate != activityFoundRate && updateExchangeCashActivityCommand.ExchangeRate != 0 { // 更新兑换活动兑换汇率
|
971
|
+ if updateExchangeCashActivityCommand.ExchangeRate != activityFoundRate && updateExchangeCashActivityCommand.ExchangeRate != 0 { // 更新兑换活动兑换汇率
|
972
|
// 判断兑换活动清单中现金总金额是否超过平台未兑换现金值
|
972
|
// 判断兑换活动清单中现金总金额是否超过平台未兑换现金值
|
973
|
- if activityFoundExchangedSuMoney * updateExchangeCashActivityCommand.ExchangeRate > cashPoolFoundUnExchangeCash {
|
973
|
+ if activityFoundExchangedSuMoney*updateExchangeCashActivityCommand.ExchangeRate > cashPoolFoundUnExchangeCash {
|
974
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "已超过投入现金池的未兑换现金")
|
974
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "已超过投入现金池的未兑换现金")
|
975
|
}
|
975
|
}
|
976
|
|
976
|
|
|
@@ -988,9 +988,9 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
|
@@ -988,9 +988,9 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
988
|
|
988
|
|
989
|
// 更新兑换清单命令
|
989
|
// 更新兑换清单命令
|
990
|
exchangeCash, _ := decimal.NewFromFloat(updateExchangeCashActivityCommand.ExchangeRate).Mul(decimal.NewFromFloat(personFoundExchangedSuMoney)).Float64()
|
990
|
exchangeCash, _ := decimal.NewFromFloat(updateExchangeCashActivityCommand.ExchangeRate).Mul(decimal.NewFromFloat(personFoundExchangedSuMoney)).Float64()
|
991
|
- updateExchangeCashPerson := &command.UpdateExchangeCashPersonCommand {
|
991
|
+ updateExchangeCashPerson := &command.UpdateExchangeCashPersonCommand{
|
992
|
//ExchangedCash: updateExchangeCashActivityCommand.ExchangeRate * personFoundExchangedSuMoney,
|
992
|
//ExchangedCash: updateExchangeCashActivityCommand.ExchangeRate * personFoundExchangedSuMoney,
|
993
|
- ExchangedCash: exchangeCash,
|
993
|
+ ExchangedCash: exchangeCash,
|
994
|
ExchangedSuMoney: personFoundExchangedSuMoney,
|
994
|
ExchangedSuMoney: personFoundExchangedSuMoney,
|
995
|
}
|
995
|
}
|
996
|
|
996
|
|
|
@@ -1000,7 +1000,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
|
@@ -1000,7 +1000,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
1000
|
}
|
1000
|
}
|
1001
|
|
1001
|
|
1002
|
// 保存素币兑换清单更新
|
1002
|
// 保存素币兑换清单更新
|
1003
|
- if _, err := exchangeCashPersonListRepository.Save(personFound);err != nil {
|
1003
|
+ if _, err := exchangeCashPersonListRepository.Save(personFound); err != nil {
|
1004
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
1004
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
1005
|
}
|
1005
|
}
|
1006
|
}
|
1006
|
}
|
|
@@ -1034,16 +1034,16 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
|
@@ -1034,16 +1034,16 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
1034
|
exchangedCash, _ := decimal.NewFromFloat(cashPoolFoundExchangedCash).Add(decimal.NewFromFloat(updateExchangeCashActivityCommand.ExchangedCash).Sub(decimal.NewFromFloat(activityFoundExchangedCash))).Float64()
|
1034
|
exchangedCash, _ := decimal.NewFromFloat(cashPoolFoundExchangedCash).Add(decimal.NewFromFloat(updateExchangeCashActivityCommand.ExchangedCash).Sub(decimal.NewFromFloat(activityFoundExchangedCash))).Float64()
|
1035
|
unExchangeCash, _ := decimal.NewFromFloat(cashPoolFoundUnExchangeCash).Sub(decimal.NewFromFloat(updateExchangeCashActivityCommand.ExchangedCash).Sub(decimal.NewFromFloat(activityFoundExchangedCash))).Float64()
|
1035
|
unExchangeCash, _ := decimal.NewFromFloat(cashPoolFoundUnExchangeCash).Sub(decimal.NewFromFloat(updateExchangeCashActivityCommand.ExchangedCash).Sub(decimal.NewFromFloat(activityFoundExchangedCash))).Float64()
|
1036
|
updateCashPoolCommand := &command.UpdateCashPoolCommand{
|
1036
|
updateCashPoolCommand := &command.UpdateCashPoolCommand{
|
1037
|
- CashPoolId: cashPoolFound.CashPoolId,
|
1037
|
+ CashPoolId: cashPoolFound.CashPoolId,
|
1038
|
//ExchangedCash: cashPoolFoundExchangedCash + (updateExchangeCashActivityCommand.ExchangedCash - activityFoundExchangedCash),
|
1038
|
//ExchangedCash: cashPoolFoundExchangedCash + (updateExchangeCashActivityCommand.ExchangedCash - activityFoundExchangedCash),
|
1039
|
//UnExchangeCash: cashPoolFoundUnExchangeCash - (updateExchangeCashActivityCommand.ExchangedCash - activityFoundExchangedCash),
|
1039
|
//UnExchangeCash: cashPoolFoundUnExchangeCash - (updateExchangeCashActivityCommand.ExchangedCash - activityFoundExchangedCash),
|
1040
|
- ExchangedCash: exchangedCash,
|
|
|
1041
|
- UnExchangeCash: unExchangeCash,
|
|
|
1042
|
- ExchangedSuMoney: systemExchangedSuMoney,
|
|
|
1043
|
- UnExchangeSuMoney: systemUnExchangeSuMoney,
|
|
|
1044
|
- Rate: rate,
|
|
|
1045
|
- LastRate: cashPoolFound.LastRate,
|
|
|
1046
|
- Cash: cashPoolFound.Cash,
|
1040
|
+ ExchangedCash: exchangedCash,
|
|
|
1041
|
+ UnExchangeCash: unExchangeCash,
|
|
|
1042
|
+ ExchangedSuMoney: systemExchangedSuMoney,
|
|
|
1043
|
+ UnExchangeSuMoney: systemUnExchangeSuMoney,
|
|
|
1044
|
+ Rate: rate,
|
|
|
1045
|
+ LastRate: cashPoolFound.LastRate,
|
|
|
1046
|
+ Cash: cashPoolFound.Cash,
|
1047
|
}
|
1047
|
}
|
1048
|
|
1048
|
|
1049
|
// 更新现金池
|
1049
|
// 更新现金池
|
|
@@ -1169,7 +1169,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
|
@@ -1169,7 +1169,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
1169
|
|
1169
|
|
1170
|
// 现金池仓储初始化
|
1170
|
// 现金池仓储初始化
|
1171
|
var cashPoolRepository domain.CashPoolRepository
|
1171
|
var cashPoolRepository domain.CashPoolRepository
|
1172
|
- if value, err := factory.CreateCashPoolRepository(map[string] interface{} {
|
1172
|
+ if value, err := factory.CreateCashPoolRepository(map[string]interface{}{
|
1173
|
"transactionContext": transactionContext,
|
1173
|
"transactionContext": transactionContext,
|
1174
|
}); err != nil {
|
1174
|
}); err != nil {
|
1175
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
1175
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
@@ -1218,9 +1218,10 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
|
@@ -1218,9 +1218,10 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
1218
|
activityFoundExchangedSuMoney := activityFound.ExchangedSuMoney
|
1218
|
activityFoundExchangedSuMoney := activityFound.ExchangedSuMoney
|
1219
|
activityFoundExchangedCash := activityFound.ExchangedCash
|
1219
|
activityFoundExchangedCash := activityFound.ExchangedCash
|
1220
|
|
1220
|
|
1221
|
- // TODO 更改:根据uid和companyId,判断当前员工是否有效
|
1221
|
+ //更改:根据uid和companyId,判断当前员工是否有效
|
1222
|
getEmployee := map[string]interface{}{
|
1222
|
getEmployee := map[string]interface{}{
|
1223
|
- "account": personFound.EmployeeInfo.EmployeeAccount,
|
1223
|
+ "uid": personFound.EmployeeInfo.Uid,
|
|
|
1224
|
+ //"account": personFound.EmployeeInfo.EmployeeAccount,
|
1224
|
"companyId": activityFound.CompanyId,
|
1225
|
"companyId": activityFound.CompanyId,
|
1225
|
}
|
1226
|
}
|
1226
|
employeeFound, err := employeeRepository.FindOne(getEmployee)
|
1227
|
employeeFound, err := employeeRepository.FindOne(getEmployee)
|
|
@@ -1257,15 +1258,15 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
|
@@ -1257,15 +1258,15 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
1257
|
// 更新素币兑换活动命令
|
1258
|
// 更新素币兑换活动命令
|
1258
|
exchangedSuMoney, _ := decimal.NewFromFloat(activityFoundExchangedSuMoney).Add(decimal.NewFromFloat(updateExchangeCashPersonCommand.ExchangedSuMoney).Sub(decimal.NewFromFloat(personFoundExchangedSuMoney))).Float64()
|
1259
|
exchangedSuMoney, _ := decimal.NewFromFloat(activityFoundExchangedSuMoney).Add(decimal.NewFromFloat(updateExchangeCashPersonCommand.ExchangedSuMoney).Sub(decimal.NewFromFloat(personFoundExchangedSuMoney))).Float64()
|
1259
|
exchangedCash, _ := decimal.NewFromFloat(activityFoundExchangedCash).Add(decimal.NewFromFloat(updateExchangeCashPersonCommand.ExchangedSuMoney).Sub(decimal.NewFromFloat(personFoundExchangedSuMoney)).Mul(decimal.NewFromFloat(activityFound.Rate))).Float64()
|
1260
|
exchangedCash, _ := decimal.NewFromFloat(activityFoundExchangedCash).Add(decimal.NewFromFloat(updateExchangeCashPersonCommand.ExchangedSuMoney).Sub(decimal.NewFromFloat(personFoundExchangedSuMoney)).Mul(decimal.NewFromFloat(activityFound.Rate))).Float64()
|
1260
|
- updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{
|
1261
|
+ updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{
|
1261
|
ExchangeCashActivityId: personFound.ExchangeCashActivityId,
|
1262
|
ExchangeCashActivityId: personFound.ExchangeCashActivityId,
|
1262
|
//ExchangedSuMoney: activityFoundExchangedSuMoney + (updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney),
|
1263
|
//ExchangedSuMoney: activityFoundExchangedSuMoney + (updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney),
|
1263
|
//ExchangedCash: activityFoundExchangedCash + (updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney) * activityFound.Rate,
|
1264
|
//ExchangedCash: activityFoundExchangedCash + (updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney) * activityFound.Rate,
|
1264
|
- ExchangedSuMoney: exchangedSuMoney,
|
|
|
1265
|
- ExchangedCash: exchangedCash,
|
|
|
1266
|
- Deadline: activityFound.Deadline,
|
|
|
1267
|
- CountDown: activityFound.CountDown,
|
|
|
1268
|
- ExchangeRate: activityFound.Rate,
|
1265
|
+ ExchangedSuMoney: exchangedSuMoney,
|
|
|
1266
|
+ ExchangedCash: exchangedCash,
|
|
|
1267
|
+ Deadline: activityFound.Deadline,
|
|
|
1268
|
+ CountDown: activityFound.CountDown,
|
|
|
1269
|
+ ExchangeRate: activityFound.Rate,
|
1269
|
}
|
1270
|
}
|
1270
|
|
1271
|
|
1271
|
// 操作素币服务以及生成素币兑换流水记录命令
|
1272
|
// 操作素币服务以及生成素币兑换流水记录命令
|
|
@@ -1278,11 +1279,11 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
|
@@ -1278,11 +1279,11 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
1278
|
}
|
1279
|
}
|
1279
|
|
1280
|
|
1280
|
// 判断操作素币类型
|
1281
|
// 判断操作素币类型
|
1281
|
- if updateExchangeCashPersonCommand.ExchangedSuMoney > personFoundExchangedSuMoney { // 追加素币兑换
|
1282
|
+ if updateExchangeCashPersonCommand.ExchangedSuMoney > personFoundExchangedSuMoney { // 追加素币兑换
|
1282
|
//operationSuMoneyCommand.SuMoney = math.Abs(updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney)
|
1283
|
//operationSuMoneyCommand.SuMoney = math.Abs(updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney)
|
1283
|
operationSuMoneyCommand.SuMoney, _ = decimal.NewFromFloat(updateExchangeCashPersonCommand.ExchangedSuMoney).Sub(decimal.NewFromFloat(personFoundExchangedSuMoney)).Abs().Float64()
|
1284
|
operationSuMoneyCommand.SuMoney, _ = decimal.NewFromFloat(updateExchangeCashPersonCommand.ExchangedSuMoney).Sub(decimal.NewFromFloat(personFoundExchangedSuMoney)).Abs().Float64()
|
1284
|
operationSuMoneyCommand.OperationType = 4
|
1285
|
operationSuMoneyCommand.OperationType = 4
|
1285
|
- } else { // 撤回素币兑换
|
1286
|
+ } else { // 撤回素币兑换
|
1286
|
//operationSuMoneyCommand.SuMoney = math.Abs(updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney)
|
1287
|
//operationSuMoneyCommand.SuMoney = math.Abs(updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney)
|
1287
|
operationSuMoneyCommand.SuMoney, _ = decimal.NewFromFloat(updateExchangeCashPersonCommand.ExchangedSuMoney).Sub(decimal.NewFromFloat(personFoundExchangedSuMoney)).Abs().Float64()
|
1288
|
operationSuMoneyCommand.SuMoney, _ = decimal.NewFromFloat(updateExchangeCashPersonCommand.ExchangedSuMoney).Sub(decimal.NewFromFloat(personFoundExchangedSuMoney)).Abs().Float64()
|
1288
|
operationSuMoneyCommand.OperationType = 41
|
1289
|
operationSuMoneyCommand.OperationType = 41
|
|
@@ -1338,7 +1339,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
|
@@ -1338,7 +1339,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
1338
|
|
1339
|
|
1339
|
// 判断是否超过平台未兑换现金
|
1340
|
// 判断是否超过平台未兑换现金
|
1340
|
if activityUpdated.ExchangedSuMoney > activityFoundExchangedSuMoney {
|
1341
|
if activityUpdated.ExchangedSuMoney > activityFoundExchangedSuMoney {
|
1341
|
- if (activityUpdated.ExchangedSuMoney - activityFoundExchangedSuMoney) * activityUpdated.Rate > cashPoolFoundUnExchangeCash {
|
1342
|
+ if (activityUpdated.ExchangedSuMoney-activityFoundExchangedSuMoney)*activityUpdated.Rate > cashPoolFoundUnExchangeCash {
|
1342
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "已超过投入现金池的未兑换现金")
|
1343
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "已超过投入现金池的未兑换现金")
|
1343
|
}
|
1344
|
}
|
1344
|
}
|
1345
|
}
|
|
@@ -1359,15 +1360,15 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
|
@@ -1359,15 +1360,15 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
1359
|
// 更新现金池命令
|
1360
|
// 更新现金池命令
|
1360
|
unExchangeCash, _ := decimal.NewFromFloat(cashPoolFoundUnExchangeCash).Sub((decimal.NewFromFloat(updateExchangeCashPersonCommand.ExchangedSuMoney).Sub(decimal.NewFromFloat(personFoundExchangedSuMoney))).Mul(decimal.NewFromFloat(activityUpdated.Rate))).Float64()
|
1361
|
unExchangeCash, _ := decimal.NewFromFloat(cashPoolFoundUnExchangeCash).Sub((decimal.NewFromFloat(updateExchangeCashPersonCommand.ExchangedSuMoney).Sub(decimal.NewFromFloat(personFoundExchangedSuMoney))).Mul(decimal.NewFromFloat(activityUpdated.Rate))).Float64()
|
1361
|
updateCashPoolCommand := &command.UpdateCashPoolCommand{
|
1362
|
updateCashPoolCommand := &command.UpdateCashPoolCommand{
|
1362
|
- CashPoolId: cashPoolFound.CashPoolId,
|
|
|
1363
|
- Cash: cashPoolFound.Cash,
|
|
|
1364
|
- ExchangedCash: systemExchangedCash,
|
1363
|
+ CashPoolId: cashPoolFound.CashPoolId,
|
|
|
1364
|
+ Cash: cashPoolFound.Cash,
|
|
|
1365
|
+ ExchangedCash: systemExchangedCash,
|
1365
|
//UnExchangeCash: cashPoolFoundUnExchangeCash - (updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney) * activityUpdated.Rate,
|
1366
|
//UnExchangeCash: cashPoolFoundUnExchangeCash - (updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney) * activityUpdated.Rate,
|
1366
|
UnExchangeCash: unExchangeCash,
|
1367
|
UnExchangeCash: unExchangeCash,
|
1367
|
Rate: newRate,
|
1368
|
Rate: newRate,
|
1368
|
ExchangedSuMoney: systemExchangedSuMoney,
|
1369
|
ExchangedSuMoney: systemExchangedSuMoney,
|
1369
|
UnExchangeSuMoney: systemUnExchangeSuMoney,
|
1370
|
UnExchangeSuMoney: systemUnExchangeSuMoney,
|
1370
|
- LastRate: cashPoolFound.LastRate,
|
1371
|
+ LastRate: cashPoolFound.LastRate,
|
1371
|
}
|
1372
|
}
|
1372
|
|
1373
|
|
1373
|
// 更新现金池
|
1374
|
// 更新现金池
|
|
@@ -1443,7 +1444,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
|
@@ -1443,7 +1444,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
1443
|
|
1444
|
|
1444
|
// 现金池仓储初始化
|
1445
|
// 现金池仓储初始化
|
1445
|
var cashPoolRepository domain.CashPoolRepository
|
1446
|
var cashPoolRepository domain.CashPoolRepository
|
1446
|
- if value, err := factory.CreateCashPoolRepository(map[string] interface{} {
|
1447
|
+ if value, err := factory.CreateCashPoolRepository(map[string]interface{}{
|
1447
|
"transactionContext": transactionContext,
|
1448
|
"transactionContext": transactionContext,
|
1448
|
}); err != nil {
|
1449
|
}); err != nil {
|
1449
|
return []interface{}{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
1450
|
return []interface{}{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
@@ -1505,8 +1506,8 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
|
@@ -1505,8 +1506,8 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
1505
|
failureDataList = append(failureDataList, row)
|
1506
|
failureDataList = append(failureDataList, row)
|
1506
|
continue
|
1507
|
continue
|
1507
|
}
|
1508
|
}
|
1508
|
- activityFoundExchangedSuMoney := activityFound.ExchangedSuMoney // 当前兑换活动未兑换素币
|
|
|
1509
|
- activityFoundExchangedCash := activityFound.ExchangedCash // 当前兑换活动已兑换素币
|
1509
|
+ activityFoundExchangedSuMoney := activityFound.ExchangedSuMoney // 当前兑换活动未兑换素币
|
|
|
1510
|
+ activityFoundExchangedCash := activityFound.ExchangedCash // 当前兑换活动已兑换素币
|
1510
|
|
1511
|
|
1511
|
// 获取当前公司现金池
|
1512
|
// 获取当前公司现金池
|
1512
|
cashPoolFound, err := cashPoolRepository.FindOne(map[string]interface{}{
|
1513
|
cashPoolFound, err := cashPoolRepository.FindOne(map[string]interface{}{
|
|
@@ -1532,12 +1533,13 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
|
@@ -1532,12 +1533,13 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
1532
|
failureDataList = append(failureDataList, row)
|
1533
|
failureDataList = append(failureDataList, row)
|
1533
|
continue
|
1534
|
continue
|
1534
|
}
|
1535
|
}
|
1535
|
- cashPoolFoundUnExchangeCash := cashPoolFound.UnExchangeCash // 当前公司现金池未兑换现金
|
|
|
1536
|
- cashPoolFoundExchangedCash := cashPoolFound.ExchangedCash // 当前公司现金池已兑换现金
|
1536
|
+ cashPoolFoundUnExchangeCash := cashPoolFound.UnExchangeCash // 当前公司现金池未兑换现金
|
|
|
1537
|
+ cashPoolFoundExchangedCash := cashPoolFound.ExchangedCash // 当前公司现金池已兑换现金
|
1537
|
|
1538
|
|
1538
|
- // TODO 更改:根据uid和companyId,判断当前员工是否有效
|
1539
|
+ // 更改:根据uid、account和companyId,判断当前员工是否有效(身份有效、手机账号有效)
|
1539
|
getEmployee := map[string]interface{}{
|
1540
|
getEmployee := map[string]interface{}{
|
1540
|
- "account": createExchangeCashPersonCommand.PersonAccount,
|
1541
|
+ "uid": createExchangeCashPersonCommand.Uid,
|
|
|
1542
|
+ "account": createExchangeCashPersonCommand.PersonAccount,
|
1541
|
"companyId": activityFound.CompanyId,
|
1543
|
"companyId": activityFound.CompanyId,
|
1542
|
}
|
1544
|
}
|
1543
|
employeeFound, err := employeeRepository.FindOne(getEmployee)
|
1545
|
employeeFound, err := employeeRepository.FindOne(getEmployee)
|
|
@@ -1561,14 +1563,15 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
|
@@ -1561,14 +1563,15 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
1561
|
failureDataList = append(failureDataList, row)
|
1563
|
failureDataList = append(failureDataList, row)
|
1562
|
continue
|
1564
|
continue
|
1563
|
}
|
1565
|
}
|
1564
|
- employeeFoundSuMoney := employeeFound.SuMoney // 当前导入员工持有的素币值
|
1566
|
+ employeeFoundSuMoney := employeeFound.SuMoney // 当前导入员工持有的素币值
|
1565
|
|
1567
|
|
1566
|
- // TODO 更改:根据uid和activityId判断当前员工是否已经在素币兑换清单中,
|
1568
|
+ // 更改:根据uid、employeeAccount和activityId判断当前员工是否已经在素币兑换清单中,
|
1567
|
personFound, _ := exchangeCashPersonListRepository.FindOne(map[string]interface{}{
|
1569
|
personFound, _ := exchangeCashPersonListRepository.FindOne(map[string]interface{}{
|
|
|
1570
|
+ "uid": employeeFound.EmployeeInfo.Uid,
|
1568
|
"employeeAccount": employeeFound.EmployeeInfo.EmployeeAccount,
|
1571
|
"employeeAccount": employeeFound.EmployeeInfo.EmployeeAccount,
|
1569
|
- "activityId": activityFound.ActivityId,
|
1572
|
+ "activityId": activityFound.ActivityId,
|
1570
|
})
|
1573
|
})
|
1571
|
- if personFound == nil { // 当前人员不在兑换素币清单中,新增兑换素币清单
|
1574
|
+ if personFound == nil { // 当前人员不在兑换素币清单中,新增兑换素币清单
|
1572
|
// 判断该员工兑换的素币是否超过本人持有的素币
|
1575
|
// 判断该员工兑换的素币是否超过本人持有的素币
|
1573
|
if createExchangeCashPersonCommand.ExchangedSuMoney > employeeFoundSuMoney {
|
1576
|
if createExchangeCashPersonCommand.ExchangedSuMoney > employeeFoundSuMoney {
|
1574
|
row := []interface{}{
|
1577
|
row := []interface{}{
|
|
@@ -1591,8 +1594,8 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
|
@@ -1591,8 +1594,8 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
1591
|
EmployeeAccount: employeeFound.EmployeeInfo.EmployeeAccount,
|
1594
|
EmployeeAccount: employeeFound.EmployeeInfo.EmployeeAccount,
|
1592
|
},
|
1595
|
},
|
1593
|
ExchangeCashActivityId: createExchangeCashPersonCommand.ExchangeCashActivityId,
|
1596
|
ExchangeCashActivityId: createExchangeCashPersonCommand.ExchangeCashActivityId,
|
1594
|
- ExchangedSuMoney: createExchangeCashPersonCommand.ExchangedSuMoney,
|
|
|
1595
|
- ExchangedCash: newPersonExchangedCash,
|
1597
|
+ ExchangedSuMoney: createExchangeCashPersonCommand.ExchangedSuMoney,
|
|
|
1598
|
+ ExchangedCash: newPersonExchangedCash,
|
1596
|
}
|
1599
|
}
|
1597
|
personSaved, err := exchangeCashPersonListRepository.Save(newPerson)
|
1600
|
personSaved, err := exchangeCashPersonListRepository.Save(newPerson)
|
1598
|
if err != nil {
|
1601
|
if err != nil {
|
|
@@ -1617,11 +1620,11 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
|
@@ -1617,11 +1620,11 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
1617
|
}
|
1620
|
}
|
1618
|
|
1621
|
|
1619
|
// 操作素币,生成素币流水
|
1622
|
// 操作素币,生成素币流水
|
1620
|
- operationSuMoneyCommand := &command.OperationSuMoneyCommand{
|
1623
|
+ operationSuMoneyCommand := &command.OperationSuMoneyCommand{
|
1621
|
Uid: employeeFound.EmployeeInfo.Uid,
|
1624
|
Uid: employeeFound.EmployeeInfo.Uid,
|
1622
|
Operator: createExchangeCashPersonCommand.Operator,
|
1625
|
Operator: createExchangeCashPersonCommand.Operator,
|
1623
|
SuMoney: createExchangeCashPersonCommand.ExchangedSuMoney,
|
1626
|
SuMoney: createExchangeCashPersonCommand.ExchangedSuMoney,
|
1624
|
- OperationType: 4, // 操作类型->记录类型对应:1->3: 增加 2->4: 扣除 3->1: 兑换物资 4->5: 兑换现金活动 41->6: 撤回兑换现金素币 5->2: 任务奖励
|
1627
|
+ OperationType: 4, // 操作类型->记录类型对应:1->3: 增加 2->4: 扣除 3->1: 兑换物资 4->5: 兑换现金活动 41->6: 撤回兑换现金素币 5->2: 任务奖励
|
1625
|
OperationDescription: "参与" + activityFound.ExchangeActivityName,
|
1628
|
OperationDescription: "参与" + activityFound.ExchangeActivityName,
|
1626
|
}
|
1629
|
}
|
1627
|
task, err := operationSuMoneyService.Operation(operationSuMoneyCommand.Uid, operationSuMoneyCommand.Operator, operationSuMoneyCommand.SuMoney, operationSuMoneyCommand.OperationType, operationSuMoneyCommand.OperationDescription)
|
1630
|
task, err := operationSuMoneyService.Operation(operationSuMoneyCommand.Uid, operationSuMoneyCommand.Operator, operationSuMoneyCommand.SuMoney, operationSuMoneyCommand.OperationType, operationSuMoneyCommand.OperationDescription)
|
|
@@ -1649,16 +1652,16 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
|
@@ -1649,16 +1652,16 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
1649
|
// 更新兑换活动
|
1652
|
// 更新兑换活动
|
1650
|
exchangedSuMoney, _ := decimal.NewFromFloat(activityFoundExchangedSuMoney).Add(decimal.NewFromFloat(createExchangeCashPersonCommand.ExchangedSuMoney)).Float64()
|
1653
|
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()
|
1654
|
exchangedCash, _ := decimal.NewFromFloat(activityFoundExchangedCash).Add(decimal.NewFromFloat(createExchangeCashPersonCommand.ExchangedSuMoney).Mul(decimal.NewFromFloat(activityFound.Rate))).Float64()
|
1652
|
- updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{
|
1655
|
+ updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{
|
1653
|
ExchangeCashActivityId: personSaved.ExchangeCashActivityId,
|
1656
|
ExchangeCashActivityId: personSaved.ExchangeCashActivityId,
|
1654
|
ExchangeActivityName: activityFound.ExchangeActivityName,
|
1657
|
ExchangeActivityName: activityFound.ExchangeActivityName,
|
1655
|
//ExchangedSuMoney: activityFoundExchangedSuMoney + createExchangeCashPersonCommand.ExchangedSuMoney,
|
1658
|
//ExchangedSuMoney: activityFoundExchangedSuMoney + createExchangeCashPersonCommand.ExchangedSuMoney,
|
1656
|
//ExchangedCash: activityFoundExchangedCash + createExchangeCashPersonCommand.ExchangedSuMoney * activityFound.Rate,
|
1659
|
//ExchangedCash: activityFoundExchangedCash + createExchangeCashPersonCommand.ExchangedSuMoney * activityFound.Rate,
|
1657
|
- ExchangedSuMoney: exchangedSuMoney,
|
|
|
1658
|
- ExchangedCash: exchangedCash,
|
|
|
1659
|
- Deadline: activityFound.Deadline,
|
|
|
1660
|
- CountDown: activityFound.CountDown,
|
|
|
1661
|
- ExchangeRate: activityFound.Rate,
|
1660
|
+ ExchangedSuMoney: exchangedSuMoney,
|
|
|
1661
|
+ ExchangedCash: exchangedCash,
|
|
|
1662
|
+ Deadline: activityFound.Deadline,
|
|
|
1663
|
+ CountDown: activityFound.CountDown,
|
|
|
1664
|
+ ExchangeRate: activityFound.Rate,
|
1662
|
}
|
1665
|
}
|
1663
|
if err := activityFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashActivityCommand)); err != nil {
|
1666
|
if err := activityFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashActivityCommand)); err != nil {
|
1664
|
row := []interface{}{
|
1667
|
row := []interface{}{
|
|
@@ -1693,7 +1696,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
|
@@ -1693,7 +1696,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
1693
|
}
|
1696
|
}
|
1694
|
|
1697
|
|
1695
|
// 判断是否超过平台未兑换现金
|
1698
|
// 判断是否超过平台未兑换现金
|
1696
|
- if createExchangeCashPersonCommand.ExchangedSuMoney * activityFound.Rate > cashPoolFoundUnExchangeCash {
|
1699
|
+ if createExchangeCashPersonCommand.ExchangedSuMoney*activityFound.Rate > cashPoolFoundUnExchangeCash {
|
1697
|
row := []interface{}{
|
1700
|
row := []interface{}{
|
1698
|
createExchangeCashPersonCommand.PersonName,
|
1701
|
createExchangeCashPersonCommand.PersonName,
|
1699
|
createExchangeCashPersonCommand.PersonAccount,
|
1702
|
createExchangeCashPersonCommand.PersonAccount,
|
|
@@ -1727,7 +1730,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
|
@@ -1727,7 +1730,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
1727
|
continue
|
1730
|
continue
|
1728
|
}
|
1731
|
}
|
1729
|
systemExchangedSuMoney := systemSuMoneyStatistics["systemExchangedSuMoney"].(float64) // 公司已兑换素币
|
1732
|
systemExchangedSuMoney := systemSuMoneyStatistics["systemExchangedSuMoney"].(float64) // 公司已兑换素币
|
1730
|
- systemUnExchangeSuMoney := systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64) // 公司未兑换素币
|
1733
|
+ systemUnExchangeSuMoney := systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64) // 公司未兑换素币
|
1731
|
|
1734
|
|
1732
|
// 更新现金池
|
1735
|
// 更新现金池
|
1733
|
var newRate float64
|
1736
|
var newRate float64
|
|
@@ -1737,19 +1740,19 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
|
@@ -1737,19 +1740,19 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
1737
|
//newRate = (cashPoolFoundExchangedCash + personSaved.ExchangedCash) / systemExchangedSuMoney
|
1740
|
//newRate = (cashPoolFoundExchangedCash + personSaved.ExchangedCash) / systemExchangedSuMoney
|
1738
|
newRate, _ = decimal.NewFromFloat(cashPoolFoundExchangedCash).Add(decimal.NewFromFloat(personSaved.ExchangedCash)).Div(decimal.NewFromFloat(systemExchangedSuMoney)).Float64()
|
1741
|
newRate, _ = decimal.NewFromFloat(cashPoolFoundExchangedCash).Add(decimal.NewFromFloat(personSaved.ExchangedCash)).Div(decimal.NewFromFloat(systemExchangedSuMoney)).Float64()
|
1739
|
}
|
1742
|
}
|
1740
|
- newExchangedCash, _ := decimal.NewFromFloat(cashPoolFoundExchangedCash).Add(decimal.NewFromFloat(personSaved.ExchangedCash)).Float64()
|
|
|
1741
|
- unExchangeCash, _ := decimal.NewFromFloat(cashPoolFoundUnExchangeCash).Sub(decimal.NewFromFloat(personSaved.ExchangedCash)).Float64()
|
1743
|
+ newExchangedCash, _ := decimal.NewFromFloat(cashPoolFoundExchangedCash).Add(decimal.NewFromFloat(personSaved.ExchangedCash)).Float64()
|
|
|
1744
|
+ unExchangeCash, _ := decimal.NewFromFloat(cashPoolFoundUnExchangeCash).Sub(decimal.NewFromFloat(personSaved.ExchangedCash)).Float64()
|
1742
|
updateCashPoolCommand := &command.UpdateCashPoolCommand{
|
1745
|
updateCashPoolCommand := &command.UpdateCashPoolCommand{
|
1743
|
- CashPoolId: cashPoolFound.CashPoolId,
|
|
|
1744
|
- Cash: cashPoolFound.Cash,
|
1746
|
+ CashPoolId: cashPoolFound.CashPoolId,
|
|
|
1747
|
+ Cash: cashPoolFound.Cash,
|
1745
|
//ExchangedCash: cashPoolFoundExchangedCash + personSaved.ExchangedCash,
|
1748
|
//ExchangedCash: cashPoolFoundExchangedCash + personSaved.ExchangedCash,
|
1746
|
//UnExchangeCash: cashPoolFoundUnExchangeCash - personSaved.ExchangedCash,
|
1749
|
//UnExchangeCash: cashPoolFoundUnExchangeCash - personSaved.ExchangedCash,
|
1747
|
- ExchangedCash: newExchangedCash,
|
1750
|
+ ExchangedCash: newExchangedCash,
|
1748
|
UnExchangeCash: unExchangeCash,
|
1751
|
UnExchangeCash: unExchangeCash,
|
1749
|
ExchangedSuMoney: systemExchangedSuMoney,
|
1752
|
ExchangedSuMoney: systemExchangedSuMoney,
|
1750
|
UnExchangeSuMoney: systemUnExchangeSuMoney,
|
1753
|
UnExchangeSuMoney: systemUnExchangeSuMoney,
|
1751
|
Rate: newRate,
|
1754
|
Rate: newRate,
|
1752
|
- LastRate: cashPoolFound.LastRate,
|
1755
|
+ LastRate: cashPoolFound.LastRate,
|
1753
|
}
|
1756
|
}
|
1754
|
if err := cashPoolFound.Update(tool_funs.SimpleStructToMap(updateCashPoolCommand)); err != nil {
|
1757
|
if err := cashPoolFound.Update(tool_funs.SimpleStructToMap(updateCashPoolCommand)); err != nil {
|
1755
|
row := []interface{}{
|
1758
|
row := []interface{}{
|
|
@@ -1782,10 +1785,10 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
|
@@ -1782,10 +1785,10 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
1782
|
failureDataList = append(failureDataList, row)
|
1785
|
failureDataList = append(failureDataList, row)
|
1783
|
continue
|
1786
|
continue
|
1784
|
}
|
1787
|
}
|
1785
|
- } else { // 当前人员存在兑换素币清单中
|
|
|
1786
|
- personFoundExchangedSuMoney := personFound.ExchangedSuMoney // 当前素币清单已兑换素币
|
|
|
1787
|
- personFoundExchangedCash := personFound.ExchangedCash // 当前素币清单已兑换现金
|
|
|
1788
|
- if createExchangeCashPersonCommand.ExchangedSuMoney < personFoundExchangedSuMoney { // 当前兑换的素币小于本人已兑换素币,撤回兑换素币
|
1788
|
+ } else { // 当前人员存在兑换素币清单中
|
|
|
1789
|
+ personFoundExchangedSuMoney := personFound.ExchangedSuMoney // 当前素币清单已兑换素币
|
|
|
1790
|
+ personFoundExchangedCash := personFound.ExchangedCash // 当前素币清单已兑换现金
|
|
|
1791
|
+ if createExchangeCashPersonCommand.ExchangedSuMoney < personFoundExchangedSuMoney { // 当前兑换的素币小于本人已兑换素币,撤回兑换素币
|
1789
|
// 素币减量
|
1792
|
// 素币减量
|
1790
|
//suMoneyDecrement := personFoundExchangedSuMoney - createExchangeCashPersonCommand.ExchangedSuMoney
|
1793
|
//suMoneyDecrement := personFoundExchangedSuMoney - createExchangeCashPersonCommand.ExchangedSuMoney
|
1791
|
suMoneyDecrement, _ := decimal.NewFromFloat(personFoundExchangedSuMoney).Sub(decimal.NewFromFloat(createExchangeCashPersonCommand.ExchangedSuMoney)).Float64()
|
1794
|
suMoneyDecrement, _ := decimal.NewFromFloat(personFoundExchangedSuMoney).Sub(decimal.NewFromFloat(createExchangeCashPersonCommand.ExchangedSuMoney)).Float64()
|
|
@@ -1796,14 +1799,14 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
|
@@ -1796,14 +1799,14 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
1796
|
|
1799
|
|
1797
|
// 更新兑换素币清单
|
1800
|
// 更新兑换素币清单
|
1798
|
exchangedSuMoney, _ := decimal.NewFromFloat(personFoundExchangedSuMoney).Sub(decimal.NewFromFloat(suMoneyDecrement)).Float64()
|
1801
|
exchangedSuMoney, _ := decimal.NewFromFloat(personFoundExchangedSuMoney).Sub(decimal.NewFromFloat(suMoneyDecrement)).Float64()
|
1799
|
- exchangedCash, _ := decimal.NewFromFloat(personFoundExchangedCash).Sub(decimal.NewFromFloat(cashDecrement)).Float64()
|
1802
|
+ exchangedCash, _ := decimal.NewFromFloat(personFoundExchangedCash).Sub(decimal.NewFromFloat(cashDecrement)).Float64()
|
1800
|
updateExchangeCashPersonCommand := &command.UpdateExchangeCashPersonCommand{
|
1803
|
updateExchangeCashPersonCommand := &command.UpdateExchangeCashPersonCommand{
|
1801
|
- ListId: personFound.ListId,
|
1804
|
+ ListId: personFound.ListId,
|
1802
|
//ExchangedSuMoney: personFoundExchangedSuMoney - suMoneyDecrement,
|
1805
|
//ExchangedSuMoney: personFoundExchangedSuMoney - suMoneyDecrement,
|
1803
|
//ExchangedCash: personFoundExchangedCash - cashDecrement,
|
1806
|
//ExchangedCash: personFoundExchangedCash - cashDecrement,
|
1804
|
ExchangedSuMoney: exchangedSuMoney,
|
1807
|
ExchangedSuMoney: exchangedSuMoney,
|
1805
|
- ExchangedCash: exchangedCash,
|
|
|
1806
|
- Operator: createExchangeCashPersonCommand.Operator,
|
1808
|
+ ExchangedCash: exchangedCash,
|
|
|
1809
|
+ Operator: createExchangeCashPersonCommand.Operator,
|
1807
|
}
|
1810
|
}
|
1808
|
if err := personFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashPersonCommand)); err != nil {
|
1811
|
if err := personFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashPersonCommand)); err != nil {
|
1809
|
row := []interface{}{
|
1812
|
row := []interface{}{
|
|
@@ -1838,17 +1841,17 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
|
@@ -1838,17 +1841,17 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
1838
|
}
|
1841
|
}
|
1839
|
|
1842
|
|
1840
|
// 更新素币兑换活动
|
1843
|
// 更新素币兑换活动
|
1841
|
- newExchangedSuMoney, _ := decimal.NewFromFloat(activityFoundExchangedSuMoney).Sub(decimal.NewFromFloat(suMoneyDecrement)).Float64()
|
1844
|
+ newExchangedSuMoney, _ := decimal.NewFromFloat(activityFoundExchangedSuMoney).Sub(decimal.NewFromFloat(suMoneyDecrement)).Float64()
|
1842
|
newExchangedCash, _ := decimal.NewFromFloat(activityFoundExchangedCash).Sub(decimal.NewFromFloat(cashDecrement)).Float64()
|
1845
|
newExchangedCash, _ := decimal.NewFromFloat(activityFoundExchangedCash).Sub(decimal.NewFromFloat(cashDecrement)).Float64()
|
1843
|
- updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{
|
1846
|
+ updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{
|
1844
|
ExchangeCashActivityId: personFound.ExchangeCashActivityId,
|
1847
|
ExchangeCashActivityId: personFound.ExchangeCashActivityId,
|
1845
|
//ExchangedSuMoney: activityFoundExchangedSuMoney - suMoneyDecrement,
|
1848
|
//ExchangedSuMoney: activityFoundExchangedSuMoney - suMoneyDecrement,
|
1846
|
//ExchangedCash: activityFoundExchangedCash - cashDecrement,
|
1849
|
//ExchangedCash: activityFoundExchangedCash - cashDecrement,
|
1847
|
- ExchangedSuMoney: newExchangedSuMoney,
|
|
|
1848
|
- ExchangedCash: newExchangedCash,
|
|
|
1849
|
- Deadline: activityFound.Deadline,
|
|
|
1850
|
- CountDown: activityFound.CountDown,
|
|
|
1851
|
- ExchangeRate: activityFound.Rate,
|
1850
|
+ ExchangedSuMoney: newExchangedSuMoney,
|
|
|
1851
|
+ ExchangedCash: newExchangedCash,
|
|
|
1852
|
+ Deadline: activityFound.Deadline,
|
|
|
1853
|
+ CountDown: activityFound.CountDown,
|
|
|
1854
|
+ ExchangeRate: activityFound.Rate,
|
1852
|
}
|
1855
|
}
|
1853
|
if err := activityFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashActivityCommand)); err != nil {
|
1856
|
if err := activityFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashActivityCommand)); err != nil {
|
1854
|
row := []interface{}{
|
1857
|
row := []interface{}{
|
|
@@ -1887,7 +1890,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
|
@@ -1887,7 +1890,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
1887
|
Uid: employeeFound.EmployeeInfo.Uid,
|
1890
|
Uid: employeeFound.EmployeeInfo.Uid,
|
1888
|
Operator: createExchangeCashPersonCommand.Operator,
|
1891
|
Operator: createExchangeCashPersonCommand.Operator,
|
1889
|
SuMoney: suMoneyDecrement,
|
1892
|
SuMoney: suMoneyDecrement,
|
1890
|
- OperationType: 41, // 操作类型->记录类型对应:1->3: 增加 2->4: 扣除 3->1: 兑换物资 4->5: 兑换现金活动 41->6: 撤回兑换现金素币 5->2: 任务奖励
|
1893
|
+ OperationType: 41, // 操作类型->记录类型对应:1->3: 增加 2->4: 扣除 3->1: 兑换物资 4->5: 兑换现金活动 41->6: 撤回兑换现金素币 5->2: 任务奖励
|
1891
|
OperationDescription: activityFound.ExchangeActivityName + "调整",
|
1894
|
OperationDescription: activityFound.ExchangeActivityName + "调整",
|
1892
|
}
|
1895
|
}
|
1893
|
task, err := operationSuMoneyService.Operation(operationSuMoneyCommand.Uid, operationSuMoneyCommand.Operator, operationSuMoneyCommand.SuMoney, operationSuMoneyCommand.OperationType, operationSuMoneyCommand.OperationDescription)
|
1896
|
task, err := operationSuMoneyService.Operation(operationSuMoneyCommand.Uid, operationSuMoneyCommand.Operator, operationSuMoneyCommand.SuMoney, operationSuMoneyCommand.OperationType, operationSuMoneyCommand.OperationDescription)
|
|
@@ -1935,7 +1938,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
|
@@ -1935,7 +1938,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
1935
|
continue
|
1938
|
continue
|
1936
|
}
|
1939
|
}
|
1937
|
systemExchangedSuMoney := systemSuMoneyStatistics["systemExchangedSuMoney"].(float64) // 公司已兑换素币
|
1940
|
systemExchangedSuMoney := systemSuMoneyStatistics["systemExchangedSuMoney"].(float64) // 公司已兑换素币
|
1938
|
- systemUnExchangeSuMoney := systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64) // 公司未兑换素币
|
1941
|
+ systemUnExchangeSuMoney := systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64) // 公司未兑换素币
|
1939
|
|
1942
|
|
1940
|
// 更新现金池
|
1943
|
// 更新现金池
|
1941
|
var newRate float64
|
1944
|
var newRate float64
|
|
@@ -1948,8 +1951,8 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
|
@@ -1948,8 +1951,8 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
1948
|
cashPoolExchangedCash, _ := decimal.NewFromFloat(cashPoolFoundExchangedCash).Sub(decimal.NewFromFloat(cashDecrement)).Float64()
|
1951
|
cashPoolExchangedCash, _ := decimal.NewFromFloat(cashPoolFoundExchangedCash).Sub(decimal.NewFromFloat(cashDecrement)).Float64()
|
1949
|
unExchangeCash, _ := decimal.NewFromFloat(cashPoolFoundUnExchangeCash).Add(decimal.NewFromFloat(cashDecrement)).Float64()
|
1952
|
unExchangeCash, _ := decimal.NewFromFloat(cashPoolFoundUnExchangeCash).Add(decimal.NewFromFloat(cashDecrement)).Float64()
|
1950
|
updateCashPoolCommand := &command.UpdateCashPoolCommand{
|
1953
|
updateCashPoolCommand := &command.UpdateCashPoolCommand{
|
1951
|
- CashPoolId: cashPoolFound.CashPoolId,
|
|
|
1952
|
- Cash: cashPoolFound.Cash,
|
1954
|
+ CashPoolId: cashPoolFound.CashPoolId,
|
|
|
1955
|
+ Cash: cashPoolFound.Cash,
|
1953
|
//ExchangedCash: cashPoolFoundExchangedCash - cashDecrement,
|
1956
|
//ExchangedCash: cashPoolFoundExchangedCash - cashDecrement,
|
1954
|
//UnExchangeCash: cashPoolFoundUnExchangeCash + cashDecrement,
|
1957
|
//UnExchangeCash: cashPoolFoundUnExchangeCash + cashDecrement,
|
1955
|
ExchangedCash: cashPoolExchangedCash,
|
1958
|
ExchangedCash: cashPoolExchangedCash,
|
|
@@ -1957,7 +1960,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
|
@@ -1957,7 +1960,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
1957
|
ExchangedSuMoney: systemExchangedSuMoney,
|
1960
|
ExchangedSuMoney: systemExchangedSuMoney,
|
1958
|
UnExchangeSuMoney: systemUnExchangeSuMoney,
|
1961
|
UnExchangeSuMoney: systemUnExchangeSuMoney,
|
1959
|
Rate: newRate,
|
1962
|
Rate: newRate,
|
1960
|
- LastRate: cashPoolFound.LastRate,
|
1963
|
+ LastRate: cashPoolFound.LastRate,
|
1961
|
}
|
1964
|
}
|
1962
|
if err := cashPoolFound.Update(tool_funs.SimpleStructToMap(updateCashPoolCommand)); err != nil {
|
1965
|
if err := cashPoolFound.Update(tool_funs.SimpleStructToMap(updateCashPoolCommand)); err != nil {
|
1963
|
row := []interface{}{
|
1966
|
row := []interface{}{
|
|
@@ -1990,7 +1993,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
|
@@ -1990,7 +1993,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
1990
|
failureDataList = append(failureDataList, row)
|
1993
|
failureDataList = append(failureDataList, row)
|
1991
|
continue
|
1994
|
continue
|
1992
|
}
|
1995
|
}
|
1993
|
- } else { // 当前兑换素币大于等于已兑换素币,追加兑换素币
|
1996
|
+ } else { // 当前兑换素币大于等于已兑换素币,追加兑换素币
|
1994
|
// 素币增量
|
1997
|
// 素币增量
|
1995
|
//suMoneyIncrement := createExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney
|
1998
|
//suMoneyIncrement := createExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney
|
1996
|
suMoneyIncrement, _ := decimal.NewFromFloat(createExchangeCashPersonCommand.ExchangedSuMoney).Sub(decimal.NewFromFloat(personFoundExchangedSuMoney)).Float64()
|
1999
|
suMoneyIncrement, _ := decimal.NewFromFloat(createExchangeCashPersonCommand.ExchangedSuMoney).Sub(decimal.NewFromFloat(personFoundExchangedSuMoney)).Float64()
|
|
@@ -2014,12 +2017,12 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
|
@@ -2014,12 +2017,12 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
2014
|
exchangedSuMoney, _ := decimal.NewFromFloat(personFoundExchangedSuMoney).Add(decimal.NewFromFloat(suMoneyIncrement)).Float64()
|
2017
|
exchangedSuMoney, _ := decimal.NewFromFloat(personFoundExchangedSuMoney).Add(decimal.NewFromFloat(suMoneyIncrement)).Float64()
|
2015
|
exchangedCash, _ := decimal.NewFromFloat(personFoundExchangedCash).Add(decimal.NewFromFloat(cashIncrement)).Float64()
|
2018
|
exchangedCash, _ := decimal.NewFromFloat(personFoundExchangedCash).Add(decimal.NewFromFloat(cashIncrement)).Float64()
|
2016
|
updateExchangeCashPersonCommand := &command.UpdateExchangeCashPersonCommand{
|
2019
|
updateExchangeCashPersonCommand := &command.UpdateExchangeCashPersonCommand{
|
2017
|
- ListId: personFound.ListId,
|
2020
|
+ ListId: personFound.ListId,
|
2018
|
//ExchangedSuMoney: personFoundExchangedSuMoney + suMoneyIncrement,
|
2021
|
//ExchangedSuMoney: personFoundExchangedSuMoney + suMoneyIncrement,
|
2019
|
//ExchangedCash: personFoundExchangedCash + cashIncrement,
|
2022
|
//ExchangedCash: personFoundExchangedCash + cashIncrement,
|
2020
|
ExchangedSuMoney: exchangedSuMoney,
|
2023
|
ExchangedSuMoney: exchangedSuMoney,
|
2021
|
- ExchangedCash: exchangedCash,
|
|
|
2022
|
- Operator: createExchangeCashPersonCommand.Operator,
|
2024
|
+ ExchangedCash: exchangedCash,
|
|
|
2025
|
+ Operator: createExchangeCashPersonCommand.Operator,
|
2023
|
}
|
2026
|
}
|
2024
|
if err := personFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashPersonCommand)); err != nil {
|
2027
|
if err := personFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashPersonCommand)); err != nil {
|
2025
|
row := []interface{}{
|
2028
|
row := []interface{}{
|
|
@@ -2060,11 +2063,11 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
|
@@ -2060,11 +2063,11 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
2060
|
ExchangeCashActivityId: personFound.ExchangeCashActivityId,
|
2063
|
ExchangeCashActivityId: personFound.ExchangeCashActivityId,
|
2061
|
//ExchangedSuMoney: activityFoundExchangedSuMoney + suMoneyIncrement,
|
2064
|
//ExchangedSuMoney: activityFoundExchangedSuMoney + suMoneyIncrement,
|
2062
|
//ExchangedCash: activityFoundExchangedCash + cashIncrement,
|
2065
|
//ExchangedCash: activityFoundExchangedCash + cashIncrement,
|
2063
|
- ExchangedSuMoney: newExchangedSuMoney,
|
|
|
2064
|
- ExchangedCash: newExchangedCash,
|
|
|
2065
|
- Deadline: activityFound.Deadline,
|
|
|
2066
|
- CountDown: activityFound.CountDown,
|
|
|
2067
|
- ExchangeRate: activityFound.Rate,
|
2066
|
+ ExchangedSuMoney: newExchangedSuMoney,
|
|
|
2067
|
+ ExchangedCash: newExchangedCash,
|
|
|
2068
|
+ Deadline: activityFound.Deadline,
|
|
|
2069
|
+ CountDown: activityFound.CountDown,
|
|
|
2070
|
+ ExchangeRate: activityFound.Rate,
|
2068
|
}
|
2071
|
}
|
2069
|
if err := activityFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashActivityCommand)); err != nil {
|
2072
|
if err := activityFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashActivityCommand)); err != nil {
|
2070
|
row := []interface{}{
|
2073
|
row := []interface{}{
|
|
@@ -2103,7 +2106,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
|
@@ -2103,7 +2106,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
2103
|
Uid: employeeFound.EmployeeInfo.Uid,
|
2106
|
Uid: employeeFound.EmployeeInfo.Uid,
|
2104
|
Operator: createExchangeCashPersonCommand.Operator,
|
2107
|
Operator: createExchangeCashPersonCommand.Operator,
|
2105
|
SuMoney: suMoneyIncrement,
|
2108
|
SuMoney: suMoneyIncrement,
|
2106
|
- OperationType: 4, // 操作类型->记录类型对应:1->3: 增加 2->4: 扣除 3->1: 兑换物资 4->5: 兑换现金活动 41->6: 撤回兑换现金素币 5->2: 任务奖励
|
2109
|
+ OperationType: 4, // 操作类型->记录类型对应:1->3: 增加 2->4: 扣除 3->1: 兑换物资 4->5: 兑换现金活动 41->6: 撤回兑换现金素币 5->2: 任务奖励
|
2107
|
OperationDescription: activityFound.ExchangeActivityName + "调整",
|
2110
|
OperationDescription: activityFound.ExchangeActivityName + "调整",
|
2108
|
}
|
2111
|
}
|
2109
|
task, err := operationSuMoneyService.Operation(operationSuMoneyCommand.Uid, operationSuMoneyCommand.Operator, operationSuMoneyCommand.SuMoney, operationSuMoneyCommand.OperationType, operationSuMoneyCommand.OperationDescription)
|
2112
|
task, err := operationSuMoneyService.Operation(operationSuMoneyCommand.Uid, operationSuMoneyCommand.Operator, operationSuMoneyCommand.SuMoney, operationSuMoneyCommand.OperationType, operationSuMoneyCommand.OperationDescription)
|
|
@@ -2176,8 +2179,8 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
|
@@ -2176,8 +2179,8 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
2176
|
newCashPoolExchangedCash, _ := decimal.NewFromFloat(cashPoolFoundExchangedCash).Add(decimal.NewFromFloat(cashIncrement)).Float64()
|
2179
|
newCashPoolExchangedCash, _ := decimal.NewFromFloat(cashPoolFoundExchangedCash).Add(decimal.NewFromFloat(cashIncrement)).Float64()
|
2177
|
unExchangeCash, _ := decimal.NewFromFloat(cashPoolFoundUnExchangeCash).Sub(decimal.NewFromFloat(cashIncrement)).Float64()
|
2180
|
unExchangeCash, _ := decimal.NewFromFloat(cashPoolFoundUnExchangeCash).Sub(decimal.NewFromFloat(cashIncrement)).Float64()
|
2178
|
updateCashPoolCommand := &command.UpdateCashPoolCommand{
|
2181
|
updateCashPoolCommand := &command.UpdateCashPoolCommand{
|
2179
|
- CashPoolId: cashPoolFound.CashPoolId,
|
|
|
2180
|
- Cash: cashPoolFound.Cash,
|
2182
|
+ CashPoolId: cashPoolFound.CashPoolId,
|
|
|
2183
|
+ Cash: cashPoolFound.Cash,
|
2181
|
//ExchangedCash: cashPoolFoundExchangedCash + cashIncrement,
|
2184
|
//ExchangedCash: cashPoolFoundExchangedCash + cashIncrement,
|
2182
|
//UnExchangeCash: cashPoolFoundUnExchangeCash - cashIncrement,
|
2185
|
//UnExchangeCash: cashPoolFoundUnExchangeCash - cashIncrement,
|
2183
|
ExchangedCash: newCashPoolExchangedCash,
|
2186
|
ExchangedCash: newCashPoolExchangedCash,
|
|
@@ -2185,7 +2188,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
|
@@ -2185,7 +2188,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
2185
|
ExchangedSuMoney: systemExchangedSuMoney,
|
2188
|
ExchangedSuMoney: systemExchangedSuMoney,
|
2186
|
UnExchangeSuMoney: systemUnExchangeSuMoney,
|
2189
|
UnExchangeSuMoney: systemUnExchangeSuMoney,
|
2187
|
Rate: newRate,
|
2190
|
Rate: newRate,
|
2188
|
- LastRate: cashPoolFound.LastRate,
|
2191
|
+ LastRate: cashPoolFound.LastRate,
|
2189
|
}
|
2192
|
}
|
2190
|
if err := cashPoolFound.Update(tool_funs.SimpleStructToMap(updateCashPoolCommand)); err != nil {
|
2193
|
if err := cashPoolFound.Update(tool_funs.SimpleStructToMap(updateCashPoolCommand)); err != nil {
|
2191
|
row := []interface{}{
|
2194
|
row := []interface{}{
|
|
@@ -2271,7 +2274,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC |
|
@@ -2271,7 +2274,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC |
2271
|
|
2274
|
|
2272
|
// 现金池仓储初始化
|
2275
|
// 现金池仓储初始化
|
2273
|
var cashPoolRepository domain.CashPoolRepository
|
2276
|
var cashPoolRepository domain.CashPoolRepository
|
2274
|
- if value, err := factory.CreateCashPoolRepository(map[string] interface{} {
|
2277
|
+ if value, err := factory.CreateCashPoolRepository(map[string]interface{}{
|
2275
|
"transactionContext": transactionContext,
|
2278
|
"transactionContext": transactionContext,
|
2276
|
}); err != nil {
|
2279
|
}); err != nil {
|
2277
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
2280
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
@@ -2319,7 +2322,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC |
|
@@ -2319,7 +2322,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC |
2319
|
|
2322
|
|
2320
|
// 判断当前员工是否有效
|
2323
|
// 判断当前员工是否有效
|
2321
|
getEmployee := map[string]interface{}{
|
2324
|
getEmployee := map[string]interface{}{
|
2322
|
- "uid": createExchangeCashPersonCommand.Uid,
|
2325
|
+ "uid": createExchangeCashPersonCommand.Uid,
|
2323
|
"companyId": activityFound.CompanyId,
|
2326
|
"companyId": activityFound.CompanyId,
|
2324
|
}
|
2327
|
}
|
2325
|
employeeFound, err := employeeRepository.FindOne(getEmployee)
|
2328
|
employeeFound, err := employeeRepository.FindOne(getEmployee)
|
|
@@ -2334,7 +2337,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC |
|
@@ -2334,7 +2337,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC |
2334
|
// 判断当前员工是否已经存在兑换素币清单中
|
2337
|
// 判断当前员工是否已经存在兑换素币清单中
|
2335
|
if _, people, err := exchangeCashPersonListRepository.Find(map[string]interface{}{
|
2338
|
if _, people, err := exchangeCashPersonListRepository.Find(map[string]interface{}{
|
2336
|
"exchangeCashActivityId": activityFound.ActivityId,
|
2339
|
"exchangeCashActivityId": activityFound.ActivityId,
|
2337
|
- "uid": employeeFound.EmployeeInfo.Uid,
|
2340
|
+ "uid": employeeFound.EmployeeInfo.Uid,
|
2338
|
}); err != nil {
|
2341
|
}); err != nil {
|
2339
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
2342
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
2340
|
} else {
|
2343
|
} else {
|
|
@@ -2358,8 +2361,8 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC |
|
@@ -2358,8 +2361,8 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC |
2358
|
EmployeeAccount: employeeFound.EmployeeInfo.EmployeeAccount,
|
2361
|
EmployeeAccount: employeeFound.EmployeeInfo.EmployeeAccount,
|
2359
|
},
|
2362
|
},
|
2360
|
ExchangeCashActivityId: createExchangeCashPersonCommand.ExchangeCashActivityId,
|
2363
|
ExchangeCashActivityId: createExchangeCashPersonCommand.ExchangeCashActivityId,
|
2361
|
- ExchangedSuMoney: createExchangeCashPersonCommand.ExchangedSuMoney,
|
|
|
2362
|
- ExchangedCash: newPersonExchangedCash,
|
2364
|
+ ExchangedSuMoney: createExchangeCashPersonCommand.ExchangedSuMoney,
|
|
|
2365
|
+ ExchangedCash: newPersonExchangedCash,
|
2363
|
}
|
2366
|
}
|
2364
|
|
2367
|
|
2365
|
// 保存兑换素币清单
|
2368
|
// 保存兑换素币清单
|
|
@@ -2369,7 +2372,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC |
|
@@ -2369,7 +2372,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC |
2369
|
}
|
2372
|
}
|
2370
|
|
2373
|
|
2371
|
// 操作素币命令
|
2374
|
// 操作素币命令
|
2372
|
- operationSuMoneyCommand := &command.OperationSuMoneyCommand{
|
2375
|
+ operationSuMoneyCommand := &command.OperationSuMoneyCommand{
|
2373
|
Uid: employeeFound.EmployeeInfo.Uid,
|
2376
|
Uid: employeeFound.EmployeeInfo.Uid,
|
2374
|
Operator: createExchangeCashPersonCommand.Operator,
|
2377
|
Operator: createExchangeCashPersonCommand.Operator,
|
2375
|
SuMoney: createExchangeCashPersonCommand.ExchangedSuMoney,
|
2378
|
SuMoney: createExchangeCashPersonCommand.ExchangedSuMoney,
|
|
@@ -2387,18 +2390,18 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC |
|
@@ -2387,18 +2390,18 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC |
2387
|
}
|
2390
|
}
|
2388
|
|
2391
|
|
2389
|
// 更新兑换活动命令
|
2392
|
// 更新兑换活动命令
|
2390
|
- exchangedSuMoney, _ := decimal.NewFromFloat(activityFoundExchangedSuMoney).Add(decimal.NewFromFloat(createExchangeCashPersonCommand.ExchangedSuMoney)).Float64()
|
|
|
2391
|
- exchangedCash, _ := decimal.NewFromFloat(activityFoundExchangedCash).Add(decimal.NewFromFloat(createExchangeCashPersonCommand.ExchangedSuMoney).Mul(decimal.NewFromFloat(activityFound.Rate))).Float64()
|
|
|
2392
|
- updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{
|
2393
|
+ exchangedSuMoney, _ := decimal.NewFromFloat(activityFoundExchangedSuMoney).Add(decimal.NewFromFloat(createExchangeCashPersonCommand.ExchangedSuMoney)).Float64()
|
|
|
2394
|
+ exchangedCash, _ := decimal.NewFromFloat(activityFoundExchangedCash).Add(decimal.NewFromFloat(createExchangeCashPersonCommand.ExchangedSuMoney).Mul(decimal.NewFromFloat(activityFound.Rate))).Float64()
|
|
|
2395
|
+ updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{
|
2393
|
ExchangeCashActivityId: personSaved.ExchangeCashActivityId,
|
2396
|
ExchangeCashActivityId: personSaved.ExchangeCashActivityId,
|
2394
|
ExchangeActivityName: activityFound.ExchangeActivityName,
|
2397
|
ExchangeActivityName: activityFound.ExchangeActivityName,
|
2395
|
//ExchangedSuMoney: activityFoundExchangedSuMoney + createExchangeCashPersonCommand.ExchangedSuMoney,
|
2398
|
//ExchangedSuMoney: activityFoundExchangedSuMoney + createExchangeCashPersonCommand.ExchangedSuMoney,
|
2396
|
//ExchangedCash: activityFoundExchangedCash + createExchangeCashPersonCommand.ExchangedSuMoney * activityFound.Rate,
|
2399
|
//ExchangedCash: activityFoundExchangedCash + createExchangeCashPersonCommand.ExchangedSuMoney * activityFound.Rate,
|
2397
|
- ExchangedSuMoney: exchangedSuMoney,
|
|
|
2398
|
- ExchangedCash: exchangedCash,
|
|
|
2399
|
- Deadline: activityFound.Deadline,
|
|
|
2400
|
- CountDown: activityFound.CountDown,
|
|
|
2401
|
- ExchangeRate: activityFound.Rate,
|
2400
|
+ ExchangedSuMoney: exchangedSuMoney,
|
|
|
2401
|
+ ExchangedCash: exchangedCash,
|
|
|
2402
|
+ Deadline: activityFound.Deadline,
|
|
|
2403
|
+ CountDown: activityFound.CountDown,
|
|
|
2404
|
+ ExchangeRate: activityFound.Rate,
|
2402
|
}
|
2405
|
}
|
2403
|
|
2406
|
|
2404
|
// 更新兑换活动
|
2407
|
// 更新兑换活动
|
|
@@ -2429,7 +2432,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC |
|
@@ -2429,7 +2432,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC |
2429
|
cashPoolFoundExchangedCash := cashPoolsFound[0].ExchangedCash
|
2432
|
cashPoolFoundExchangedCash := cashPoolsFound[0].ExchangedCash
|
2430
|
|
2433
|
|
2431
|
// 判断是否超过平台未兑换现金
|
2434
|
// 判断是否超过平台未兑换现金
|
2432
|
- if createExchangeCashPersonCommand.ExchangedSuMoney * activityFound.Rate > cashPoolFoundUnExchangeCash {
|
2435
|
+ if createExchangeCashPersonCommand.ExchangedSuMoney*activityFound.Rate > cashPoolFoundUnExchangeCash {
|
2433
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "已超过投入现金池的未兑换现金")
|
2436
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "已超过投入现金池的未兑换现金")
|
2434
|
}
|
2437
|
}
|
2435
|
|
2438
|
|
|
@@ -2454,11 +2457,11 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC |
|
@@ -2454,11 +2457,11 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC |
2454
|
}
|
2457
|
}
|
2455
|
|
2458
|
|
2456
|
// 更新现金池命令
|
2459
|
// 更新现金池命令
|
2457
|
- newCashPoolExchangedCash, _ := decimal.NewFromFloat(cashPoolFoundExchangedCash).Add(decimal.NewFromFloat(personSaved.ExchangedCash)).Float64()
|
|
|
2458
|
- unExchangeCash, _ := decimal.NewFromFloat(cashPoolFoundUnExchangeCash).Sub(decimal.NewFromFloat(personSaved.ExchangedCash)).Float64()
|
2460
|
+ newCashPoolExchangedCash, _ := decimal.NewFromFloat(cashPoolFoundExchangedCash).Add(decimal.NewFromFloat(personSaved.ExchangedCash)).Float64()
|
|
|
2461
|
+ unExchangeCash, _ := decimal.NewFromFloat(cashPoolFoundUnExchangeCash).Sub(decimal.NewFromFloat(personSaved.ExchangedCash)).Float64()
|
2459
|
updateCashPoolCommand := &command.UpdateCashPoolCommand{
|
2462
|
updateCashPoolCommand := &command.UpdateCashPoolCommand{
|
2460
|
- CashPoolId: cashPoolsFound[0].CashPoolId,
|
|
|
2461
|
- Cash: cashPoolsFound[0].Cash,
|
2463
|
+ CashPoolId: cashPoolsFound[0].CashPoolId,
|
|
|
2464
|
+ Cash: cashPoolsFound[0].Cash,
|
2462
|
//ExchangedCash: cashPoolFoundExchangedCash + personSaved.ExchangedCash,
|
2465
|
//ExchangedCash: cashPoolFoundExchangedCash + personSaved.ExchangedCash,
|
2463
|
//UnExchangeCash: cashPoolFoundUnExchangeCash - personSaved.ExchangedCash,
|
2466
|
//UnExchangeCash: cashPoolFoundUnExchangeCash - personSaved.ExchangedCash,
|
2464
|
ExchangedCash: newCashPoolExchangedCash,
|
2467
|
ExchangedCash: newCashPoolExchangedCash,
|
|
@@ -2466,7 +2469,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC |
|
@@ -2466,7 +2469,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC |
2466
|
ExchangedSuMoney: systemExchangedSuMoney,
|
2469
|
ExchangedSuMoney: systemExchangedSuMoney,
|
2467
|
UnExchangeSuMoney: systemUnExchangeSuMoney,
|
2470
|
UnExchangeSuMoney: systemUnExchangeSuMoney,
|
2468
|
Rate: newRate,
|
2471
|
Rate: newRate,
|
2469
|
- LastRate: cashPoolsFound[0].LastRate,
|
2472
|
+ LastRate: cashPoolsFound[0].LastRate,
|
2470
|
}
|
2473
|
}
|
2471
|
|
2474
|
|
2472
|
// 更新现金池
|
2475
|
// 更新现金池
|
|
@@ -2589,8 +2592,8 @@ func (cashPoolService *CashPoolService) ListExchangeCashPerson(listExchangeCashP |
|
@@ -2589,8 +2592,8 @@ func (cashPoolService *CashPoolService) ListExchangeCashPerson(listExchangeCashP |
2589
|
// 获取该公司活动下所有兑换员工
|
2592
|
// 获取该公司活动下所有兑换员工
|
2590
|
if count, people, err := exchangeCashPersonListRepository.FindAll(map[string]interface{}{
|
2593
|
if count, people, err := exchangeCashPersonListRepository.FindAll(map[string]interface{}{
|
2591
|
"exchangeCashActivityIds": activityIds,
|
2594
|
"exchangeCashActivityIds": activityIds,
|
2592
|
- "offset": listExchangeCashPersonQuery.Offset,
|
|
|
2593
|
- "limit": listExchangeCashPersonQuery.Limit,
|
2595
|
+ "offset": listExchangeCashPersonQuery.Offset,
|
|
|
2596
|
+ "limit": listExchangeCashPersonQuery.Limit,
|
2594
|
}); err != nil {
|
2597
|
}); err != nil {
|
2595
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
2598
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
2596
|
} else {
|
2599
|
} else {
|
|
@@ -2602,8 +2605,8 @@ func (cashPoolService *CashPoolService) ListExchangeCashPerson(listExchangeCashP |
|
@@ -2602,8 +2605,8 @@ func (cashPoolService *CashPoolService) ListExchangeCashPerson(listExchangeCashP |
2602
|
people[i].ExchangedCash, _ = decimal.NewFromFloatWithExponent(people[i].ExchangedCash, -2).Float64()
|
2605
|
people[i].ExchangedCash, _ = decimal.NewFromFloatWithExponent(people[i].ExchangedCash, -2).Float64()
|
2603
|
}
|
2606
|
}
|
2604
|
return map[string]interface{}{
|
2607
|
return map[string]interface{}{
|
2605
|
- "count": count,
|
|
|
2606
|
- "people": people,
|
2608
|
+ "count": count,
|
|
|
2609
|
+ "people": people,
|
2607
|
}, nil
|
2610
|
}, nil
|
2608
|
}
|
2611
|
}
|
2609
|
}
|
2612
|
}
|
|
@@ -2620,8 +2623,8 @@ func (cashPoolService *CashPoolService) ListExchangeCashPerson(listExchangeCashP |
|
@@ -2620,8 +2623,8 @@ func (cashPoolService *CashPoolService) ListExchangeCashPerson(listExchangeCashP |
2620
|
people[i].ExchangedCash, _ = decimal.NewFromFloatWithExponent(people[i].ExchangedCash, -2).Float64()
|
2623
|
people[i].ExchangedCash, _ = decimal.NewFromFloatWithExponent(people[i].ExchangedCash, -2).Float64()
|
2621
|
}
|
2624
|
}
|
2622
|
return map[string]interface{}{
|
2625
|
return map[string]interface{}{
|
2623
|
- "count": count,
|
|
|
2624
|
- "people": people,
|
2626
|
+ "count": count,
|
|
|
2627
|
+ "people": people,
|
2625
|
}, nil
|
2628
|
}, nil
|
2626
|
}
|
2629
|
}
|
2627
|
}
|
2630
|
}
|
|
@@ -2665,7 +2668,7 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC |
|
@@ -2665,7 +2668,7 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC |
2665
|
|
2668
|
|
2666
|
// 现金池仓储初始化
|
2669
|
// 现金池仓储初始化
|
2667
|
var cashPoolRepository domain.CashPoolRepository
|
2670
|
var cashPoolRepository domain.CashPoolRepository
|
2668
|
- if value, err := factory.CreateCashPoolRepository(map[string] interface{} {
|
2671
|
+ if value, err := factory.CreateCashPoolRepository(map[string]interface{}{
|
2669
|
"transactionContext": transactionContext,
|
2672
|
"transactionContext": transactionContext,
|
2670
|
}); err != nil {
|
2673
|
}); err != nil {
|
2671
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
2674
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
@@ -2732,7 +2735,7 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC |
|
@@ -2732,7 +2735,7 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC |
2732
|
|
2735
|
|
2733
|
// 判断当前员工是否有效
|
2736
|
// 判断当前员工是否有效
|
2734
|
getEmployee := map[string]interface{}{
|
2737
|
getEmployee := map[string]interface{}{
|
2735
|
- "uid": personFound.EmployeeInfo.Uid,
|
2738
|
+ "uid": personFound.EmployeeInfo.Uid,
|
2736
|
"companyId": activityFound.CompanyId,
|
2739
|
"companyId": activityFound.CompanyId,
|
2737
|
}
|
2740
|
}
|
2738
|
employeeFound, err := employeeRepository.FindOne(getEmployee)
|
2741
|
employeeFound, err := employeeRepository.FindOne(getEmployee)
|
|
@@ -2745,16 +2748,16 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC |
|
@@ -2745,16 +2748,16 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC |
2745
|
|
2748
|
|
2746
|
// 更新兑换素币活动命令
|
2749
|
// 更新兑换素币活动命令
|
2747
|
exchangedSuMoney, _ := decimal.NewFromFloat(activityFoundExchangedSuMoney).Sub(decimal.NewFromFloat(personFoundExchangedSuMoney)).Float64()
|
2750
|
exchangedSuMoney, _ := decimal.NewFromFloat(activityFoundExchangedSuMoney).Sub(decimal.NewFromFloat(personFoundExchangedSuMoney)).Float64()
|
2748
|
- exchangedCash, _ := decimal.NewFromFloat(activityFoundExchangedCash).Sub(decimal.NewFromFloat(personFoundExchangedCash)).Float64()
|
|
|
2749
|
- updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{
|
2751
|
+ exchangedCash, _ := decimal.NewFromFloat(activityFoundExchangedCash).Sub(decimal.NewFromFloat(personFoundExchangedCash)).Float64()
|
|
|
2752
|
+ updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{
|
2750
|
ExchangeCashActivityId: personFound.ExchangeCashActivityId,
|
2753
|
ExchangeCashActivityId: personFound.ExchangeCashActivityId,
|
2751
|
//ExchangedSuMoney: activityFoundExchangedSuMoney - personFoundExchangedSuMoney,
|
2754
|
//ExchangedSuMoney: activityFoundExchangedSuMoney - personFoundExchangedSuMoney,
|
2752
|
//ExchangedCash: activityFoundExchangedCash - personFoundExchangedCash,
|
2755
|
//ExchangedCash: activityFoundExchangedCash - personFoundExchangedCash,
|
2753
|
- ExchangedSuMoney: exchangedSuMoney,
|
|
|
2754
|
- ExchangedCash: exchangedCash,
|
|
|
2755
|
- Deadline: activityFound.Deadline,
|
|
|
2756
|
- CountDown: activityFound.CountDown,
|
|
|
2757
|
- ExchangeRate: activityFound.Rate,
|
2756
|
+ ExchangedSuMoney: exchangedSuMoney,
|
|
|
2757
|
+ ExchangedCash: exchangedCash,
|
|
|
2758
|
+ Deadline: activityFound.Deadline,
|
|
|
2759
|
+ CountDown: activityFound.CountDown,
|
|
|
2760
|
+ ExchangeRate: activityFound.Rate,
|
2758
|
}
|
2761
|
}
|
2759
|
|
2762
|
|
2760
|
// 更新兑换活动
|
2763
|
// 更新兑换活动
|
|
@@ -2772,11 +2775,11 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC |
|
@@ -2772,11 +2775,11 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC |
2772
|
}
|
2775
|
}
|
2773
|
|
2776
|
|
2774
|
// 操作素币命令
|
2777
|
// 操作素币命令
|
2775
|
- operationSuMoneyCommand := &command.OperationSuMoneyCommand{
|
2778
|
+ operationSuMoneyCommand := &command.OperationSuMoneyCommand{
|
2776
|
Uid: personFound.EmployeeInfo.Uid,
|
2779
|
Uid: personFound.EmployeeInfo.Uid,
|
2777
|
Operator: removeExchangeCashPersonCommand.Operator,
|
2780
|
Operator: removeExchangeCashPersonCommand.Operator,
|
2778
|
SuMoney: personFoundExchangedSuMoney,
|
2781
|
SuMoney: personFoundExchangedSuMoney,
|
2779
|
- OperationType: 41, // 删除兑换素币清单,撤回已兑换素币
|
2782
|
+ OperationType: 41, // 删除兑换素币清单,撤回已兑换素币
|
2780
|
OperationDescription: activityFound.ExchangeActivityName + "调整",
|
2783
|
OperationDescription: activityFound.ExchangeActivityName + "调整",
|
2781
|
}
|
2784
|
}
|
2782
|
|
2785
|
|
|
@@ -2824,12 +2827,12 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC |
|
@@ -2824,12 +2827,12 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC |
2824
|
}
|
2827
|
}
|
2825
|
|
2828
|
|
2826
|
// 更新现金池命令
|
2829
|
// 更新现金池命令
|
2827
|
- newExchangedCash, _ := decimal.NewFromFloat(cashPoolFoundExchangedCash).Sub(decimal.NewFromFloat(personFoundExchangedCash)).Float64()
|
|
|
2828
|
- UnExchangeCash, _ := decimal.NewFromFloat(cashPoolFoundUnExchangeCash).Add(decimal.NewFromFloat(personFoundExchangedCash)).Float64()
|
2830
|
+ newExchangedCash, _ := decimal.NewFromFloat(cashPoolFoundExchangedCash).Sub(decimal.NewFromFloat(personFoundExchangedCash)).Float64()
|
|
|
2831
|
+ UnExchangeCash, _ := decimal.NewFromFloat(cashPoolFoundUnExchangeCash).Add(decimal.NewFromFloat(personFoundExchangedCash)).Float64()
|
2829
|
updateCashPoolCommand := &command.UpdateCashPoolCommand{
|
2832
|
updateCashPoolCommand := &command.UpdateCashPoolCommand{
|
2830
|
- CashPoolId: cashPoolsFound[0].CashPoolId,
|
|
|
2831
|
- Cash: cashPoolsFound[0].Cash,
|
|
|
2832
|
- LastRate: cashPoolsFound[0].LastRate,
|
2833
|
+ CashPoolId: cashPoolsFound[0].CashPoolId,
|
|
|
2834
|
+ Cash: cashPoolsFound[0].Cash,
|
|
|
2835
|
+ LastRate: cashPoolsFound[0].LastRate,
|
2833
|
//ExchangedCash: cashPoolFoundExchangedCash - personFoundExchangedCash,
|
2836
|
//ExchangedCash: cashPoolFoundExchangedCash - personFoundExchangedCash,
|
2834
|
//UnExchangeCash: cashPoolFoundUnExchangeCash + personFoundExchangedCash,
|
2837
|
//UnExchangeCash: cashPoolFoundUnExchangeCash + personFoundExchangedCash,
|
2835
|
ExchangedCash: newExchangedCash,
|
2838
|
ExchangedCash: newExchangedCash,
|
|
@@ -2999,17 +3002,47 @@ func (cashPoolService *CashPoolService) ExchangeListRanking(exchangeListRankingQ |
|
@@ -2999,17 +3002,47 @@ func (cashPoolService *CashPoolService) ExchangeListRanking(exchangeListRankingQ |
2999
|
}
|
3002
|
}
|
3000
|
|
3003
|
|
3001
|
// 兑换素币清单排行榜
|
3004
|
// 兑换素币清单排行榜
|
3002
|
- for i, _ := range exchangeCashListRankingStatistics["people"].([]struct{Uid int64; EmployeeName string; SuMoney float64; Cash float64; Ranking int}) {
|
|
|
3003
|
- uid := exchangeCashListRankingStatistics["people"].([]struct{Uid int64; EmployeeName string; SuMoney float64; Cash float64; Ranking int})[i].Uid
|
3005
|
+ for i, _ := range exchangeCashListRankingStatistics["people"].([]struct {
|
|
|
3006
|
+ Uid int64
|
|
|
3007
|
+ EmployeeName string
|
|
|
3008
|
+ SuMoney float64
|
|
|
3009
|
+ Cash float64
|
|
|
3010
|
+ Ranking int
|
|
|
3011
|
+ }) {
|
|
|
3012
|
+ uid := exchangeCashListRankingStatistics["people"].([]struct {
|
|
|
3013
|
+ Uid int64
|
|
|
3014
|
+ EmployeeName string
|
|
|
3015
|
+ SuMoney float64
|
|
|
3016
|
+ Cash float64
|
|
|
3017
|
+ Ranking int
|
|
|
3018
|
+ })[i].Uid
|
3004
|
if uidName[uid] != nil {
|
3019
|
if uidName[uid] != nil {
|
3005
|
- exchangeCashListRankingStatistics["people"].([]struct{Uid int64; EmployeeName string; SuMoney float64; Cash float64; Ranking int})[i].EmployeeName = uidName[uid].(string)
|
3020
|
+ exchangeCashListRankingStatistics["people"].([]struct {
|
|
|
3021
|
+ Uid int64
|
|
|
3022
|
+ EmployeeName string
|
|
|
3023
|
+ SuMoney float64
|
|
|
3024
|
+ Cash float64
|
|
|
3025
|
+ Ranking int
|
|
|
3026
|
+ })[i].EmployeeName = uidName[uid].(string)
|
3006
|
}
|
3027
|
}
|
3007
|
}
|
3028
|
}
|
3008
|
|
3029
|
|
3009
|
// 个人素币兑换清单
|
3030
|
// 个人素币兑换清单
|
3010
|
if exchangeCashListRankingStatistics["currentEmployee"] != nil {
|
3031
|
if exchangeCashListRankingStatistics["currentEmployee"] != nil {
|
3011
|
- currentEmployeeExchangeCashList := exchangeCashListRankingStatistics["currentEmployee"].(struct{Uid int64;EmployeeName string;SuMoney float64; Cash float64;Ranking int})
|
|
|
3012
|
- uidExchangeCashList := exchangeCashListRankingStatistics["currentEmployee"].(struct{Uid int64;EmployeeName string;SuMoney float64; Cash float64;Ranking int}).Uid
|
3032
|
+ currentEmployeeExchangeCashList := exchangeCashListRankingStatistics["currentEmployee"].(struct {
|
|
|
3033
|
+ Uid int64
|
|
|
3034
|
+ EmployeeName string
|
|
|
3035
|
+ SuMoney float64
|
|
|
3036
|
+ Cash float64
|
|
|
3037
|
+ Ranking int
|
|
|
3038
|
+ })
|
|
|
3039
|
+ uidExchangeCashList := exchangeCashListRankingStatistics["currentEmployee"].(struct {
|
|
|
3040
|
+ Uid int64
|
|
|
3041
|
+ EmployeeName string
|
|
|
3042
|
+ SuMoney float64
|
|
|
3043
|
+ Cash float64
|
|
|
3044
|
+ Ranking int
|
|
|
3045
|
+ }).Uid
|
3013
|
if uidName[uidExchangeCashList] != nil {
|
3046
|
if uidName[uidExchangeCashList] != nil {
|
3014
|
currentEmployeeExchangeCashList.EmployeeName = uidName[uidExchangeCashList].(string)
|
3047
|
currentEmployeeExchangeCashList.EmployeeName = uidName[uidExchangeCashList].(string)
|
3015
|
}
|
3048
|
}
|