95 lines
2.2 KiB
Go
95 lines
2.2 KiB
Go
package model
|
|
|
|
import (
|
|
"encoding/json"
|
|
butil "enterprise/base/util"
|
|
"fmt"
|
|
"github.com/smbrave/goutil"
|
|
"github.com/spf13/cast"
|
|
"strings"
|
|
)
|
|
|
|
var (
|
|
StaffSalaryStatusWait = 1
|
|
StaffSalaryStatusPayed = 2
|
|
StaffSalaryStatusPause = 3
|
|
StaffSalaryPaymentBank = "bank"
|
|
StaffSalaryPaymentAlipay = "alipay"
|
|
)
|
|
|
|
type SalaryBillLine struct {
|
|
Label string
|
|
Value string
|
|
}
|
|
|
|
type SalaryBillSection struct {
|
|
Name string
|
|
Line []*SalaryBillLine
|
|
}
|
|
|
|
type StaffSalary struct {
|
|
Id int64
|
|
CorpId int64
|
|
UserId int64
|
|
Username string
|
|
Month string
|
|
Salary float64
|
|
AttendSalary float64
|
|
TargetSalary float64
|
|
AwardSalary float64
|
|
OtherSalary float64
|
|
ShouldDay int
|
|
AttendDay float64
|
|
HolidayDay float64
|
|
SocialDeduct float64
|
|
HouseDeduct float64
|
|
PersonalDeduct float64
|
|
OtherDeduct float64
|
|
CreateTime int64
|
|
UpdateTime int64
|
|
Extra string
|
|
Comment string
|
|
Status int
|
|
}
|
|
|
|
func (s *StaffSalary) GetShouldSalary() float64 {
|
|
return butil.FloatCut(s.AttendSalary + s.TargetSalary + s.AwardSalary + s.OtherSalary)
|
|
}
|
|
func (s *StaffSalary) GetRealSalary() float64 {
|
|
return butil.FloatCut(s.AttendSalary + s.TargetSalary + s.AwardSalary + s.OtherSalary -
|
|
s.SocialDeduct - s.HouseDeduct - s.PersonalDeduct - s.OtherDeduct)
|
|
}
|
|
|
|
func (s *StaffSalary) SetExtra(key string, value interface{}) {
|
|
var extra map[string]interface{}
|
|
json.Unmarshal([]byte(s.Extra), &extra)
|
|
extra[key] = value
|
|
s.Extra = goutil.EncodeJSON(extra)
|
|
}
|
|
|
|
func (s *StaffSalary) GetBillUrl() string {
|
|
encId := goutil.EncryptID(s.Id, "@@salary@@")
|
|
billUrl := fmt.Sprintf("https://e.yubanqy.com/api/staff/salary/bill?id=%s", encId)
|
|
return billUrl
|
|
}
|
|
|
|
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]
|
|
}
|