enterprise/server/controller/staff.go

46 lines
959 B
Go

package controller
import (
"enterprise/server/service"
"enterprise/server/session"
"enterprise/worker"
"github.com/gin-gonic/gin"
"net/http"
"strings"
"time"
)
type Staff struct {
}
func (s *Staff) Salary(ctx *gin.Context) {
month := ctx.Query("month")
tp := ctx.Query("type")
if month == "" {
month = time.Now().AddDate(0, -1, 0).Format("200601")
}
month = strings.ReplaceAll(month, "-", "")
if tp == "" {
tp = service.StaffSalaryTypeSummary
}
serv := new(service.StaffSalary)
if tp == service.StaffSalaryTypeAgent {
serv.Agent(month, ctx)
} else if tp == service.StaffSalaryTypeBank {
serv.Bank(month, ctx)
} else {
serv.Summary(month, ctx)
}
}
func (s *Staff) SyncStaffInfo(ctx *gin.Context) {
go new(worker.Staff).SyncStaffInfo()
ctx.JSON(http.StatusOK, session.NewRspOk())
}
func (s *Staff) SyncStaffSalary(ctx *gin.Context) {
go new(worker.Staff).SyncStaffSalary("")
ctx.JSON(http.StatusOK, session.NewRspOk())
}