|
@@ -91,6 +91,8 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co |
|
@@ -91,6 +91,8 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co |
91
|
if err != nil {
|
91
|
if err != nil {
|
92
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
92
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
93
|
}
|
93
|
}
|
|
|
94
|
+
|
|
|
95
|
+ // 不存在现金池
|
94
|
if count == 0 { // 新增现金池
|
96
|
if count == 0 { // 新增现金池
|
95
|
newCashPool := &domain.CashPool{
|
97
|
newCashPool := &domain.CashPool{
|
96
|
CompanyId: createCashPoolCommand.CompanyId,
|
98
|
CompanyId: createCashPoolCommand.CompanyId,
|
|
@@ -120,7 +122,7 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co |
|
@@ -120,7 +122,7 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co |
120
|
CompanyId: createCashPoolCommand.CompanyId,
|
122
|
CompanyId: createCashPoolCommand.CompanyId,
|
121
|
Cash: createCashPoolCommand.Cash,
|
123
|
Cash: createCashPoolCommand.Cash,
|
122
|
ExchangedCash: cashPools[0].ExchangedCash,
|
124
|
ExchangedCash: cashPools[0].ExchangedCash,
|
123
|
- UnExchangeCash: cashPools[0].UnExchangeCash + (createCashPoolCommand.Cash - (cashPools[0].ExchangedCash + cashPools[0].UnExchangeCash)),
|
125
|
+ UnExchangeCash: cashPools[0].UnExchangeCash + (createCashPoolCommand.Cash - cashPools[0].Cash),
|
124
|
ExchangedSuMoney: systemExchangedSuMoney,
|
126
|
ExchangedSuMoney: systemExchangedSuMoney,
|
125
|
UnExchangeSuMoney: systemUnExchangeSuMoney,
|
127
|
UnExchangeSuMoney: systemUnExchangeSuMoney,
|
126
|
Rate: cashPools[0].Rate,
|
128
|
Rate: cashPools[0].Rate,
|
|
@@ -285,10 +287,9 @@ func (cashPoolService *CashPoolService) CreateExchangeCashActivity(createExchang |
|
@@ -285,10 +287,9 @@ func (cashPoolService *CashPoolService) CreateExchangeCashActivity(createExchang |
285
|
}
|
287
|
}
|
286
|
|
288
|
|
287
|
// 时间格式化
|
289
|
// 时间格式化
|
288
|
- var timeNow = time.Now()
|
|
|
289
|
var deadline = createExchangeCashActivityCommand.Deadline
|
290
|
var deadline = createExchangeCashActivityCommand.Deadline
|
290
|
- var t1 = time.Date(timeNow.Year(), timeNow.Month(), timeNow.Day(), 0, 0, 0, 0, time.Local)
|
|
|
291
|
- var t2 = time.Date(deadline.Year(), deadline.Month(), deadline.Day(), 23, 59, 59, 999999, time.Local)
|
291
|
+ var t1 = time.Now()
|
|
|
292
|
+ var t2 = time.Date(deadline.Year(), deadline.Month(), deadline.Day(), 23, 59, 59, 0, time.Now().Location())
|
292
|
|
293
|
|
293
|
// 创建兑换活动命令
|
294
|
// 创建兑换活动命令
|
294
|
newActivity := &domain.ExchangeCashActivity{
|
295
|
newActivity := &domain.ExchangeCashActivity{
|
|
@@ -355,7 +356,7 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivityDeadline(listExc |
|
@@ -355,7 +356,7 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivityDeadline(listExc |
355
|
// 提取兑换现金活动截止时间
|
356
|
// 提取兑换现金活动截止时间
|
356
|
var deadlines []interface{}
|
357
|
var deadlines []interface{}
|
357
|
for _, activity := range activities {
|
358
|
for _, activity := range activities {
|
358
|
- deadlines = append(deadlines, activity.Deadline)
|
359
|
+ deadlines = append(deadlines, activity.Deadline.Format("2006-01-02"))
|
359
|
}
|
360
|
}
|
360
|
|
361
|
|
361
|
if len(deadlines) == 0 {
|
362
|
if len(deadlines) == 0 {
|
|
@@ -773,9 +774,11 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
|
@@ -773,9 +774,11 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
773
|
// 批量更新兑换清单,更新已兑换现金值
|
774
|
// 批量更新兑换清单,更新已兑换现金值
|
774
|
for _, personFound := range peopleFound {
|
775
|
for _, personFound := range peopleFound {
|
775
|
personFoundExchangedSuMoney := personFound.ExchangedSuMoney
|
776
|
personFoundExchangedSuMoney := personFound.ExchangedSuMoney
|
|
|
777
|
+
|
776
|
// 更新兑换清单命令
|
778
|
// 更新兑换清单命令
|
|
|
779
|
+ updateExchangeCashActivityExchangedCash, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", updateExchangeCashActivityCommand.ExchangeRate * personFoundExchangedSuMoney), 64)
|
777
|
updateExchangeCashPerson := &command.UpdateExchangeCashPersonCommand {
|
780
|
updateExchangeCashPerson := &command.UpdateExchangeCashPersonCommand {
|
778
|
- ExchangedCash: updateExchangeCashActivityCommand.ExchangeRate * personFoundExchangedSuMoney,
|
781
|
+ ExchangedCash: updateExchangeCashActivityExchangedCash,
|
779
|
ExchangedSuMoney: personFoundExchangedSuMoney,
|
782
|
ExchangedSuMoney: personFoundExchangedSuMoney,
|
780
|
}
|
783
|
}
|
781
|
|
784
|
|
|
@@ -813,7 +816,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
|
@@ -813,7 +816,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
813
|
systemUnExchangeCash := systemCashStatistics["systemUnExchangeCash"].(float64)
|
816
|
systemUnExchangeCash := systemCashStatistics["systemUnExchangeCash"].(float64)
|
814
|
|
817
|
|
815
|
// 更新兑换活动命令已兑换现金
|
818
|
// 更新兑换活动命令已兑换现金
|
816
|
- updateExchangeCashActivityCommand.ExchangedCash = updateExchangeCashActivityCommand.ExchangeRate * activityFound.ExchangedSuMoney
|
819
|
+ updateExchangeCashActivityCommand.ExchangedCash, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", updateExchangeCashActivityCommand.ExchangeRate * activityFound.ExchangedSuMoney), 64)
|
817
|
|
820
|
|
818
|
// 计算平均兑换汇率
|
821
|
// 计算平均兑换汇率
|
819
|
var rate float64
|
822
|
var rate float64
|
|
@@ -862,7 +865,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
|
@@ -862,7 +865,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
862
|
}
|
865
|
}
|
863
|
|
866
|
|
864
|
// 更新兑换活动命令已兑换素币
|
867
|
// 更新兑换活动命令已兑换素币
|
865
|
- updateExchangeCashActivityCommand.ExchangedSuMoney = activityFound.ExchangedSuMoney
|
868
|
+ updateExchangeCashActivityCommand.ExchangedSuMoney, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", activityFound.ExchangedSuMoney), 64)
|
866
|
|
869
|
|
867
|
// 更新兑换活动
|
870
|
// 更新兑换活动
|
868
|
if err := activityFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashActivityCommand)); err != nil {
|
871
|
if err := activityFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashActivityCommand)); err != nil {
|
|
@@ -1000,6 +1003,8 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC |
|
@@ -1000,6 +1003,8 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC |
1000
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "当前兑换素币超过本人持有的素币值")
|
1003
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "当前兑换素币超过本人持有的素币值")
|
1001
|
}
|
1004
|
}
|
1002
|
|
1005
|
|
|
|
1006
|
+ newPersonExchangedCash, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", createExchangeCashPersonCommand.ExchangedSuMoney * activityFound.Rate), 64)
|
|
|
1007
|
+
|
1003
|
// 新增兑换清单命令
|
1008
|
// 新增兑换清单命令
|
1004
|
newPerson := &domain.ExchangeCashPersonList{
|
1009
|
newPerson := &domain.ExchangeCashPersonList{
|
1005
|
EmployeeInfo: &domain.EmployeeInfo{
|
1010
|
EmployeeInfo: &domain.EmployeeInfo{
|
|
@@ -1009,7 +1014,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC |
|
@@ -1009,7 +1014,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC |
1009
|
},
|
1014
|
},
|
1010
|
ExchangeCashActivityId: createExchangeCashPersonCommand.ExchangeCashActivityId,
|
1015
|
ExchangeCashActivityId: createExchangeCashPersonCommand.ExchangeCashActivityId,
|
1011
|
ExchangedSuMoney: createExchangeCashPersonCommand.ExchangedSuMoney,
|
1016
|
ExchangedSuMoney: createExchangeCashPersonCommand.ExchangedSuMoney,
|
1012
|
- ExchangedCash: createExchangeCashPersonCommand.ExchangedSuMoney * activityFound.Rate,
|
1017
|
+ ExchangedCash: newPersonExchangedCash,
|
1013
|
}
|
1018
|
}
|
1014
|
|
1019
|
|
1015
|
// 保存兑换素币清单
|
1020
|
// 保存兑换素币清单
|
|
@@ -1036,12 +1041,14 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC |
|
@@ -1036,12 +1041,14 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC |
1036
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(operationSuMoneyCommand.Uid)))
|
1041
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(operationSuMoneyCommand.Uid)))
|
1037
|
}
|
1042
|
}
|
1038
|
|
1043
|
|
|
|
1044
|
+ updateExchangeCashActivityExchangedCash, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", activityFound.ExchangedCash + createExchangeCashPersonCommand.ExchangedSuMoney * activityFound.Rate), 64)
|
|
|
1045
|
+
|
1039
|
// 更新兑换活动命令
|
1046
|
// 更新兑换活动命令
|
1040
|
updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{
|
1047
|
updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{
|
1041
|
ExchangeCashActivityId: personSaved.ExchangeCashActivityId,
|
1048
|
ExchangeCashActivityId: personSaved.ExchangeCashActivityId,
|
1042
|
ExchangeActivityName: activityFound.ExchangeActivityName,
|
1049
|
ExchangeActivityName: activityFound.ExchangeActivityName,
|
1043
|
ExchangedSuMoney: activityFound.ExchangedSuMoney + createExchangeCashPersonCommand.ExchangedSuMoney,
|
1050
|
ExchangedSuMoney: activityFound.ExchangedSuMoney + createExchangeCashPersonCommand.ExchangedSuMoney,
|
1044
|
- ExchangedCash: activityFound.ExchangedCash + createExchangeCashPersonCommand.ExchangedSuMoney * activityFound.Rate,
|
1051
|
+ ExchangedCash: updateExchangeCashActivityExchangedCash,
|
1045
|
Deadline: activityFound.Deadline,
|
1052
|
Deadline: activityFound.Deadline,
|
1046
|
CountDown: activityFound.CountDown,
|
1053
|
CountDown: activityFound.CountDown,
|
1047
|
ExchangeRate: activityFound.Rate,
|
1054
|
ExchangeRate: activityFound.Rate,
|
|
@@ -1117,12 +1124,15 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC |
|
@@ -1117,12 +1124,15 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC |
1117
|
newRate, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", (cashPoolsFound[0].ExchangedCash + personSaved.ExchangedCash) / systemExchangedSuMoney), 64)
|
1124
|
newRate, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", (cashPoolsFound[0].ExchangedCash + personSaved.ExchangedCash) / systemExchangedSuMoney), 64)
|
1118
|
}
|
1125
|
}
|
1119
|
|
1126
|
|
|
|
1127
|
+ updateCashPoolExchangedCash, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", cashPoolsFound[0].ExchangedCash + personSaved.ExchangedCash), 64)
|
|
|
1128
|
+ updateCashPoolUnExchangeCash, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", cashPoolsFound[0].UnExchangeCash - personSaved.ExchangedCash), 64)
|
|
|
1129
|
+
|
1120
|
// 更新现金池命令
|
1130
|
// 更新现金池命令
|
1121
|
updateCashPoolCommand := &command.UpdateCashPoolCommand{
|
1131
|
updateCashPoolCommand := &command.UpdateCashPoolCommand{
|
1122
|
CashPoolId: cashPoolsFound[0].CashPoolId,
|
1132
|
CashPoolId: cashPoolsFound[0].CashPoolId,
|
1123
|
Cash: cashPoolsFound[0].Cash,
|
1133
|
Cash: cashPoolsFound[0].Cash,
|
1124
|
- ExchangedCash: cashPoolsFound[0].ExchangedCash + personSaved.ExchangedCash,
|
|
|
1125
|
- UnExchangeCash: cashPoolsFound[0].UnExchangeCash - personSaved.ExchangedCash,
|
1134
|
+ ExchangedCash: updateCashPoolExchangedCash,
|
|
|
1135
|
+ UnExchangeCash: updateCashPoolUnExchangeCash,
|
1126
|
ExchangedSuMoney: systemExchangedSuMoney,
|
1136
|
ExchangedSuMoney: systemExchangedSuMoney,
|
1127
|
UnExchangeSuMoney: systemUnExchangeSuMoney,
|
1137
|
UnExchangeSuMoney: systemUnExchangeSuMoney,
|
1128
|
Rate: newRate,
|
1138
|
Rate: newRate,
|
|
@@ -1370,7 +1380,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
|
@@ -1370,7 +1380,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
1370
|
}
|
1380
|
}
|
1371
|
|
1381
|
|
1372
|
// 更新兑换清单,个人已兑换现金计算
|
1382
|
// 更新兑换清单,个人已兑换现金计算
|
1373
|
- updateExchangeCashPersonCommand.ExchangedCash = updateExchangeCashPersonCommand.ExchangedSuMoney * activityFound.Rate
|
1383
|
+ updateExchangeCashPersonCommand.ExchangedCash, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", updateExchangeCashPersonCommand.ExchangedSuMoney * activityFound.Rate), 64)
|
1374
|
|
1384
|
|
1375
|
// 更新兑换素币清单
|
1385
|
// 更新兑换素币清单
|
1376
|
if err := personFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashPersonCommand)); err != nil {
|
1386
|
if err := personFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashPersonCommand)); err != nil {
|
|
@@ -1383,11 +1393,13 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
|
@@ -1383,11 +1393,13 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
1383
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
1393
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
1384
|
}
|
1394
|
}
|
1385
|
|
1395
|
|
|
|
1396
|
+ updateActivityExchangeCash ,_ := strconv.ParseFloat(fmt.Sprintf("%.2f", activityFound.ExchangedCash + (updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney) * activityFound.Rate), 64)
|
|
|
1397
|
+
|
1386
|
// 更新素币兑换活动命令
|
1398
|
// 更新素币兑换活动命令
|
1387
|
updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{
|
1399
|
updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{
|
1388
|
ExchangeCashActivityId: personFound.ExchangeCashActivityId,
|
1400
|
ExchangeCashActivityId: personFound.ExchangeCashActivityId,
|
1389
|
ExchangedSuMoney: activityFound.ExchangedSuMoney + (updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney),
|
1401
|
ExchangedSuMoney: activityFound.ExchangedSuMoney + (updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney),
|
1390
|
- ExchangedCash: activityFound.ExchangedCash + (updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney) * activityFound.Rate,
|
1402
|
+ ExchangedCash: updateActivityExchangeCash,
|
1391
|
Deadline: activityFound.Deadline,
|
1403
|
Deadline: activityFound.Deadline,
|
1392
|
CountDown: activityFound.CountDown,
|
1404
|
CountDown: activityFound.CountDown,
|
1393
|
ExchangeRate: activityFound.Rate,
|
1405
|
ExchangeRate: activityFound.Rate,
|
|
@@ -1482,7 +1494,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
|
@@ -1482,7 +1494,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
1482
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(activityFound.CompanyId)))
|
1494
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(activityFound.CompanyId)))
|
1483
|
}
|
1495
|
}
|
1484
|
|
1496
|
|
1485
|
- systemExchangedCash := cashPoolsFound[0].ExchangedCash + (updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney) * activityFound.Rate
|
1497
|
+ systemExchangedCash, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", cashPoolsFound[0].ExchangedCash + (updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney) * activityFound.Rate), 64)
|
1486
|
systemExchangedSuMoney := cashPoolsFound[0].ExchangedSuMoney + (updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney)
|
1498
|
systemExchangedSuMoney := cashPoolsFound[0].ExchangedSuMoney + (updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney)
|
1487
|
|
1499
|
|
1488
|
// 计算现金池平均兑换汇率
|
1500
|
// 计算现金池平均兑换汇率
|
|
@@ -1493,12 +1505,14 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
|
@@ -1493,12 +1505,14 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
1493
|
newRate, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", systemExchangedCash / systemExchangedSuMoney), 64)
|
1505
|
newRate, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", systemExchangedCash / systemExchangedSuMoney), 64)
|
1494
|
}
|
1506
|
}
|
1495
|
|
1507
|
|
|
|
1508
|
+ updateCashPoolUnExchangeCash, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", cashPoolsFound[0].UnExchangeCash - (updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney) * activityFound.Rate), 64)
|
|
|
1509
|
+
|
1496
|
// 更新现金池命令
|
1510
|
// 更新现金池命令
|
1497
|
updateCashPoolCommand := &command.UpdateCashPoolCommand{
|
1511
|
updateCashPoolCommand := &command.UpdateCashPoolCommand{
|
1498
|
CashPoolId: cashPoolsFound[0].CashPoolId,
|
1512
|
CashPoolId: cashPoolsFound[0].CashPoolId,
|
1499
|
Cash: cashPoolsFound[0].Cash,
|
1513
|
Cash: cashPoolsFound[0].Cash,
|
1500
|
ExchangedCash: systemExchangedCash,
|
1514
|
ExchangedCash: systemExchangedCash,
|
1501
|
- UnExchangeCash: cashPoolsFound[0].UnExchangeCash - (updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney) * activityFound.Rate,
|
1515
|
+ UnExchangeCash: updateCashPoolUnExchangeCash,
|
1502
|
Rate: newRate,
|
1516
|
Rate: newRate,
|
1503
|
ExchangedSuMoney: systemExchangedSuMoney,
|
1517
|
ExchangedSuMoney: systemExchangedSuMoney,
|
1504
|
UnExchangeSuMoney: systemUnExchangeSuMoney,
|
1518
|
UnExchangeSuMoney: systemUnExchangeSuMoney,
|