69 lines
1.5 KiB
Go
69 lines
1.5 KiB
Go
package model
|
|
|
|
import (
|
|
"encoding/json"
|
|
butil "enterprise/base/util"
|
|
"github.com/spf13/cast"
|
|
"strings"
|
|
)
|
|
|
|
var (
|
|
StaffSalaryStatusNormal = 1
|
|
StaffSalaryStatusDisable = 2
|
|
)
|
|
|
|
type StaffSalary struct {
|
|
Id int64
|
|
Username string
|
|
Master string
|
|
Month string
|
|
BaseSalary float64
|
|
PerfSalary float64
|
|
AttendSalary float64
|
|
RealSalary float64
|
|
AwardSalary float64
|
|
SocialInsurence float64
|
|
HouseFund float64
|
|
PersonalTax float64
|
|
TotalDay float64
|
|
RealDay float64
|
|
Holiday float64
|
|
CreateTime int64
|
|
UpdateTime int64
|
|
Extra string
|
|
}
|
|
|
|
func (s *StaffSalary) GetRealSalary() float64 {
|
|
if s.Master == "" {
|
|
return butil.FloatCut(s.AttendSalary + s.PerfSalary + s.AwardSalary - s.SocialInsurence - s.PersonalTax - s.HouseFund)
|
|
}
|
|
|
|
return butil.FloatCut(s.BaseSalary)
|
|
}
|
|
|
|
func (s *StaffSalary) GetShouldSalary() float64 {
|
|
if s.Master == "" {
|
|
return butil.FloatCut(s.AttendSalary + s.PerfSalary + s.AwardSalary)
|
|
}
|
|
return butil.FloatCut(s.BaseSalary)
|
|
}
|
|
|
|
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]
|
|
}
|