award2
This commit is contained in:
parent
bbc9c78499
commit
b039d1fcf8
|
@ -66,12 +66,16 @@ func (d *StaffSalaryDao) GetBy(username, month string) (*model.StaffSalary, erro
|
||||||
return &u, nil
|
return &u, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *StaffSalaryDao) Query(month string) ([]*model.StaffSalary, error) {
|
func (d *StaffSalaryDao) Query(month, username string) ([]*model.StaffSalary, error) {
|
||||||
var u []*model.StaffSalary
|
var u []*model.StaffSalary
|
||||||
tx := GetDB().Table(d.TableName())
|
tx := GetDB().Table(d.TableName())
|
||||||
if month != "" {
|
if month != "" {
|
||||||
tx = tx.Where("month = ?", month)
|
tx = tx.Where("month = ?", month)
|
||||||
}
|
}
|
||||||
|
if username != "" {
|
||||||
|
tx.Where("username = ?", username)
|
||||||
|
}
|
||||||
|
tx.Order("month DESC")
|
||||||
|
|
||||||
res := tx.Find(&u)
|
res := tx.Find(&u)
|
||||||
if res.Error == gorm.ErrRecordNotFound {
|
if res.Error == gorm.ErrRecordNotFound {
|
||||||
|
|
|
@ -34,6 +34,10 @@ func (s *Staff) Salary(ctx *gin.Context) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Staff) SalaryHistory(ctx *gin.Context) {
|
||||||
|
new(service.StaffSalary).History(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Staff) SyncStaffInfo(ctx *gin.Context) {
|
func (s *Staff) SyncStaffInfo(ctx *gin.Context) {
|
||||||
go new(worker.Staff).SyncStaffInfo()
|
go new(worker.Staff).SyncStaffInfo()
|
||||||
ctx.JSON(http.StatusOK, session.NewRspOk())
|
ctx.JSON(http.StatusOK, session.NewRspOk())
|
||||||
|
|
|
@ -18,6 +18,7 @@ func initRoutge(engine *gin.Engine) {
|
||||||
apiGroup.Any("/qyweixin/pay", qyweixin.Pay)
|
apiGroup.Any("/qyweixin/pay", qyweixin.Pay)
|
||||||
|
|
||||||
group.GET("/staff/salary", staff.Salary)
|
group.GET("/staff/salary", staff.Salary)
|
||||||
|
group.GET("/staff/salary/history", staff.SalaryHistory)
|
||||||
group.GET("/staff/sync/salary", staff.SyncStaffSalary)
|
group.GET("/staff/sync/salary", staff.SyncStaffSalary)
|
||||||
group.GET("/staff/sync/info", staff.SyncStaffInfo)
|
group.GET("/staff/sync/info", staff.SyncStaffInfo)
|
||||||
|
|
||||||
|
|
|
@ -27,9 +27,57 @@ var (
|
||||||
type StaffSalary struct {
|
type StaffSalary struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *StaffSalary) History(ctx *gin.Context) {
|
||||||
|
username := ctx.Query("username")
|
||||||
|
staffSalarys, err := dao.NewStaffSalaryDao().Query("", username)
|
||||||
|
if err != nil {
|
||||||
|
panic(config.ErrDb.New().Append(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
header := []string{"月份", "基本工资", "绩效工资", "出勤工资", "奖金", "社保扣除", "公积金扣除", "个税扣除", "应出勤天数", "实际出勤天数", "补卡天数", "请假天数", "实发工资"}
|
||||||
|
datas := make([][]string, 0)
|
||||||
|
|
||||||
|
for _, staff := range staffSalarys {
|
||||||
|
baseInfo, err := dao.NewStaffInfoDao().GetByUsername(staff.Username)
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("db error :%s", err.Error())
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if baseInfo == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
extra := make(map[string]interface{})
|
||||||
|
json.Unmarshal([]byte(staff.Extra), &extra)
|
||||||
|
item := make([]string, 0)
|
||||||
|
|
||||||
|
item = append(item, cast.ToString(staff.Month))
|
||||||
|
item = append(item, cast.ToString(staff.BaseSalary))
|
||||||
|
item = append(item, cast.ToString(butil.FloatCut(staff.PerfSalary)))
|
||||||
|
item = append(item, cast.ToString(butil.FloatCut(staff.AttendSalary)))
|
||||||
|
item = append(item, cast.ToString(butil.FloatCut(staff.AwardSalary)))
|
||||||
|
item = append(item, cast.ToString(staff.SocialInsurence))
|
||||||
|
item = append(item, cast.ToString(staff.HouseFund))
|
||||||
|
item = append(item, cast.ToString(staff.PersonalTax))
|
||||||
|
item = append(item, cast.ToString(staff.TotalDay))
|
||||||
|
item = append(item, cast.ToString(staff.RealDay))
|
||||||
|
|
||||||
|
item = append(item, cast.ToString(extra["approvalCheckinDay"]))
|
||||||
|
item = append(item, cast.ToString(staff.Holiday))
|
||||||
|
item = append(item, cast.ToString(staff.GetRealSalary()))
|
||||||
|
datas = append(datas, item)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.HTML(http.StatusOK, "salary.html", gin.H{
|
||||||
|
"title": username + "工资汇总",
|
||||||
|
"header": header,
|
||||||
|
"data": datas,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func (s *StaffSalary) Agent(month string, ctx *gin.Context) {
|
func (s *StaffSalary) Agent(month string, ctx *gin.Context) {
|
||||||
xls := ctx.Query("xls")
|
xls := ctx.Query("xls")
|
||||||
staffSalarys, err := dao.NewStaffSalaryDao().Query(month)
|
staffSalarys, err := dao.NewStaffSalaryDao().Query(month, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(config.ErrDb.New().Append(err))
|
panic(config.ErrDb.New().Append(err))
|
||||||
}
|
}
|
||||||
|
@ -49,6 +97,7 @@ func (s *StaffSalary) Agent(month string, ctx *gin.Context) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
item := make([]string, 0)
|
item := make([]string, 0)
|
||||||
|
|
||||||
item = append(item, baseInfo.Realname)
|
item = append(item, baseInfo.Realname)
|
||||||
item = append(item, cast.ToString(baseInfo.Idno))
|
item = append(item, cast.ToString(baseInfo.Idno))
|
||||||
item = append(item, cast.ToString(baseInfo.Phone))
|
item = append(item, cast.ToString(baseInfo.Phone))
|
||||||
|
@ -90,7 +139,7 @@ func (s *StaffSalary) Agent(month string, ctx *gin.Context) {
|
||||||
|
|
||||||
func (s *StaffSalary) Bank(month string, ctx *gin.Context) {
|
func (s *StaffSalary) Bank(month string, ctx *gin.Context) {
|
||||||
xls := ctx.Query("xls")
|
xls := ctx.Query("xls")
|
||||||
staffSalarys, err := dao.NewStaffSalaryDao().Query(month)
|
staffSalarys, err := dao.NewStaffSalaryDao().Query(month, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(config.ErrDb.New().Append(err))
|
panic(config.ErrDb.New().Append(err))
|
||||||
}
|
}
|
||||||
|
@ -148,7 +197,7 @@ func (s *StaffSalary) Bank(month string, ctx *gin.Context) {
|
||||||
|
|
||||||
func (s *StaffSalary) Summary(month string, ctx *gin.Context) {
|
func (s *StaffSalary) Summary(month string, ctx *gin.Context) {
|
||||||
xls := ctx.Query("xls")
|
xls := ctx.Query("xls")
|
||||||
staffSalarys, err := dao.NewStaffSalaryDao().Query(month)
|
staffSalarys, err := dao.NewStaffSalaryDao().Query(month, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(config.ErrDb.New().Append(err))
|
panic(config.ErrDb.New().Append(err))
|
||||||
}
|
}
|
||||||
|
@ -191,6 +240,7 @@ func (s *StaffSalary) Summary(month string, ctx *gin.Context) {
|
||||||
} else {
|
} else {
|
||||||
item = append(item, "")
|
item = append(item, "")
|
||||||
}
|
}
|
||||||
|
//item = append(item, fmt.Sprintf("https://e.batiao8.com/staff/salary/history?username=%s", baseInfo.Username))
|
||||||
|
|
||||||
datas = append(datas, item)
|
datas = append(datas, item)
|
||||||
summary.BaseSalary += staff.BaseSalary
|
summary.BaseSalary += staff.BaseSalary
|
||||||
|
|
|
@ -55,7 +55,7 @@ func (s *Staff) MontorWorkAge() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Staff) SendStaffSalaryBill(month string) {
|
func (s *Staff) SendStaffSalaryBill(month string) {
|
||||||
staffSalarys, err := dao.NewStaffSalaryDao().Query(month)
|
staffSalarys, err := dao.NewStaffSalaryDao().Query(month, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("db error :%s", err.Error())
|
log.Errorf("db error :%s", err.Error())
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue