作者 陈志颖

fix:活动倒计时向上取整

... ... @@ -296,6 +296,8 @@ func (cashPoolService *CashPoolService) CreateExchangeCashActivity(createExchang
var deadline = createExchangeCashActivityCommand.Deadline.Add(dd)
var t1 = time.Now()
var t2 = time.Date(deadline.Year(), deadline.Month(), deadline.Day(), 23, 59, 59, 0, time.UTC)
//countDown := math.Ceil(t2.Sub(t1).Hours() / 24)
//fmt.Print(math.Ceil(t2.Sub(t1).Hours() / 24), "\n")
// 创建兑换活动命令
newActivity := &domain.ExchangeCashActivity{
... ... @@ -304,7 +306,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashActivity(createExchang
ExchangedCash: 0,
ExchangedSuMoney: 0,
Deadline: t2,
CountDown: int64(t2.Sub(t1).Hours() / 24), // 计算活动截止倒计时
CountDown: int64(math.Ceil(t2.Sub(t1).Hours() / 24)), // 计算活动截止倒计时
Rate: createExchangeCashActivityCommand.ExchangeRate,
CreateTime: time.Now(),
}
... ... @@ -413,7 +415,7 @@ func (cashPoolService *CashPoolService) SearchExchangeCashActivity(activityComma
// 更新兑换活动倒计时命令
updateExchangeCashActivity := &command.UpdateExchangeCashActivityCommand {
ExchangeCashActivityId: activity.ActivityId,
CountDown: int64(t2.Sub(t1).Hours() / 24), // 计算倒计时
CountDown: int64(math.Ceil(t2.Sub(t1).Hours() / 24)), // 计算倒计时
Deadline: activity.Deadline,
ExchangedSuMoney: activity.ExchangedSuMoney,
ExchangedCash: activity.ExchangedCash,
... ... @@ -423,7 +425,6 @@ func (cashPoolService *CashPoolService) SearchExchangeCashActivity(activityComma
// 倒计时结束处理
if t2.Before(t1) {
updateExchangeCashActivity.CountDown = 0
updateExchangeCashActivity.Deadline = activity.Deadline
}
// 更新兑换现金活动倒计时
... ... @@ -502,7 +503,7 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas
// 更新兑换现金活动倒计时命令
updateExchangeCashActivity := &command.UpdateExchangeCashActivityCommand {
ExchangeCashActivityId: activity.ActivityId,
CountDown: int64(t2.Sub(t1).Hours() / 24), // 重新计算活动倒计时
CountDown: int64(math.Ceil(t2.Sub(t1).Hours() / 24)), // 重新计算活动倒计时
Deadline: activity.Deadline,
ExchangedSuMoney: activity.ExchangedSuMoney,
ExchangedCash: activity.ExchangedCash,
... ... @@ -644,7 +645,7 @@ func (cashPoolService *CashPoolService) GetExchangeCashActivity(getExchangeCashA
// 更新兑换现金活动倒计时命令
updateExchangeCashActivity := &command.UpdateExchangeCashActivityCommand {
ExchangeCashActivityId: activityFound.ActivityId,
CountDown: int64(t2.Sub(t1).Hours() / 24),
CountDown: int64(math.Ceil(t2.Sub(t1).Hours() / 24)),
Deadline: activityFound.Deadline,
ExchangedSuMoney: activityFound.ExchangedSuMoney,
ExchangedCash: activityFound.ExchangedCash,
... ... @@ -1090,7 +1091,6 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC
return personUpdated, nil
}
// 新增导入兑换素币清单
func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExchangeCashPersonCommand *command.CreateExchangeCashPersonCommand) (interface{}, error) {
if err := createExchangeCashPersonCommand.ValidateCommand(); err != nil {
... ... @@ -1194,7 +1194,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
}
// 判断当前员工是否已经在素币兑换清单中
count, peopleFound, err := exchangeCashPersonListRepository.Find(map[string]interface{}{
_, peopleFound, err := exchangeCashPersonListRepository.Find(map[string]interface{}{
"employeeAccount": employeeFound.EmployeeInfo.EmployeeAccount,
"exchangeCashActivityId": activityFound.ActivityId,
"offset": 0,
... ... @@ -1203,11 +1203,14 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if count > 0 { // 追加素币兑换或撤回素币兑换
fmt.Printf("员工:%+v\n", peopleFound[0])
if len(peopleFound) > 0 { // 追加素币兑换或撤回素币兑换
// 获取兑换清单员工已兑换素币
personFoundExchangedSuMoney := peopleFound[0].ExchangedSuMoney
if createExchangeCashPersonCommand.ExchangedSuMoney < peopleFound[0].ExchangedSuMoney { // 当前兑换的素币小于已兑换素币,撤回兑换素币
if createExchangeCashPersonCommand.ExchangedSuMoney < personFoundExchangedSuMoney { // 当前兑换的素币小于已兑换素币,撤回兑换素币
// 减量
suMoneyDecrement := peopleFound[0].ExchangedSuMoney - createExchangeCashPersonCommand.ExchangedSuMoney
... ... @@ -1337,7 +1340,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
}
return personUpdated, nil
} else if createExchangeCashPersonCommand.ExchangedSuMoney > peopleFound[0].ExchangedSuMoney { // 当前兑换素币大于已兑换素币,追加兑换素币
} else if createExchangeCashPersonCommand.ExchangedSuMoney > personFoundExchangedSuMoney { // 当前兑换素币大于已兑换素币,追加兑换素币
// 增量
suMoneyIncrement := createExchangeCashPersonCommand.ExchangedSuMoney - peopleFound[0].ExchangedSuMoney
... ... @@ -1468,7 +1471,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
return personUpdated, nil
}
} else if count == 0 { // 新增
} else if len(peopleFound) == 0 { // 新增
// 新增兑换素币清单命令
newPersonExchangedCash, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", createExchangeCashPersonCommand.ExchangedSuMoney * activityFound.Rate), 64)
newPerson := &domain.ExchangeCashPersonList{
... ...
... ... @@ -444,12 +444,13 @@ func (controller *SuMoneyController) ImportExchangeList () {
for _, _ = range row {
r2, _ := strconv.ParseFloat(row[2], 64)
if row[0] == "" || row[1] == "" || r2 == 0 {
row = append(row, "单元格包含空字符")
nullLine = append(nullLine, row)
//row = append(row, "单元格包含空字符")
//nullLine = append(nullLine, row)
}
}
}
}
if len(nullLine) > 0 {
ret = map[string]interface{}{
"successCount": 0,
... ... @@ -482,8 +483,8 @@ func (controller *SuMoneyController) ImportExchangeList () {
// 创建兑换素币清单
_, err := cashPoolService.ImportCreateExchangeCashPerson(createExchangeCashPersonCommand)
if err != nil { // 导入失败处理
rows[i] = append(rows[i], err.Error())
failureDataList = append(failureDataList, rows[i]) // 导入失败的记录
//rows[i] = append(rows[i], err.Error())
//failureDataList = append(failureDataList, rows[i]) // 导入失败的记录
} else { // 导入成功处理
successDataCount += 1
}
... ...