This commit is contained in:
jiangyong27 2024-07-04 21:04:50 +08:00
parent d0800688aa
commit 527d44d6c4
1 changed files with 13 additions and 7 deletions

View File

@ -122,6 +122,19 @@ func (s *Staff) SyncStaffSalary(month string) {
return return
} }
for _, staff := range staffs { 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) salary, err := salaryDao.GetBy(staff.Username, month)
if err != nil { if err != nil {
log.Errorf("db error :%s", err.Error()) log.Errorf("db error :%s", err.Error())
@ -133,13 +146,6 @@ func (s *Staff) SyncStaffSalary(month string) {
salary.Username = staff.Username 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) config, err := dao.NewUserConfigDao().GetByUsername(staff.Username)
if err != nil { if err != nil {
log.Errorf("db error :%s", err.Error()) log.Errorf("db error :%s", err.Error())