diff --git a/worker/staff.go b/worker/staff.go index b260c6b..2b4a4d4 100644 --- a/worker/staff.go +++ b/worker/staff.go @@ -122,6 +122,19 @@ func (s *Staff) SyncStaffSalary(month string) { return } for _, staff := range staffs { + + entryTime, _ := time.ParseInLocation("2006-01-02", staff.EntryDate, time.Local) + officalTime, _ := time.ParseInLocation("2006-01-02", staff.OfficialDate, time.Local) + leaveTime, _ := time.ParseInLocation("2006-01-02", staff.LeaveDate, time.Local) + isEntryMonth := goutil.If(cast.ToInt(entryTime.Format("200601")) == cast.ToInt(month), true, false) + isOfficialMonth := goutil.If(cast.ToInt(officalTime.Format("200601")) == cast.ToInt(month), true, false) + isLeaveMonth := goutil.If(cast.ToInt(leaveTime.Format("200601")) == cast.ToInt(month), true, false) + + // 已离职的员工不处理 + if staff.LeaveDate != "" && !isLeaveMonth { + continue + } + salary, err := salaryDao.GetBy(staff.Username, month) if err != nil { log.Errorf("db error :%s", err.Error()) @@ -133,13 +146,6 @@ func (s *Staff) SyncStaffSalary(month string) { salary.Username = staff.Username } - entryTime, _ := time.ParseInLocation("2006-01-02", staff.EntryDate, time.Local) - officalTime, _ := time.ParseInLocation("2006-01-02", staff.OfficialDate, time.Local) - leaveTime, _ := time.ParseInLocation("2006-01-02", staff.LeaveDate, time.Local) - isEntryMonth := goutil.If(cast.ToInt(entryTime.Format("200601")) == cast.ToInt(month), true, false) - isOfficialMonth := goutil.If(cast.ToInt(officalTime.Format("200601")) == cast.ToInt(month), true, false) - isLeaveMonth := goutil.If(cast.ToInt(leaveTime.Format("200601")) == cast.ToInt(month), true, false) - config, err := dao.NewUserConfigDao().GetByUsername(staff.Username) if err != nil { log.Errorf("db error :%s", err.Error())