enterprise/common/model/staff_salary.go

61 lines
1.4 KiB
Go
Raw Normal View History

2023-09-01 20:01:30 +08:00
package model
2024-11-04 23:00:55 +08:00
import (
"encoding/json"
butil "enterprise/base/util"
"github.com/spf13/cast"
"strings"
)
2024-04-02 13:54:39 +08:00
2023-09-04 21:58:26 +08:00
var (
StaffSalaryStatusNormal = 1
StaffSalaryStatusDisable = 2
)
2023-09-01 20:01:30 +08:00
type StaffSalary struct {
Id int64
Username string
Month string
BaseSalary float64
2024-11-04 23:00:55 +08:00
PerfSalary float64
2024-04-02 12:14:23 +08:00
AttendSalary float64
2023-09-01 20:01:30 +08:00
RealSalary float64
2023-10-07 14:30:31 +08:00
AwardSalary float64
2023-09-01 20:01:30 +08:00
SocialInsurence float64
2024-11-04 23:00:55 +08:00
HouseFund float64
2023-09-04 19:14:02 +08:00
PersonalTax float64
2024-01-31 20:49:43 +08:00
TotalDay float64
RealDay float64
2023-09-04 19:14:02 +08:00
Holiday float64
2023-09-01 20:01:30 +08:00
CreateTime int64
UpdateTime int64
Extra string
}
2024-04-02 13:54:39 +08:00
func (s *StaffSalary) GetRealSalary() float64 {
2024-11-04 23:00:55 +08:00
return butil.FloatCut(s.AttendSalary + s.PerfSalary + s.AwardSalary - s.SocialInsurence - s.PersonalTax - s.HouseFund)
}
func (s *StaffSalary) GetShouldSalary() float64 {
return butil.FloatCut(s.AttendSalary + s.PerfSalary + s.AwardSalary)
}
type StaffSalarySort []*StaffSalary
func (s StaffSalarySort) Len() int {
return len(s)
}
func (s StaffSalarySort) Less(i, j int) bool {
var iExtra map[string]string
var jExtra map[string]string
json.Unmarshal([]byte(s[i].Extra), &iExtra)
json.Unmarshal([]byte(s[j].Extra), &jExtra)
return cast.ToInt64(strings.ReplaceAll(iExtra["entryDate"], "-", "")) < cast.ToInt64(strings.ReplaceAll(jExtra["entryDate"], "-", ""))
}
func (s StaffSalarySort) Swap(i, j int) {
s[i], s[j] = s[j], s[i]
2024-04-02 13:54:39 +08:00
}