作者 陈志颖

fix:活动倒计时向上取整

@@ -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{
@@ -444,12 +444,13 @@ func (controller *SuMoneyController) ImportExchangeList () { @@ -444,12 +444,13 @@ func (controller *SuMoneyController) ImportExchangeList () {
444 for _, _ = range row { 444 for _, _ = range row {
445 r2, _ := strconv.ParseFloat(row[2], 64) 445 r2, _ := strconv.ParseFloat(row[2], 64)
446 if row[0] == "" || row[1] == "" || r2 == 0 { 446 if row[0] == "" || row[1] == "" || r2 == 0 {
447 - row = append(row, "单元格包含空字符")  
448 - nullLine = append(nullLine, row) 447 + //row = append(row, "单元格包含空字符")
  448 + //nullLine = append(nullLine, row)
449 } 449 }
450 } 450 }
451 } 451 }
452 } 452 }
  453 +
453 if len(nullLine) > 0 { 454 if len(nullLine) > 0 {
454 ret = map[string]interface{}{ 455 ret = map[string]interface{}{
455 "successCount": 0, 456 "successCount": 0,
@@ -482,8 +483,8 @@ func (controller *SuMoneyController) ImportExchangeList () { @@ -482,8 +483,8 @@ func (controller *SuMoneyController) ImportExchangeList () {
482 // 创建兑换素币清单 483 // 创建兑换素币清单
483 _, err := cashPoolService.ImportCreateExchangeCashPerson(createExchangeCashPersonCommand) 484 _, err := cashPoolService.ImportCreateExchangeCashPerson(createExchangeCashPersonCommand)
484 if err != nil { // 导入失败处理 485 if err != nil { // 导入失败处理
485 - rows[i] = append(rows[i], err.Error())  
486 - failureDataList = append(failureDataList, rows[i]) // 导入失败的记录 486 + //rows[i] = append(rows[i], err.Error())
  487 + //failureDataList = append(failureDataList, rows[i]) // 导入失败的记录
487 } else { // 导入成功处理 488 } else { // 导入成功处理
488 successDataCount += 1 489 successDataCount += 1
489 } 490 }