53 lines
2.1 KiB
Go
53 lines
2.1 KiB
Go
package plugin
|
|
|
|
import (
|
|
"enterprise/common/global"
|
|
"enterprise/common/model"
|
|
"fmt"
|
|
log "github.com/sirupsen/logrus"
|
|
"strings"
|
|
"time"
|
|
)
|
|
|
|
type Staff struct {
|
|
}
|
|
|
|
func (s *Staff) MonitorWorkAge(user *model.StaffUser) {
|
|
nowDate := time.Now()
|
|
entryDate, _ := time.ParseInLocation("2006-01-02", user.EntryDate, time.Local)
|
|
OfficialDate, _ := time.ParseInLocation("2006-01-02", user.OfficialDate, time.Local)
|
|
|
|
entryMonth := (nowDate.Year()-entryDate.Year())*12 + int(nowDate.Month()) - int(entryDate.Month())
|
|
officalDay := (OfficialDate.Unix() - nowDate.Unix()) / 86400
|
|
log.Infof("staff[%s] entryDate[%s] spanMonth[%.1f]", user.Username, user.EntryDate, float64(entryMonth)/12.0)
|
|
|
|
salary := user.GetSalary()
|
|
if nowDate.Day() == 1 && entryMonth%6 == 0 {
|
|
message := make([]string, 0)
|
|
message = append(message, fmt.Sprintf("【员工半年提醒】[%s]", user.Realname))
|
|
message = append(message, fmt.Sprintf("入职时间:%s", user.EntryDate))
|
|
message = append(message, fmt.Sprintf("入职年限:%.1f", float64(entryMonth)/12))
|
|
message = append(message, fmt.Sprintf("基本工资:%s", salary.Base))
|
|
message = append(message, fmt.Sprintf("绩效工资:%s", salary.Target))
|
|
message = append(message, fmt.Sprintf("身份证号:%s", user.Idno))
|
|
|
|
if err := global.SendCorpMessage(user.CorpId, []string{"jiangyong"}, strings.Join(message, "\n")); err != nil {
|
|
log.Errorf("send message error :%s", err.Error())
|
|
}
|
|
}
|
|
|
|
if officalDay > 0 && officalDay <= 30 && officalDay%7 == 0 {
|
|
message := make([]string, 0)
|
|
message = append(message, fmt.Sprintf("【员工转正提醒】[%s]", user.Realname))
|
|
message = append(message, fmt.Sprintf("入职时间:%s", user.EntryDate))
|
|
message = append(message, fmt.Sprintf("转正时间:%s", user.OfficialDate))
|
|
message = append(message, fmt.Sprintf("基本工资:%s", salary.Base))
|
|
message = append(message, fmt.Sprintf("绩效工资:%s", salary.Target))
|
|
message = append(message, fmt.Sprintf("身份证号:%s", user.Idno))
|
|
|
|
if err := global.SendCorpMessage(user.CorpId, []string{"jiangyong"}, strings.Join(message, "\n")); err != nil {
|
|
log.Errorf("send message error :%s", err.Error())
|
|
}
|
|
}
|
|
}
|