...
|
...
|
@@ -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{
|
...
|
...
|
|