This commit is contained in:
parent
13e9665ff1
commit
f6d0951c39
|
@ -5,5 +5,4 @@ import "enterprise/common/registry"
|
|||
func init() {
|
||||
registry.RegisterSalaryCalculator("1000", NewSalaryCalculator1000)
|
||||
registry.RegisterSalaryCalculator("1002", NewSalaryCalculator1002)
|
||||
registry.RegisterSalaryCalculator("1000_wujiefeng", NewSalaryCalculator1000Wujiefeng)
|
||||
}
|
||||
|
|
|
@ -1,64 +0,0 @@
|
|||
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,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *SalaryCalculator1000Wujiefeng) Calculate(salary *model.StaffSalary) map[string]interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *SalaryCalculator1000Wujiefeng) CalculateDel(salary *model.StaffSalary) {
|
||||
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)
|
||||
}
|
Loading…
Reference in New Issue