|
@@ -296,6 +296,8 @@ func (cashPoolService *CashPoolService) CreateExchangeCashActivity(createExchang |
|
@@ -296,6 +296,8 @@ func (cashPoolService *CashPoolService) CreateExchangeCashActivity(createExchang |
296
|
var deadline = createExchangeCashActivityCommand.Deadline.Add(dd)
|
296
|
var deadline = createExchangeCashActivityCommand.Deadline.Add(dd)
|
297
|
var t1 = time.Now()
|
297
|
var t1 = time.Now()
|
298
|
var t2 = time.Date(deadline.Year(), deadline.Month(), deadline.Day(), 23, 59, 59, 0, time.UTC)
|
298
|
var t2 = time.Date(deadline.Year(), deadline.Month(), deadline.Day(), 23, 59, 59, 0, time.UTC)
|
|
|
299
|
+ //countDown := math.Ceil(t2.Sub(t1).Hours() / 24)
|
|
|
300
|
+ //fmt.Print(math.Ceil(t2.Sub(t1).Hours() / 24), "\n")
|
299
|
|
301
|
|
300
|
// 创建兑换活动命令
|
302
|
// 创建兑换活动命令
|
301
|
newActivity := &domain.ExchangeCashActivity{
|
303
|
newActivity := &domain.ExchangeCashActivity{
|
|
@@ -304,7 +306,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashActivity(createExchang |
|
@@ -304,7 +306,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashActivity(createExchang |
304
|
ExchangedCash: 0,
|
306
|
ExchangedCash: 0,
|
305
|
ExchangedSuMoney: 0,
|
307
|
ExchangedSuMoney: 0,
|
306
|
Deadline: t2,
|
308
|
Deadline: t2,
|
307
|
- CountDown: int64(t2.Sub(t1).Hours() / 24), // 计算活动截止倒计时
|
309
|
+ CountDown: int64(math.Ceil(t2.Sub(t1).Hours() / 24)), // 计算活动截止倒计时
|
308
|
Rate: createExchangeCashActivityCommand.ExchangeRate,
|
310
|
Rate: createExchangeCashActivityCommand.ExchangeRate,
|
309
|
CreateTime: time.Now(),
|
311
|
CreateTime: time.Now(),
|
310
|
}
|
312
|
}
|
|
@@ -413,7 +415,7 @@ func (cashPoolService *CashPoolService) SearchExchangeCashActivity(activityComma |
|
@@ -413,7 +415,7 @@ func (cashPoolService *CashPoolService) SearchExchangeCashActivity(activityComma |
413
|
// 更新兑换活动倒计时命令
|
415
|
// 更新兑换活动倒计时命令
|
414
|
updateExchangeCashActivity := &command.UpdateExchangeCashActivityCommand {
|
416
|
updateExchangeCashActivity := &command.UpdateExchangeCashActivityCommand {
|
415
|
ExchangeCashActivityId: activity.ActivityId,
|
417
|
ExchangeCashActivityId: activity.ActivityId,
|
416
|
- CountDown: int64(t2.Sub(t1).Hours() / 24), // 计算倒计时
|
418
|
+ CountDown: int64(math.Ceil(t2.Sub(t1).Hours() / 24)), // 计算倒计时
|
417
|
Deadline: activity.Deadline,
|
419
|
Deadline: activity.Deadline,
|
418
|
ExchangedSuMoney: activity.ExchangedSuMoney,
|
420
|
ExchangedSuMoney: activity.ExchangedSuMoney,
|
419
|
ExchangedCash: activity.ExchangedCash,
|
421
|
ExchangedCash: activity.ExchangedCash,
|
|
@@ -423,7 +425,6 @@ func (cashPoolService *CashPoolService) SearchExchangeCashActivity(activityComma |
|
@@ -423,7 +425,6 @@ func (cashPoolService *CashPoolService) SearchExchangeCashActivity(activityComma |
423
|
// 倒计时结束处理
|
425
|
// 倒计时结束处理
|
424
|
if t2.Before(t1) {
|
426
|
if t2.Before(t1) {
|
425
|
updateExchangeCashActivity.CountDown = 0
|
427
|
updateExchangeCashActivity.CountDown = 0
|
426
|
- updateExchangeCashActivity.Deadline = activity.Deadline
|
|
|
427
|
}
|
428
|
}
|
428
|
|
429
|
|
429
|
// 更新兑换现金活动倒计时
|
430
|
// 更新兑换现金活动倒计时
|
|
@@ -502,7 +503,7 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas |
|
@@ -502,7 +503,7 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas |
502
|
// 更新兑换现金活动倒计时命令
|
503
|
// 更新兑换现金活动倒计时命令
|
503
|
updateExchangeCashActivity := &command.UpdateExchangeCashActivityCommand {
|
504
|
updateExchangeCashActivity := &command.UpdateExchangeCashActivityCommand {
|
504
|
ExchangeCashActivityId: activity.ActivityId,
|
505
|
ExchangeCashActivityId: activity.ActivityId,
|
505
|
- CountDown: int64(t2.Sub(t1).Hours() / 24), // 重新计算活动倒计时
|
506
|
+ CountDown: int64(math.Ceil(t2.Sub(t1).Hours() / 24)), // 重新计算活动倒计时
|
506
|
Deadline: activity.Deadline,
|
507
|
Deadline: activity.Deadline,
|
507
|
ExchangedSuMoney: activity.ExchangedSuMoney,
|
508
|
ExchangedSuMoney: activity.ExchangedSuMoney,
|
508
|
ExchangedCash: activity.ExchangedCash,
|
509
|
ExchangedCash: activity.ExchangedCash,
|
|
@@ -644,7 +645,7 @@ func (cashPoolService *CashPoolService) GetExchangeCashActivity(getExchangeCashA |
|
@@ -644,7 +645,7 @@ func (cashPoolService *CashPoolService) GetExchangeCashActivity(getExchangeCashA |
644
|
// 更新兑换现金活动倒计时命令
|
645
|
// 更新兑换现金活动倒计时命令
|
645
|
updateExchangeCashActivity := &command.UpdateExchangeCashActivityCommand {
|
646
|
updateExchangeCashActivity := &command.UpdateExchangeCashActivityCommand {
|
646
|
ExchangeCashActivityId: activityFound.ActivityId,
|
647
|
ExchangeCashActivityId: activityFound.ActivityId,
|
647
|
- CountDown: int64(t2.Sub(t1).Hours() / 24),
|
648
|
+ CountDown: int64(math.Ceil(t2.Sub(t1).Hours() / 24)),
|
648
|
Deadline: activityFound.Deadline,
|
649
|
Deadline: activityFound.Deadline,
|
649
|
ExchangedSuMoney: activityFound.ExchangedSuMoney,
|
650
|
ExchangedSuMoney: activityFound.ExchangedSuMoney,
|
650
|
ExchangedCash: activityFound.ExchangedCash,
|
651
|
ExchangedCash: activityFound.ExchangedCash,
|
|
@@ -1090,7 +1091,6 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
|
@@ -1090,7 +1091,6 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
1090
|
return personUpdated, nil
|
1091
|
return personUpdated, nil
|
1091
|
}
|
1092
|
}
|
1092
|
|
1093
|
|
1093
|
-
|
|
|
1094
|
// 新增导入兑换素币清单
|
1094
|
// 新增导入兑换素币清单
|
1095
|
func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExchangeCashPersonCommand *command.CreateExchangeCashPersonCommand) (interface{}, error) {
|
1095
|
func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExchangeCashPersonCommand *command.CreateExchangeCashPersonCommand) (interface{}, error) {
|
1096
|
if err := createExchangeCashPersonCommand.ValidateCommand(); err != nil {
|
1096
|
if err := createExchangeCashPersonCommand.ValidateCommand(); err != nil {
|
|
@@ -1194,7 +1194,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
|
@@ -1194,7 +1194,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
1194
|
}
|
1194
|
}
|
1195
|
|
1195
|
|
1196
|
// 判断当前员工是否已经在素币兑换清单中
|
1196
|
// 判断当前员工是否已经在素币兑换清单中
|
1197
|
- count, peopleFound, err := exchangeCashPersonListRepository.Find(map[string]interface{}{
|
1197
|
+ _, peopleFound, err := exchangeCashPersonListRepository.Find(map[string]interface{}{
|
1198
|
"employeeAccount": employeeFound.EmployeeInfo.EmployeeAccount,
|
1198
|
"employeeAccount": employeeFound.EmployeeInfo.EmployeeAccount,
|
1199
|
"exchangeCashActivityId": activityFound.ActivityId,
|
1199
|
"exchangeCashActivityId": activityFound.ActivityId,
|
1200
|
"offset": 0,
|
1200
|
"offset": 0,
|
|
@@ -1203,11 +1203,14 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
|
@@ -1203,11 +1203,14 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
1203
|
if err != nil {
|
1203
|
if err != nil {
|
1204
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
1204
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
1205
|
}
|
1205
|
}
|
1206
|
- if count > 0 { // 追加素币兑换或撤回素币兑换
|
1206
|
+
|
|
|
1207
|
+ fmt.Printf("员工:%+v\n", peopleFound[0])
|
|
|
1208
|
+
|
|
|
1209
|
+ if len(peopleFound) > 0 { // 追加素币兑换或撤回素币兑换
|
1207
|
// 获取兑换清单员工已兑换素币
|
1210
|
// 获取兑换清单员工已兑换素币
|
1208
|
personFoundExchangedSuMoney := peopleFound[0].ExchangedSuMoney
|
1211
|
personFoundExchangedSuMoney := peopleFound[0].ExchangedSuMoney
|
1209
|
|
1212
|
|
1210
|
- if createExchangeCashPersonCommand.ExchangedSuMoney < peopleFound[0].ExchangedSuMoney { // 当前兑换的素币小于已兑换素币,撤回兑换素币
|
1213
|
+ if createExchangeCashPersonCommand.ExchangedSuMoney < personFoundExchangedSuMoney { // 当前兑换的素币小于已兑换素币,撤回兑换素币
|
1211
|
// 减量
|
1214
|
// 减量
|
1212
|
suMoneyDecrement := peopleFound[0].ExchangedSuMoney - createExchangeCashPersonCommand.ExchangedSuMoney
|
1215
|
suMoneyDecrement := peopleFound[0].ExchangedSuMoney - createExchangeCashPersonCommand.ExchangedSuMoney
|
1213
|
|
1216
|
|
|
@@ -1337,7 +1340,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
|
@@ -1337,7 +1340,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
1337
|
}
|
1340
|
}
|
1338
|
|
1341
|
|
1339
|
return personUpdated, nil
|
1342
|
return personUpdated, nil
|
1340
|
- } else if createExchangeCashPersonCommand.ExchangedSuMoney > peopleFound[0].ExchangedSuMoney { // 当前兑换素币大于已兑换素币,追加兑换素币
|
1343
|
+ } else if createExchangeCashPersonCommand.ExchangedSuMoney > personFoundExchangedSuMoney { // 当前兑换素币大于已兑换素币,追加兑换素币
|
1341
|
// 增量
|
1344
|
// 增量
|
1342
|
suMoneyIncrement := createExchangeCashPersonCommand.ExchangedSuMoney - peopleFound[0].ExchangedSuMoney
|
1345
|
suMoneyIncrement := createExchangeCashPersonCommand.ExchangedSuMoney - peopleFound[0].ExchangedSuMoney
|
1343
|
|
1346
|
|
|
@@ -1468,7 +1471,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
|
@@ -1468,7 +1471,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
1468
|
|
1471
|
|
1469
|
return personUpdated, nil
|
1472
|
return personUpdated, nil
|
1470
|
}
|
1473
|
}
|
1471
|
- } else if count == 0 { // 新增
|
1474
|
+ } else if len(peopleFound) == 0 { // 新增
|
1472
|
// 新增兑换素币清单命令
|
1475
|
// 新增兑换素币清单命令
|
1473
|
newPersonExchangedCash, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", createExchangeCashPersonCommand.ExchangedSuMoney * activityFound.Rate), 64)
|
1476
|
newPersonExchangedCash, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", createExchangeCashPersonCommand.ExchangedSuMoney * activityFound.Rate), 64)
|
1474
|
newPerson := &domain.ExchangeCashPersonList{
|
1477
|
newPerson := &domain.ExchangeCashPersonList{
|