del
This commit is contained in:
parent
c5a006ec66
commit
13e9665ff1
|
@ -5,7 +5,6 @@ import (
|
||||||
"enterprise/common/model"
|
"enterprise/common/model"
|
||||||
"enterprise/common/registry"
|
"enterprise/common/registry"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"github.com/spf13/cast"
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -58,85 +57,3 @@ func (s *SalaryCalculator1002) Calculate(salary *model.StaffSalary) map[string]i
|
||||||
|
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SalaryCalculator1002) CalculateDel(salary *model.StaffSalary) {
|
|
||||||
userSlary := s.user.GetSalary()
|
|
||||||
if s.user.Status == model.StaffUserStatusAttach { //挂靠直接算工资
|
|
||||||
salary.AttendSalary = cast.ToFloat64(userSlary.Base)
|
|
||||||
salary.TargetSalary = cast.ToFloat64(userSlary.Target)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
fullAttendSalary := float64(0)
|
|
||||||
|
|
||||||
//特殊情况
|
|
||||||
if salary.Month == "202502" {
|
|
||||||
salary.ShouldDay = 21
|
|
||||||
}
|
|
||||||
|
|
||||||
if salary.AttendDay == float64(salary.ShouldDay) {
|
|
||||||
fullAttendSalary = 500
|
|
||||||
}
|
|
||||||
//特殊情况
|
|
||||||
if salary.Month == "202502" && (salary.Username == "luoyi" || salary.Username == "zhouhong" || salary.Username == "wangyan") {
|
|
||||||
fullAttendSalary = 500
|
|
||||||
}
|
|
||||||
|
|
||||||
salary.AttendSalary = (cast.ToFloat64(userSlary.Base)-500)*(salary.AttendDay/float64(salary.ShouldDay)) + fullAttendSalary
|
|
||||||
salary.TargetSalary = cast.ToFloat64(userSlary.Target)
|
|
||||||
|
|
||||||
// 1.订单
|
|
||||||
monthTime, _ := time.ParseInLocation("200601", salary.Month, time.Local)
|
|
||||||
startTime := monthTime.Unix()
|
|
||||||
endTime := monthTime.AddDate(0, 1, 0).Unix() - 1
|
|
||||||
orders, err := dao.NewExternalCorpOrder().QueryOwnerOrder(s.user.Username, startTime, endTime)
|
|
||||||
if err != nil {
|
|
||||||
log.Errorf("db error:%s", err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
orderNum := len(orders)
|
|
||||||
salary.SetExtra("corp_order_num", cast.ToString(orderNum))
|
|
||||||
|
|
||||||
//2.处理的订单
|
|
||||||
processOrders, err := dao.NewExternalCorpOrder().QueryProcessOrder(s.user.Username, startTime, endTime)
|
|
||||||
if err != nil {
|
|
||||||
log.Errorf("db error:%s", err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
//3.下属订单
|
|
||||||
corpUser, err := dao.NewExternalCorpUser().Get(s.user.Username)
|
|
||||||
if err != nil {
|
|
||||||
log.Errorf("db error:%s", err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
childOrderNum := 0
|
|
||||||
if corpUser != nil {
|
|
||||||
childOrders, err := dao.NewExternalCorpOrder().QueryChildOrder(corpUser.Id, startTime, endTime)
|
|
||||||
if err != nil {
|
|
||||||
log.Errorf("db error:%s", err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
childOrderNum = len(childOrders)
|
|
||||||
}
|
|
||||||
salary.SetExtra("corp_child_order_num", cast.ToString(childOrderNum))
|
|
||||||
|
|
||||||
processOrderNum := len(processOrders)
|
|
||||||
salary.SetExtra("corp_process_order_num", cast.ToString(processOrderNum))
|
|
||||||
salary.AwardSalary = 0
|
|
||||||
if orderNum >= 40 {
|
|
||||||
salary.TargetSalary = cast.ToFloat64(userSlary.Target)
|
|
||||||
if orderNum <= 60 {
|
|
||||||
salary.TargetSalary += float64((orderNum - 40) * 80)
|
|
||||||
} else if orderNum <= 80 {
|
|
||||||
salary.TargetSalary += 1600 + float64((orderNum-60)*100)
|
|
||||||
} else {
|
|
||||||
salary.TargetSalary += 3600 + float64((orderNum-80)*120)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
salary.TargetSalary = float64(60 * orderNum)
|
|
||||||
}
|
|
||||||
salary.AwardSalary += float64(processOrderNum * 5)
|
|
||||||
salary.AwardSalary += float64(childOrderNum * 5)
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue