previous
This commit is contained in:
parent
f6d0951c39
commit
b684f0d710
|
@ -27,11 +27,13 @@ func NewSalaryCalculator1000(corp *model.Corp, user *model.StaffUser) registry.S
|
|||
}
|
||||
|
||||
func (s *SalaryCalculator1000) Calculate(salary *model.StaffSalary) map[string]interface{} {
|
||||
monthTime, _ := time.ParseInLocation("200601", salary.Month, time.Local)
|
||||
|
||||
data := make(map[string]interface{})
|
||||
data["adProfit"] = s.getAdOwnerProfit(salary)
|
||||
data["appIncRate10024"] = s.getAppIncRate(salary, 10024)
|
||||
|
||||
data["appProfit1024"] = s.getAppProfit(10024, salary.Month)
|
||||
data["appProfit1024Previous "] = s.getAppProfit(10024, monthTime.AddDate(0, -1, 0).Format("2006-01"))
|
||||
return data
|
||||
}
|
||||
|
||||
|
@ -53,12 +55,11 @@ func (s *SalaryCalculator1000) getAdOwnerProfit(salary *model.StaffSalary) float
|
|||
return totalProfit
|
||||
}
|
||||
|
||||
func (s *SalaryCalculator1000) getAppIncRate(salary *model.StaffSalary, appid int64) float64 {
|
||||
func (s *SalaryCalculator1000) getAppProfit(appid int64, month string) float64 {
|
||||
|
||||
monthTime, _ := time.ParseInLocation("200601", salary.Month, time.Local)
|
||||
monthTime, _ := time.ParseInLocation("200601", month, time.Local)
|
||||
|
||||
sumProfitAmount1 := int64(0)
|
||||
sumProfitAmount2 := int64(0)
|
||||
sumProfitAmount := int64(0)
|
||||
|
||||
//本月
|
||||
datas, err := dao.NewUnifyKctData().QueryData(monthTime.Format("2006-01-02"), monthTime.AddDate(0, 1, -1).Format("2006-01-02"))
|
||||
|
@ -68,22 +69,7 @@ func (s *SalaryCalculator1000) getAppIncRate(salary *model.StaffSalary, appid in
|
|||
}
|
||||
|
||||
for _, data := range datas {
|
||||
sumProfitAmount1 += data.PayAmount - data.RefundAmount - data.Cost
|
||||
sumProfitAmount += 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 0
|
||||
}
|
||||
|
||||
for _, data := range datas {
|
||||
sumProfitAmount2 += data.PayAmount - data.RefundAmount - data.Cost
|
||||
}
|
||||
salary.SetExtra("sumProfitAmount1", sumProfitAmount1)
|
||||
salary.SetExtra("sumProfitAmount2", sumProfitAmount2)
|
||||
|
||||
return float64(sumProfitAmount1) / float64(sumProfitAmount2)
|
||||
return float64(sumProfitAmount) / 100
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue