download
This commit is contained in:
parent
fa2596ccd4
commit
3a8a7b94df
|
@ -12,6 +12,8 @@ import (
|
||||||
"github.com/smbrave/goutil"
|
"github.com/smbrave/goutil"
|
||||||
"github.com/spf13/cast"
|
"github.com/spf13/cast"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Salary struct {
|
type Salary struct {
|
||||||
|
@ -60,6 +62,29 @@ func (s *Salary) Upload(ctx *gin.Context) {
|
||||||
ctx.JSON(http.StatusOK, session.NewRsp(rsp))
|
ctx.JSON(http.StatusOK, session.NewRsp(rsp))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Salary) Download(ctx *gin.Context) {
|
||||||
|
sess := ctx.Keys[session.ContextSession].(*session.AdminSession)
|
||||||
|
|
||||||
|
tp := ctx.Query("type")
|
||||||
|
|
||||||
|
corp, err := dao.NewCorpDao().Get(sess.GetCorpId())
|
||||||
|
session.CheckDBError(err)
|
||||||
|
session.CheckNilError(corp, "企业不存在")
|
||||||
|
month := time.Now().AddDate(0, -1, 0).Format("200601")
|
||||||
|
|
||||||
|
month = strings.ReplaceAll(month, "-", "")
|
||||||
|
if tp == "" {
|
||||||
|
tp = service.StaffSalaryTypeBank
|
||||||
|
}
|
||||||
|
serv := new(service.StaffSalary)
|
||||||
|
|
||||||
|
if tp == service.StaffSalaryTypeAgent {
|
||||||
|
serv.Agent(corp.Id, month, "xls", ctx)
|
||||||
|
} else if tp == service.StaffSalaryTypeBank {
|
||||||
|
serv.Bank(corp.Id, month, "xls", ctx)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Salary) Pay(ctx *gin.Context) {
|
func (s *Salary) Pay(ctx *gin.Context) {
|
||||||
sess := ctx.Keys[session.ContextSession].(*session.AdminSession)
|
sess := ctx.Keys[session.ContextSession].(*session.AdminSession)
|
||||||
if !sess.GetAdmin().GetConfig().IsAdmin() {
|
if !sess.GetAdmin().GetConfig().IsAdmin() {
|
||||||
|
|
|
@ -111,6 +111,7 @@ func (s *Staff) Salary(ctx *gin.Context) {
|
||||||
sess := ctx.Keys[session.ContextSession].(*session.AdminSession)
|
sess := ctx.Keys[session.ContextSession].(*session.AdminSession)
|
||||||
month := ctx.Query("month")
|
month := ctx.Query("month")
|
||||||
tp := ctx.Query("type")
|
tp := ctx.Query("type")
|
||||||
|
xls := ctx.Query("xls")
|
||||||
|
|
||||||
corp, err := dao.NewCorpDao().GetByHost(sess.GetHeader().Host)
|
corp, err := dao.NewCorpDao().GetByHost(sess.GetHeader().Host)
|
||||||
session.CheckDBError(err)
|
session.CheckDBError(err)
|
||||||
|
@ -126,9 +127,9 @@ func (s *Staff) Salary(ctx *gin.Context) {
|
||||||
serv := new(service.StaffSalary)
|
serv := new(service.StaffSalary)
|
||||||
|
|
||||||
if tp == service.StaffSalaryTypeAgent {
|
if tp == service.StaffSalaryTypeAgent {
|
||||||
serv.Agent(corp.Id, month, ctx)
|
serv.Agent(corp.Id, month, xls, ctx)
|
||||||
} else if tp == service.StaffSalaryTypeBank {
|
} else if tp == service.StaffSalaryTypeBank {
|
||||||
serv.Bank(corp.Id, month, ctx)
|
serv.Bank(corp.Id, month, xls, ctx)
|
||||||
} else {
|
} else {
|
||||||
serv.Summary(corp.Id, month, ctx)
|
serv.Summary(corp.Id, month, ctx)
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,7 @@ func initRoutge(engine *gin.Engine) {
|
||||||
apiGroup.POST("/salary/pay", controller.NewSalary().Pay)
|
apiGroup.POST("/salary/pay", controller.NewSalary().Pay)
|
||||||
apiGroup.PUT("/staff/salary", controller.NewSalary().Update)
|
apiGroup.PUT("/staff/salary", controller.NewSalary().Update)
|
||||||
apiGroup.POST("/staff/salary/upload", controller.NewSalary().Upload)
|
apiGroup.POST("/staff/salary/upload", controller.NewSalary().Upload)
|
||||||
|
apiGroup.GET("/staff/salary/download", controller.NewSalary().Download)
|
||||||
apiGroup.DELETE("/staff/salary", controller.NewSalary().Delete)
|
apiGroup.DELETE("/staff/salary", controller.NewSalary().Delete)
|
||||||
noTokenGroup.GET("/staff/salary/bill", controller.NewSalary().Bill)
|
noTokenGroup.GET("/staff/salary/bill", controller.NewSalary().Bill)
|
||||||
|
|
||||||
|
|
|
@ -199,8 +199,7 @@ func (s *StaffSalary) Pay(sess *session.AdminSession, req *api.PaySalaryReq) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *StaffSalary) Agent(cid int64, month string, ctx *gin.Context) {
|
func (s *StaffSalary) Agent(cid int64, month, xls string, ctx *gin.Context) {
|
||||||
xls := ctx.Query("xls")
|
|
||||||
staffSalarys, err := dao.NewStaffSalaryDao().QueryAll(cid, month, model.StaffSalaryStatusWait)
|
staffSalarys, err := dao.NewStaffSalaryDao().QueryAll(cid, month, model.StaffSalaryStatusWait)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(config.ErrDb.New().Append(err))
|
panic(config.ErrDb.New().Append(err))
|
||||||
|
@ -265,8 +264,8 @@ func (s *StaffSalary) Agent(cid int64, month string, ctx *gin.Context) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *StaffSalary) Bank(cid int64, month string, ctx *gin.Context) {
|
func (s *StaffSalary) Bank(cid int64, month, xls string, ctx *gin.Context) {
|
||||||
xls := ctx.Query("xls")
|
|
||||||
staffSalarys, err := dao.NewStaffSalaryDao().QueryAll(cid, month, model.StaffSalaryStatusWait)
|
staffSalarys, err := dao.NewStaffSalaryDao().QueryAll(cid, month, model.StaffSalaryStatusWait)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(config.ErrDb.New().Append(err))
|
panic(config.ErrDb.New().Append(err))
|
||||||
|
|
Loading…
Reference in New Issue