enterprise/common/model/approval_vacation.go

44 lines
1.2 KiB
Go

package model
import (
"git.u8t.cn/open/gosdk/qyweixin"
"github.com/smbrave/goutil"
"github.com/spf13/cast"
"strings"
"time"
)
var ()
type ApprovalVacation struct {
Id int64
Username string
Month string
SpNo string
VacationType string
VacationDate string
VacationStartTime string
VacationEndTime string
VacationDuration float64
VacationRemark string
ApplyTime string
CreateTime int64
UpdateTime int64
}
func (vacation *ApprovalVacation) From(d *qyweixin.ApproveDetail) {
vacation.SpNo = d.SpNo
vacation.Username = d.GetUserid()
vacation.ApplyTime = goutil.TimeToDateTime(d.ApplyTime)
fields := strings.SplitN(d.GetValue("请假类型"), ",", 4)
dTime := cast.ToInt64(fields[1])
vacation.VacationType = fields[0]
vacation.VacationDate = goutil.TimeToDate(dTime)
vacation.VacationStartTime = goutil.TimeToDateTime(cast.ToInt64(fields[1]))
vacation.VacationEndTime = goutil.TimeToDateTime(cast.ToInt64(fields[2]))
vacation.VacationDuration = float64(cast.ToInt64(fields[3])) / float64(3600*8)
vacation.VacationRemark = d.GetValue("请假事由")
vacation.Month = time.Unix(dTime, 0).Format("200601")
}