pay_channel
This commit is contained in:
parent
ea5a93a94d
commit
6b22c2472f
|
@ -2,6 +2,7 @@ package dao
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"enterprise/common/model"
|
"enterprise/common/model"
|
||||||
|
"fmt"
|
||||||
"github.com/spf13/cast"
|
"github.com/spf13/cast"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
"time"
|
"time"
|
||||||
|
@ -116,21 +117,26 @@ func (d *StaffSalaryDao) QueryAll(corpId int64, month string, status int) ([]*mo
|
||||||
return u, nil
|
return u, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *StaffSalaryDao) QueryAdmin(page, size int, corpId int64, staffId string, startMonth, endMonth, status string) ([]*model.StaffSalary, int64, error) {
|
func (d *StaffSalaryDao) QueryAdmin(page, size int, corpId int64, staffId string, startMonth, endMonth, status, payChannel string) ([]*model.StaffSalary, int64, error) {
|
||||||
var u []*model.StaffSalary
|
var u []*model.StaffSalary
|
||||||
|
staffTable := new(StaffUserDao).TableName()
|
||||||
tx := GetDB().Table(d.TableName())
|
tx := GetDB().Table(d.TableName())
|
||||||
tx.Where("corp_id = ?", corpId)
|
tx.Where(d.TableName()+".corp_id = ?", corpId)
|
||||||
if startMonth != "" {
|
if startMonth != "" {
|
||||||
tx.Where("month >= ?", startMonth)
|
tx.Where(d.TableName()+".month >= ?", startMonth)
|
||||||
}
|
}
|
||||||
if endMonth != "" {
|
if endMonth != "" {
|
||||||
tx.Where("month <= ?", endMonth)
|
tx.Where(d.TableName()+".month <= ?", endMonth)
|
||||||
}
|
}
|
||||||
if staffId != "" {
|
if staffId != "" {
|
||||||
tx.Where("user_id = ?", cast.ToInt64(staffId))
|
tx.Where(d.TableName()+".user_id = ?", cast.ToInt64(staffId))
|
||||||
}
|
}
|
||||||
if status != "" {
|
if status != "" {
|
||||||
tx.Where("status = ?", cast.ToInt(status))
|
tx.Where(d.TableName()+".status = ?", cast.ToInt(status))
|
||||||
|
}
|
||||||
|
if payChannel != "" {
|
||||||
|
tx.Where(staffTable+".config ->> '$.pay_channel' = ?", payChannel)
|
||||||
|
tx.Joins(fmt.Sprintf("JOIN %s ON %s.user_id = %s.id", staffTable, d.TableName(), staffTable))
|
||||||
}
|
}
|
||||||
|
|
||||||
var count int64
|
var count int64
|
||||||
|
|
|
@ -55,6 +55,7 @@ type ListSalaryReq struct {
|
||||||
StartMonth string `form:"start_month"`
|
StartMonth string `form:"start_month"`
|
||||||
EndMonth string `form:"end_month"`
|
EndMonth string `form:"end_month"`
|
||||||
StaffId string `form:"staff_id"`
|
StaffId string `form:"staff_id"`
|
||||||
|
PayChannel string `form:"pay_channel"`
|
||||||
Status string `form:"status"`
|
Status string `form:"status"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ func (s *StaffSalary) List(sess *session.AdminSession, req *api.ListSalaryReq) (
|
||||||
return 0, nil, nil
|
return 0, nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
salarys, total, err := dao.NewStaffSalaryDao().QueryAdmin(1, -1, sess.GetCorpId(), req.StaffId, req.StartMonth, req.EndMonth, req.Status)
|
salarys, total, err := dao.NewStaffSalaryDao().QueryAdmin(1, -1, sess.GetCorpId(), req.StaffId, req.StartMonth, req.EndMonth, req.Status, req.PayChannel)
|
||||||
session.CheckDBError(err)
|
session.CheckDBError(err)
|
||||||
start := (req.Page - 1) * req.Size
|
start := (req.Page - 1) * req.Size
|
||||||
end := start + req.Size
|
end := start + req.Size
|
||||||
|
|
Loading…
Reference in New Issue