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"
|
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")
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|
2023-10-07 14:18:46 +08:00
|
|
|
|
|
|
|
func (s *Staff) SyncStaffInfo(ctx *gin.Context) {
|
|
|
|
go worker.SyncStaffInfo()
|
2023-10-07 14:21:00 +08:00
|
|
|
ctx.JSON(http.StatusOK, session.NewRspOk())
|
2023-10-07 14:18:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Staff) SyncStaffSalary(ctx *gin.Context) {
|
|
|
|
go worker.SyncStaffSalary("")
|
2023-10-07 14:21:00 +08:00
|
|
|
ctx.JSON(http.StatusOK, session.NewRspOk())
|
2023-10-07 14:18:46 +08:00
|
|
|
}
|