2025-03-04 23:14:09 +08:00
|
|
|
package salary_calculator
|
|
|
|
|
|
|
|
import (
|
|
|
|
"enterprise/common/dao"
|
|
|
|
"enterprise/common/model"
|
|
|
|
"enterprise/common/registry"
|
|
|
|
log "github.com/sirupsen/logrus"
|
|
|
|
"github.com/smbrave/goutil"
|
|
|
|
"github.com/spf13/cast"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
type SalaryCalculator1000Wujiefeng struct {
|
|
|
|
corp *model.Corp
|
|
|
|
user *model.StaffUser
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewSalaryCalculator1000Wujiefeng(corp *model.Corp, user *model.StaffUser) registry.SalaryCalculator {
|
|
|
|
return &SalaryCalculator1000Wujiefeng{
|
|
|
|
corp: corp,
|
|
|
|
user: user,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-03-13 19:19:30 +08:00
|
|
|
func (s *SalaryCalculator1000Wujiefeng) Calculate(salary *model.StaffSalary) map[string]interface{} {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *SalaryCalculator1000Wujiefeng) CalculateDel(salary *model.StaffSalary) {
|
2025-03-04 23:14:09 +08:00
|
|
|
baseCalculate := NewSalaryCalculator1000(s.corp, s.user)
|
|
|
|
baseCalculate.Calculate(salary)
|
|
|
|
|
|
|
|
monthTime, _ := time.ParseInLocation("200601", salary.Month, time.Local)
|
|
|
|
|
|
|
|
sumProfitAmount1 := int64(0)
|
|
|
|
sumProfitAmount2 := int64(0)
|
|
|
|
|
|
|
|
//本月
|
|
|
|
datas, err := dao.NewUnifyKctData().QueryData(monthTime.Format("2006-01-02"), monthTime.AddDate(0, 1, -1).Format("2006-01-02"))
|
|
|
|
if err != nil {
|
|
|
|
log.Errorf("db error :%s", err.Error())
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, data := range datas {
|
|
|
|
sumProfitAmount1 += data.PayAmount - data.RefundAmount - data.Cost
|
|
|
|
}
|
|
|
|
|
|
|
|
//上月
|
|
|
|
datas, err = dao.NewUnifyKctData().QueryData(monthTime.AddDate(0, -1, 0).Format("2006-01-02"),
|
|
|
|
monthTime.AddDate(0, 0, -1).Format("2006-01-02"))
|
|
|
|
if err != nil {
|
|
|
|
log.Errorf("db error :%s", err.Error())
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, data := range datas {
|
|
|
|
sumProfitAmount2 += data.PayAmount - data.RefundAmount - data.Cost
|
|
|
|
}
|
|
|
|
salary.SetExtra("sumProfitAmount1", sumProfitAmount1)
|
|
|
|
salary.SetExtra("sumProfitAmount2", sumProfitAmount2)
|
|
|
|
userSalary := s.user.GetSalary()
|
|
|
|
salary.TargetSalary = goutil.If(sumProfitAmount1-sumProfitAmount2 > 0, cast.ToFloat64(userSalary.Target)*float64(sumProfitAmount1)/float64(sumProfitAmount2), 0)
|
|
|
|
}
|