From 72309d20f29387ce61d9d836e4c5b029c055a8dd Mon Sep 17 00:00:00 2001 From: jiangyong27 Date: Tue, 1 Apr 2025 22:35:13 +0800 Subject: [PATCH] stalary --- common/dao/staff_salary.go | 9 +++++---- server/service/staff_salary.go | 6 +++--- worker/staff.go | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/common/dao/staff_salary.go b/common/dao/staff_salary.go index 3831163..e105a5a 100644 --- a/common/dao/staff_salary.go +++ b/common/dao/staff_salary.go @@ -68,14 +68,15 @@ func (d *StaffSalaryDao) GetBy(corpId, userId int64, month string) (*model.Staff return &u, nil } -func (d *StaffSalaryDao) QueryAll(corpId int64, month string) ([]*model.StaffSalary, error) { +func (d *StaffSalaryDao) QueryAll(corpId int64, month string, status int) ([]*model.StaffSalary, error) { var u []*model.StaffSalary tx := GetDB().Table(d.TableName()) tx.Where("corp_id = ?", corpId) - - tx = tx.Where("month = ?", month) - + tx.Where("month = ?", month) + if status != 0 { + tx.Where("status = ?", status) + } tx.Order("month DESC") res := tx.Find(&u) diff --git a/server/service/staff_salary.go b/server/service/staff_salary.go index 3d9cc9f..7391207 100644 --- a/server/service/staff_salary.go +++ b/server/service/staff_salary.go @@ -166,7 +166,7 @@ func (s *StaffSalary) Pay(sess *session.AdminSession, req *api.PaySalaryReq) { func (s *StaffSalary) Agent(cid int64, month string, ctx *gin.Context) { xls := ctx.Query("xls") - staffSalarys, err := dao.NewStaffSalaryDao().QueryAll(cid, month) + staffSalarys, err := dao.NewStaffSalaryDao().QueryAll(cid, month, model.StaffSalaryStatusWait) if err != nil { panic(config.ErrDb.New().Append(err)) } @@ -229,7 +229,7 @@ func (s *StaffSalary) Agent(cid int64, month string, ctx *gin.Context) { func (s *StaffSalary) Bank(cid int64, month string, ctx *gin.Context) { xls := ctx.Query("xls") - staffSalarys, err := dao.NewStaffSalaryDao().QueryAll(cid, month) + staffSalarys, err := dao.NewStaffSalaryDao().QueryAll(cid, month, model.StaffSalaryStatusWait) if err != nil { panic(config.ErrDb.New().Append(err)) } @@ -290,7 +290,7 @@ func (s *StaffSalary) Bank(cid int64, month string, ctx *gin.Context) { func (s *StaffSalary) Summary(cid int64, month string, ctx *gin.Context) { xls := ctx.Query("xls") - staffSalarys, err := dao.NewStaffSalaryDao().QueryAll(cid, month) + staffSalarys, err := dao.NewStaffSalaryDao().QueryAll(cid, month, 0) if err != nil { panic(config.ErrDb.New().Append(err)) } diff --git a/worker/staff.go b/worker/staff.go index 2f68337..5aef89c 100644 --- a/worker/staff.go +++ b/worker/staff.go @@ -70,7 +70,7 @@ func (s *Staff) MontorWorkAge(corpId int64) { } func (s *Staff) SendStaffSalaryBill(corpId int64, month string) { - staffSalarys, err := dao.NewStaffSalaryDao().QueryAll(corpId, month) + staffSalarys, err := dao.NewStaffSalaryDao().QueryAll(corpId, month, model.StaffSalaryStatusPayed) if err != nil { log.Errorf("db error :%s", err.Error()) return