enterprise/server/controller/staff.go

51 lines
1021 B
Go
Raw Normal View History

2023-09-04 21:59:27 +08:00
package controller
import (
"enterprise/server/service"
2023-10-07 14:21:00 +08:00
"enterprise/server/session"
2023-10-07 14:18:46 +08:00
"enterprise/worker"
2023-09-04 21:59:27 +08:00
"github.com/gin-gonic/gin"
2025-03-05 10:11:07 +08:00
"github.com/spf13/cast"
2023-10-07 14:21:00 +08:00
"net/http"
2023-09-04 21:59:27 +08:00
"strings"
"time"
)
type Staff struct {
}
func (s *Staff) Salary(ctx *gin.Context) {
month := ctx.Query("month")
tp := ctx.Query("type")
2025-03-05 10:11:07 +08:00
cid := cast.ToInt64(ctx.Query("cid"))
if cid == 0 {
cid = 1000
}
2023-09-04 21:59:27 +08:00
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 {
2025-03-05 10:11:07 +08:00
serv.Agent(cid, month, ctx)
2023-09-04 21:59:27 +08:00
} else if tp == service.StaffSalaryTypeBank {
2025-03-05 10:11:07 +08:00
serv.Bank(cid, month, ctx)
2023-09-04 21:59:27 +08:00
} else {
2025-03-05 10:11:07 +08:00
serv.Summary(cid, month, ctx)
2023-09-04 21:59:27 +08:00
}
}
2023-10-07 14:18:46 +08:00
func (s *Staff) SyncStaffSalary(ctx *gin.Context) {
2025-03-05 10:11:07 +08:00
corpId := cast.ToInt64(ctx.Query("cid"))
if corpId == 0 {
corpId = 1000
}
go new(worker.Staff).SyncStaffSalary(corpId, "")
2023-10-07 14:21:00 +08:00
ctx.JSON(http.StatusOK, session.NewRspOk())
2023-10-07 14:18:46 +08:00
}