2025-03-12 23:57:24 +08:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"enterprise/common/model"
|
|
|
|
"github.com/smbrave/goutil"
|
|
|
|
"github.com/spf13/cast"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Salary struct {
|
|
|
|
Id string `json:"id,omitempty"`
|
|
|
|
Month string `json:"month,omitempty"`
|
|
|
|
Username string `json:"username,omitempty"`
|
|
|
|
Realname string `json:"realname,omitempty"`
|
2025-03-13 11:18:47 +08:00
|
|
|
BaseSalary string `json:"base_salary,omitempty"`
|
2025-03-12 23:57:24 +08:00
|
|
|
TargetSalary string `json:"target_salary,omitempty"`
|
2025-03-13 11:18:47 +08:00
|
|
|
RealSalary string `json:"real_salary,omitempty"`
|
|
|
|
AttendIncome string `json:"attend_income,omitempty"`
|
|
|
|
TargetIncome string `json:"target_income,omitempty"`
|
|
|
|
AwardIncome string `json:"award_income,omitempty"`
|
|
|
|
OtherIncome string `json:"other_income,omitempty"`
|
2025-03-12 23:57:24 +08:00
|
|
|
ShouldDay string `json:"should_day,omitempty"`
|
|
|
|
AttendDay string `json:"attend_day,omitempty"`
|
|
|
|
HolidayDay string `json:"holiday_day,omitempty"`
|
|
|
|
SocialDeduct string `json:"social_deduct,omitempty"`
|
|
|
|
HouseDeduct string `json:"house_deduct,omitempty"`
|
|
|
|
PersonalDeduct string `json:"personal_deduct,omitempty"`
|
|
|
|
OtherDeduct string `json:"other_deduct,omitempty"`
|
|
|
|
CreateTime string `json:"create_time,omitempty"`
|
|
|
|
UpdateTime string `json:"update_time,omitempty"`
|
2025-03-13 20:36:09 +08:00
|
|
|
Extra string `json:"extra"`
|
2025-03-12 23:57:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
type CreateSalaryReq struct {
|
|
|
|
Month string `json:"month"`
|
|
|
|
Username string `json:"username"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type UpdateSalaryReq struct {
|
2025-03-13 11:59:20 +08:00
|
|
|
Id string `json:"id"`
|
2025-03-13 11:51:35 +08:00
|
|
|
OtherIncome string `json:"other_income"`
|
2025-03-12 23:57:24 +08:00
|
|
|
OtherDeduct string `json:"other_deduct"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type ListSalaryReq struct {
|
|
|
|
BaseRequest
|
|
|
|
StartMonth string `form:"start_month"`
|
|
|
|
EndMonth string `form:"end_month"`
|
|
|
|
Username string `form:"username"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Salary) From(m *model.StaffSalary) {
|
|
|
|
s.Id = cast.ToString(m.Id)
|
|
|
|
s.Username = m.Username
|
|
|
|
s.Month = m.Month
|
2025-03-13 11:18:47 +08:00
|
|
|
s.RealSalary = goutil.FormatFloat(m.GetRealSalary())
|
|
|
|
s.AttendIncome = goutil.FormatFloat(m.AttendSalary)
|
|
|
|
s.TargetIncome = goutil.FormatFloat(m.TargetSalary)
|
|
|
|
s.AwardIncome = goutil.FormatFloat(m.AwardSalary)
|
|
|
|
s.OtherIncome = goutil.FormatFloat(m.OtherSalary)
|
2025-03-12 23:57:24 +08:00
|
|
|
s.ShouldDay = cast.ToString(m.ShouldDay)
|
|
|
|
s.AttendDay = goutil.FormatFloat(m.AttendDay)
|
|
|
|
s.HolidayDay = goutil.FormatFloat(m.HolidayDay)
|
|
|
|
s.SocialDeduct = goutil.FormatFloat(m.SocialDeduct)
|
|
|
|
s.HouseDeduct = goutil.FormatFloat(m.HouseDeduct)
|
|
|
|
s.PersonalDeduct = goutil.FormatFloat(m.PersonalDeduct)
|
|
|
|
s.OtherDeduct = goutil.FormatFloat(m.OtherDeduct)
|
|
|
|
s.CreateTime = goutil.TimeToDateTime(m.CreateTime)
|
|
|
|
s.UpdateTime = goutil.TimeToDateTime(m.UpdateTime)
|
2025-03-13 20:36:09 +08:00
|
|
|
s.Extra = m.Extra
|
2025-03-12 23:57:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Salary) Add(o *Salary) {
|
|
|
|
s.TargetSalary = goutil.FormatFloat(cast.ToFloat64(s.TargetSalary) + cast.ToFloat64(o.TargetSalary))
|
2025-03-13 11:18:47 +08:00
|
|
|
s.BaseSalary = goutil.FormatFloat(cast.ToFloat64(s.BaseSalary) + cast.ToFloat64(o.BaseSalary))
|
|
|
|
s.RealSalary = goutil.FormatFloat(cast.ToFloat64(s.RealSalary) + cast.ToFloat64(o.RealSalary))
|
|
|
|
s.AttendIncome = goutil.FormatFloat(cast.ToFloat64(s.AttendIncome) + cast.ToFloat64(o.AttendIncome))
|
|
|
|
s.TargetIncome = goutil.FormatFloat(cast.ToFloat64(s.TargetIncome) + cast.ToFloat64(o.TargetIncome))
|
|
|
|
s.AwardIncome = goutil.FormatFloat(cast.ToFloat64(s.AwardIncome) + cast.ToFloat64(o.AwardIncome))
|
|
|
|
s.OtherIncome = goutil.FormatFloat(cast.ToFloat64(s.OtherIncome) + cast.ToFloat64(o.OtherIncome))
|
2025-03-12 23:57:24 +08:00
|
|
|
s.ShouldDay = cast.ToString(cast.ToInt(s.ShouldDay) + cast.ToInt(o.ShouldDay))
|
|
|
|
s.AttendDay = goutil.FormatFloat(cast.ToFloat64(s.AttendDay) + cast.ToFloat64(o.AttendDay))
|
|
|
|
s.HolidayDay = goutil.FormatFloat(cast.ToFloat64(s.HolidayDay) + cast.ToFloat64(o.HolidayDay))
|
|
|
|
s.SocialDeduct = goutil.FormatFloat(cast.ToFloat64(s.SocialDeduct) + cast.ToFloat64(o.SocialDeduct))
|
|
|
|
s.HouseDeduct = goutil.FormatFloat(cast.ToFloat64(s.HouseDeduct) + cast.ToFloat64(o.HouseDeduct))
|
|
|
|
s.PersonalDeduct = goutil.FormatFloat(cast.ToFloat64(s.PersonalDeduct) + cast.ToFloat64(o.PersonalDeduct))
|
|
|
|
s.OtherDeduct = goutil.FormatFloat(cast.ToFloat64(s.OtherDeduct) + cast.ToFloat64(o.OtherDeduct))
|
|
|
|
|
|
|
|
}
|