salary status2

This commit is contained in:
jiangyong27 2025-03-27 20:12:03 +08:00
parent a114e9bffd
commit fe6ad48054
3 changed files with 10 additions and 5 deletions

View File

@ -2,6 +2,7 @@ package dao
import (
"enterprise/common/model"
"github.com/spf13/cast"
"gorm.io/gorm"
"time"
)
@ -88,7 +89,7 @@ func (d *StaffSalaryDao) QueryAll(corpId int64, month string) ([]*model.StaffSal
return u, nil
}
func (d *StaffSalaryDao) QueryAdmin(page, size int, corpId int64, username string, startMonth, endMonth string) ([]*model.StaffSalary, int64, error) {
func (d *StaffSalaryDao) QueryAdmin(page, size int, corpId int64, staffId string, startMonth, endMonth, status string) ([]*model.StaffSalary, int64, error) {
var u []*model.StaffSalary
tx := GetDB().Table(d.TableName())
tx.Where("corp_id = ?", corpId)
@ -98,8 +99,11 @@ func (d *StaffSalaryDao) QueryAdmin(page, size int, corpId int64, username strin
if endMonth != "" {
tx.Where("month <= ?", endMonth)
}
if username != "" {
tx.Where("username = ?", username)
if staffId != "" {
tx.Where("user_id = ?", cast.ToInt64(staffId))
}
if status != "" {
tx.Where("status = ?", cast.ToInt(status))
}
var count int64

View File

@ -53,7 +53,8 @@ type ListSalaryReq struct {
BaseRequest
StartMonth string `form:"start_month"`
EndMonth string `form:"end_month"`
Username string `form:"username"`
StaffId string `form:"staff_id"`
Status string `json:"status"`
}
func (s *Salary) From(m *model.StaffSalary) {

View File

@ -34,7 +34,7 @@ func NewStaffSalary() *StaffSalary {
}
func (s *StaffSalary) List(sess *session.AdminSession, req *api.ListSalaryReq) (int64, interface{}, interface{}) {
salarys, total, err := dao.NewStaffSalaryDao().QueryAdmin(1, -1, sess.GetCorpId(), req.Username, req.StartMonth, req.EndMonth)
salarys, total, err := dao.NewStaffSalaryDao().QueryAdmin(1, -1, sess.GetCorpId(), req.StaffId, req.StartMonth, req.EndMonth, req.Status)
session.CheckDBError(err)
start := (req.Page - 1) * req.Size
end := start + req.Size