diff --git a/common/dao/approval_vacation.go b/common/dao/approval_vacation.go index 1a88165..910b4e6 100644 --- a/common/dao/approval_vacation.go +++ b/common/dao/approval_vacation.go @@ -81,3 +81,21 @@ func (d *ApprovalVacationDao) GetByUsername(username, month, day string) ([]*mod } return u, nil } + +func (d *ApprovalVacationDao) GetByUsernameDay(username, day string) (*model.ApprovalVacation, error) { + var u model.ApprovalVacation + tx := GetDB().Table(d.TableName()) + tx = tx.Where("vacation_date = ?", day) + tx = tx.Where("username = ?", username) + + res := tx.First(&u) + if res.Error == gorm.ErrRecordNotFound { + return nil, nil + } + + if res.Error != nil { + return nil, res.Error + } + + return &u, nil +} diff --git a/worker/staff.go b/worker/staff.go index d3a1293..4be9098 100644 --- a/worker/staff.go +++ b/worker/staff.go @@ -314,6 +314,8 @@ func (s *Staff) getRealWorkDay(entryDate, username, month string) float64 { realWorkdays += 1 continue } + + //有补卡申请就直接算出勤 approvalCheckin, _ := dao.NewApprovalCheckinDao().GetByUsernameDay(username, checkin.Day) if approvalCheckin != nil { realWorkdays += 1 @@ -321,6 +323,12 @@ func (s *Staff) getRealWorkDay(entryDate, username, month string) float64 { continue } + //有请假申请的不算出勤 + approvalVacation, _ := dao.NewApprovalVacationDao().GetByUsernameDay(username, checkin.Day) + if approvalVacation != nil { + continue + } + //入职当天考勤异常忽略 if checkin.Day == entryDate { realWorkdays += 1