60 lines
1.3 KiB
Go
60 lines
1.3 KiB
Go
package controller
|
|
|
|
import (
|
|
"enterprise/server/api"
|
|
"enterprise/server/service"
|
|
"enterprise/server/session"
|
|
"enterprise/worker"
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/spf13/cast"
|
|
"net/http"
|
|
"strings"
|
|
"time"
|
|
)
|
|
|
|
type Staff struct {
|
|
}
|
|
|
|
func (s *Staff) Login(ctx *gin.Context) {
|
|
var req api.StaffLoginReq
|
|
session.CheckParamError(ctx.ShouldBindJSON(&req))
|
|
sess := ctx.Keys[session.ContextSession].(*session.AdminSession)
|
|
data := new(service.StaffUser).Login(sess, &req)
|
|
ctx.JSON(http.StatusOK, session.NewRsp(data))
|
|
}
|
|
|
|
func (s *Staff) Salary(ctx *gin.Context) {
|
|
month := ctx.Query("month")
|
|
tp := ctx.Query("type")
|
|
|
|
cid := cast.ToInt64(ctx.Query("cid"))
|
|
if cid == 0 {
|
|
cid = 1000
|
|
}
|
|
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(cid, month, ctx)
|
|
} else if tp == service.StaffSalaryTypeBank {
|
|
serv.Bank(cid, month, ctx)
|
|
} else {
|
|
serv.Summary(cid, month, ctx)
|
|
}
|
|
}
|
|
|
|
func (s *Staff) SyncStaffSalary(ctx *gin.Context) {
|
|
corpId := cast.ToInt64(ctx.Query("cid"))
|
|
if corpId == 0 {
|
|
corpId = 1000
|
|
}
|
|
go new(worker.Staff).SyncStaffSalary(corpId, "")
|
|
ctx.JSON(http.StatusOK, session.NewRspOk())
|
|
}
|