|
@@ -501,7 +501,7 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas |
|
@@ -501,7 +501,7 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas |
501
|
"deadline": activity.Deadline.UnixNano() / 1e6,
|
501
|
"deadline": activity.Deadline.UnixNano() / 1e6,
|
502
|
"countDown": activity.CountDown,
|
502
|
"countDown": activity.CountDown,
|
503
|
"rate": activity.Rate,
|
503
|
"rate": activity.Rate,
|
504
|
- "createTime": activity.Deadline,
|
504
|
+ "createTime": activity.CreateTime,
|
505
|
}
|
505
|
}
|
506
|
activitiesWithTs = append(activitiesWithTs, activityWithTs)
|
506
|
activitiesWithTs = append(activitiesWithTs, activityWithTs)
|
507
|
}
|
507
|
}
|
|
@@ -815,7 +815,6 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
|
@@ -815,7 +815,6 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
815
|
|
815
|
|
816
|
// 计算倒计时
|
816
|
// 计算倒计时
|
817
|
updateExchangeCashActivityCommand.CountDown = int64(t2.Sub(t1).Hours() / 24)
|
817
|
updateExchangeCashActivityCommand.CountDown = int64(t2.Sub(t1).Hours() / 24)
|
818
|
- //updateExchangeCashActivityCommand.Deadline = deadline
|
|
|
819
|
|
818
|
|
820
|
// 倒计时结束
|
819
|
// 倒计时结束
|
821
|
if t2.Before(t1) {
|
820
|
if t2.Before(t1) {
|
|
@@ -1247,6 +1246,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
|
@@ -1247,6 +1246,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
1247
|
transactionContext.RollbackTransaction()
|
1246
|
transactionContext.RollbackTransaction()
|
1248
|
}()
|
1247
|
}()
|
1249
|
|
1248
|
|
|
|
1249
|
+ // 兑换素币清单仓储初始化
|
1250
|
var exchangeCashPersonListRepository domain.ExchangeCashPersonListRepository
|
1250
|
var exchangeCashPersonListRepository domain.ExchangeCashPersonListRepository
|
1251
|
if value, err := factory.CreateExchangeCashPersonListRepository(map[string]interface{}{
|
1251
|
if value, err := factory.CreateExchangeCashPersonListRepository(map[string]interface{}{
|
1252
|
"transactionContext": transactionContext,
|
1252
|
"transactionContext": transactionContext,
|
|
@@ -1256,15 +1256,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
|
@@ -1256,15 +1256,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
1256
|
exchangeCashPersonListRepository = value
|
1256
|
exchangeCashPersonListRepository = value
|
1257
|
}
|
1257
|
}
|
1258
|
|
1258
|
|
1259
|
- // 获取兑换清单
|
|
|
1260
|
- person, err := exchangeCashPersonListRepository.FindOne(map[string]interface{}{"listId": updateExchangeCashPersonCommand.ListId})
|
|
|
1261
|
- if err != nil {
|
|
|
1262
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
1263
|
- }
|
|
|
1264
|
- if person == nil {
|
|
|
1265
|
- return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateExchangeCashPersonCommand.ListId)))
|
|
|
1266
|
- }
|
|
|
1267
|
-
|
1259
|
+ // 兑换现金活动仓储初始化
|
1268
|
var exchangeCashActivityRepository domain.ExchangeActivityRepository
|
1260
|
var exchangeCashActivityRepository domain.ExchangeActivityRepository
|
1269
|
if value, err := factory.CreateExchangeCashActivityRepository(map[string]interface{}{
|
1261
|
if value, err := factory.CreateExchangeCashActivityRepository(map[string]interface{}{
|
1270
|
"transactionContext": transactionContext,
|
1262
|
"transactionContext": transactionContext,
|
|
@@ -1274,36 +1266,48 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
|
@@ -1274,36 +1266,48 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
1274
|
exchangeCashActivityRepository = value
|
1266
|
exchangeCashActivityRepository = value
|
1275
|
}
|
1267
|
}
|
1276
|
|
1268
|
|
1277
|
- // 获取相关兑换活动
|
|
|
1278
|
- activityFound, err := exchangeCashActivityRepository.FindOne(map[string]interface{}{"activityId": person.ExchangeCashActivityId})
|
1269
|
+ // 获取兑换清单
|
|
|
1270
|
+ personFound, err := exchangeCashPersonListRepository.FindOne(map[string]interface{}{"listId": updateExchangeCashPersonCommand.ListId})
|
1279
|
if err != nil {
|
1271
|
if err != nil {
|
1280
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
1272
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
1281
|
}
|
1273
|
}
|
1282
|
- if activityFound == nil {
|
|
|
1283
|
- return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(person.ExchangeCashActivityId)))
|
1274
|
+ if personFound == nil {
|
|
|
1275
|
+ return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateExchangeCashPersonCommand.ListId)))
|
1284
|
}
|
1276
|
}
|
1285
|
|
1277
|
|
1286
|
- updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{
|
|
|
1287
|
- ExchangeCashActivityId: person.ExchangeCashActivityId,
|
|
|
1288
|
- ExchangedSuMoney: activityFound.ExchangedSuMoney + (updateExchangeCashPersonCommand.ExchangedSuMoney - person.ExchangedSuMoney),
|
|
|
1289
|
- ExchangedCash: activityFound.ExchangedCash + (updateExchangeCashPersonCommand.ExchangedSuMoney - person.ExchangedSuMoney) * activityFound.Rate,
|
|
|
1290
|
- Deadline: activityFound.Deadline,
|
|
|
1291
|
- CountDown: activityFound.CountDown,
|
|
|
1292
|
- ExchangeRate: activityFound.Rate,
|
1278
|
+ // 获取相关兑换活动
|
|
|
1279
|
+ activityFound, err := exchangeCashActivityRepository.FindOne(map[string]interface{}{"activityId": personFound.ExchangeCashActivityId})
|
|
|
1280
|
+ if err != nil {
|
|
|
1281
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
1282
|
+ }
|
|
|
1283
|
+ if activityFound == nil {
|
|
|
1284
|
+ return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(personFound.ExchangeCashActivityId)))
|
1293
|
}
|
1285
|
}
|
1294
|
|
1286
|
|
1295
|
// 更新兑换清单,个人已兑换现金计算
|
1287
|
// 更新兑换清单,个人已兑换现金计算
|
1296
|
updateExchangeCashPersonCommand.ExchangedCash = updateExchangeCashPersonCommand.ExchangedSuMoney * activityFound.Rate
|
1288
|
updateExchangeCashPersonCommand.ExchangedCash = updateExchangeCashPersonCommand.ExchangedSuMoney * activityFound.Rate
|
1297
|
|
1289
|
|
1298
|
- if err := person.Update(tool_funs.SimpleStructToMap(updateExchangeCashPersonCommand)); err != nil {
|
1290
|
+ // 更新兑换素币清单
|
|
|
1291
|
+ if err := personFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashPersonCommand)); err != nil {
|
1299
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
1292
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
1300
|
}
|
1293
|
}
|
1301
|
|
1294
|
|
1302
|
- personUpdated, err := exchangeCashPersonListRepository.Save(person)
|
1295
|
+ // 保存兑换清单更新
|
|
|
1296
|
+ personUpdated, err := exchangeCashPersonListRepository.Save(personFound)
|
1303
|
if err != nil {
|
1297
|
if err != nil {
|
1304
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
1298
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
1305
|
}
|
1299
|
}
|
1306
|
|
1300
|
|
|
|
1301
|
+ // 更新素币兑换活动命令
|
|
|
1302
|
+ updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{
|
|
|
1303
|
+ ExchangeCashActivityId: personFound.ExchangeCashActivityId,
|
|
|
1304
|
+ ExchangedSuMoney: activityFound.ExchangedSuMoney + (updateExchangeCashPersonCommand.ExchangedSuMoney - personFound.ExchangedSuMoney),
|
|
|
1305
|
+ ExchangedCash: activityFound.ExchangedCash + (updateExchangeCashPersonCommand.ExchangedSuMoney - personFound.ExchangedSuMoney) * activityFound.Rate,
|
|
|
1306
|
+ Deadline: activityFound.Deadline,
|
|
|
1307
|
+ CountDown: activityFound.CountDown,
|
|
|
1308
|
+ ExchangeRate: activityFound.Rate,
|
|
|
1309
|
+ }
|
|
|
1310
|
+
|
1307
|
// 更新员工素币,生成素币兑换流水记录
|
1311
|
// 更新员工素币,生成素币兑换流水记录
|
1308
|
var operationSuMoneyService service.OperationSuMoneyService
|
1312
|
var operationSuMoneyService service.OperationSuMoneyService
|
1309
|
if value, err := factory.CreateOperationSuMoneyService(map[string]interface{}{
|
1313
|
if value, err := factory.CreateOperationSuMoneyService(map[string]interface{}{
|
|
@@ -1315,7 +1319,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
|
@@ -1315,7 +1319,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
1315
|
}
|
1319
|
}
|
1316
|
|
1320
|
|
1317
|
operationSuMoneyCommand := &command.OperationSuMoneyCommand{
|
1321
|
operationSuMoneyCommand := &command.OperationSuMoneyCommand{
|
1318
|
- Uid: person.EmployeeInfo.Uid,
|
1322
|
+ Uid: personFound.EmployeeInfo.Uid,
|
1319
|
Operator: updateExchangeCashPersonCommand.Operator,
|
1323
|
Operator: updateExchangeCashPersonCommand.Operator,
|
1320
|
SuMoney: 0,
|
1324
|
SuMoney: 0,
|
1321
|
OperationType: 0,
|
1325
|
OperationType: 0,
|
|
@@ -1448,10 +1452,10 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
|
@@ -1448,10 +1452,10 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
1448
|
|
1452
|
|
1449
|
updateCashPoolCommand := &command.UpdateCashPoolCommand{
|
1453
|
updateCashPoolCommand := &command.UpdateCashPoolCommand{
|
1450
|
CashPoolId: cashPools[0].CashPoolId,
|
1454
|
CashPoolId: cashPools[0].CashPoolId,
|
1451
|
- ExchangedCash: cashPools[0].ExchangedCash + (updateExchangeCashPersonCommand.ExchangedSuMoney - person.ExchangedSuMoney) * activityFound.Rate,
|
|
|
1452
|
- UnExchangeCash: cashPools[0].UnExchangeCash - (updateExchangeCashPersonCommand.ExchangedSuMoney - person.ExchangedSuMoney) * activityFound.Rate,
|
1455
|
+ ExchangedCash: cashPools[0].ExchangedCash + (updateExchangeCashPersonCommand.ExchangedSuMoney - personFound.ExchangedSuMoney) * activityFound.Rate,
|
|
|
1456
|
+ UnExchangeCash: cashPools[0].UnExchangeCash - (updateExchangeCashPersonCommand.ExchangedSuMoney - personFound.ExchangedSuMoney) * activityFound.Rate,
|
1453
|
Rate: newRate,
|
1457
|
Rate: newRate,
|
1454
|
- ExchangedSuMoney: cashPools[0].ExchangedSuMoney + (updateExchangeCashPersonCommand.ExchangedSuMoney - person.ExchangedSuMoney),
|
1458
|
+ ExchangedSuMoney: cashPools[0].ExchangedSuMoney + (updateExchangeCashPersonCommand.ExchangedSuMoney - personFound.ExchangedSuMoney),
|
1455
|
UnExchangeSuMoney: systemUnExchangeSuMoney,
|
1459
|
UnExchangeSuMoney: systemUnExchangeSuMoney,
|
1456
|
}
|
1460
|
}
|
1457
|
|
1461
|
|