From f3a8931b1bd85da30fe4487cd2a5d61aa4a4ef13 Mon Sep 17 00:00:00 2001 From: jiangyong27 Date: Tue, 1 Apr 2025 19:01:38 +0800 Subject: [PATCH] checkin3 --- server/api/salary.go | 6 +++--- service/staff_salary.go | 10 ++++++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/server/api/salary.go b/server/api/salary.go index fb06092..47fd786 100644 --- a/server/api/salary.go +++ b/server/api/salary.go @@ -29,7 +29,7 @@ type Salary struct { UpdateTime string `json:"update_time,omitempty"` Extra string `json:"extra,omitempty"` Status string `json:"status,omitempty"` - Tags string `json:"tags,omitempty"` + AttendStatus string `json:"attend_status,omitempty"` } type CreateSalaryReq struct { @@ -80,9 +80,9 @@ func (s *Salary) From(m *model.StaffSalary) { s.Status = cast.ToString(m.Status) if s.AttendDay+s.HolidayDay != s.ShouldDay { - s.Tags = "出勤异常" + s.AttendStatus = "2" } else { - s.Tags = "出勤正常" + s.AttendStatus = "1" } } diff --git a/service/staff_salary.go b/service/staff_salary.go index 15a4165..7ac65a3 100644 --- a/service/staff_salary.go +++ b/service/staff_salary.go @@ -297,8 +297,14 @@ func (s *StaffSalary) getRealWorkDay(month string) float64 { //其他按工作时长结算 if checkin.IsCheckin() { - duration := (float64(checkin.EndTime-checkin.StartTime)/float64(3600) - 1.5) / cast.ToFloat64(corp.GetConfig().WorkerHouer) //减去午休的1.5小时 - realWorkdays += goutil.If(duration > 1, 1, duration) + shouldAttendHour := cast.ToFloat64(corp.GetConfig().WorkerHouer) + lackSecond := int64(float64(3600)*(1.5+shouldAttendHour)) - (checkin.EndTime - checkin.StartTime) //加上午休的1.5小时 + if lackSecond > 0 { + lackHour := float64(lackSecond/3600 + 1) //按小时取整 + realWorkdays += goutil.If(lackHour > shouldAttendHour, 0, 1-lackHour/shouldAttendHour) + } else { + realWorkdays += 1 + } } } return realWorkdays