diff --git a/worker/staff.go b/worker/staff.go index 005b91c..a7cac3c 100644 --- a/worker/staff.go +++ b/worker/staff.go @@ -33,22 +33,37 @@ func (s *Staff) MontorWorkAge() { } entryDate, _ := time.ParseInLocation("2006-01-02", staff.EntryDate, time.Local) - spanMonth := (nowDate.Year()-entryDate.Year())*12 + int(nowDate.Month()) - int(entryDate.Month()) + OfficialDate, _ := time.ParseInLocation("2006-01-02", staff.OfficialDate, time.Local) - log.Infof("staff[%s] entryDate[%s] spanMonth[%.1f]", staff.Username, staff.EntryDate, float64(spanMonth)/12.0) - if nowDate.Day() != entryDate.Day() || spanMonth%6 != 0 { - continue + entryMonth := (nowDate.Year()-entryDate.Year())*12 + int(nowDate.Month()) - int(entryDate.Month()) + officelDay := (OfficialDate.Unix() - nowDate.Unix()) / 86400 + log.Infof("staff[%s] entryDate[%s] spanMonth[%.1f]", staff.Username, staff.EntryDate, float64(entryMonth)/12.0) + if nowDate.Day() == 1 && entryMonth%6 == 0 { + message := make([]string, 0) + message = append(message, fmt.Sprintf("【员工半年提醒】[%s]", staff.Realname)) + message = append(message, fmt.Sprintf("入职时间:%s", staff.EntryDate)) + message = append(message, fmt.Sprintf("入职年限:%.1f", float64(entryMonth)/12)) + message = append(message, fmt.Sprintf("基本工资:%s", staff.BaseSalary)) + message = append(message, fmt.Sprintf("绩效工资:%s", staff.PerfSalary)) + message = append(message, fmt.Sprintf("身份证号:%s", staff.Idno)) + + if err := global.SendMessage([]string{"jiangyong"}, strings.Join(message, "\n")); err != nil { + log.Errorf("send message error :%s", err.Error()) + } } - message := make([]string, 0) - message = append(message, fmt.Sprintf("【员工半年提醒】[%s]", staff.Realname)) - message = append(message, fmt.Sprintf("入职时间:%s", staff.EntryDate)) - message = append(message, fmt.Sprintf("入职年限:%.1f", float64(spanMonth)/12)) - message = append(message, fmt.Sprintf("基本工资:%s", staff.BaseSalary)) - message = append(message, fmt.Sprintf("绩效工资:%s", staff.PerfSalary)) - message = append(message, fmt.Sprintf("身份证号:%s", staff.Idno)) - if err := global.SendMessage([]string{"jiangyong"}, strings.Join(message, "\n")); err != nil { - log.Errorf("send message error :%s", err.Error()) + if officelDay <= 30 && officelDay%7 == 0 { + message := make([]string, 0) + message = append(message, fmt.Sprintf("【员工转账提醒】[%s]", staff.Realname)) + message = append(message, fmt.Sprintf("入职时间:%s", staff.EntryDate)) + message = append(message, fmt.Sprintf("转正时间:%s", staff.OfficialDate)) + message = append(message, fmt.Sprintf("基本工资:%s", staff.BaseSalary)) + message = append(message, fmt.Sprintf("绩效工资:%s", staff.PerfSalary)) + message = append(message, fmt.Sprintf("身份证号:%s", staff.Idno)) + + if err := global.SendMessage([]string{"jiangyong"}, strings.Join(message, "\n")); err != nil { + log.Errorf("send message error :%s", err.Error()) + } } }