corpid
This commit is contained in:
parent
f3cc2dc3aa
commit
21965eca8b
|
@ -0,0 +1,51 @@
|
||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"enterprise/common/model"
|
||||||
|
"gorm.io/gorm"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type CorpDao struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewCorpDao() *CorpDao {
|
||||||
|
return &CorpDao{}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *CorpDao) TableName() string {
|
||||||
|
return "corp"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *CorpDao) Create(o *model.Corp) (int64, error) {
|
||||||
|
o.CreateTime = time.Now().Unix()
|
||||||
|
res := GetDB().Table(d.TableName()).Create(o)
|
||||||
|
return o.Id, res.Error
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *CorpDao) Update(o *model.Corp) error {
|
||||||
|
o.UpdateTime = time.Now().Unix()
|
||||||
|
tx := GetDB().Table(d.TableName())
|
||||||
|
res := tx.Save(o)
|
||||||
|
return res.Error
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *CorpDao) Delete(id int64) error {
|
||||||
|
res := GetDB().Table(d.TableName()).Delete(&model.Corp{}, id)
|
||||||
|
return res.Error
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *CorpDao) Get(id int64) (*model.Corp, error) {
|
||||||
|
var u model.Corp
|
||||||
|
tx := GetDB().Table(d.TableName())
|
||||||
|
tx = tx.Where("id = ?", id)
|
||||||
|
res := tx.First(&u)
|
||||||
|
if res.Error == gorm.ErrRecordNotFound {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if res.Error != nil {
|
||||||
|
return nil, res.Error
|
||||||
|
}
|
||||||
|
return &u, nil
|
||||||
|
}
|
|
@ -27,6 +27,7 @@ type UsernameCount struct {
|
||||||
|
|
||||||
type ApprovalCheckin struct {
|
type ApprovalCheckin struct {
|
||||||
Id int64
|
Id int64
|
||||||
|
CorpId int64
|
||||||
Username string
|
Username string
|
||||||
Month string
|
Month string
|
||||||
SpNo string
|
SpNo string
|
||||||
|
|
|
@ -10,6 +10,7 @@ import (
|
||||||
|
|
||||||
type ApprovalPayment struct {
|
type ApprovalPayment struct {
|
||||||
Id int64
|
Id int64
|
||||||
|
CorpId int64
|
||||||
Username string
|
Username string
|
||||||
Month string
|
Month string
|
||||||
SpNo string
|
SpNo string
|
||||||
|
|
|
@ -13,15 +13,12 @@ var (
|
||||||
ApprovalTypeRefund = "refund"
|
ApprovalTypeRefund = "refund"
|
||||||
ApprovalTypeCheckin = "checkin"
|
ApprovalTypeCheckin = "checkin"
|
||||||
ApprovalTypeVacation = "vacation"
|
ApprovalTypeVacation = "vacation"
|
||||||
|
ApprovalTypePayment = "payment"
|
||||||
ApprovalTpIdCheckin = "C4UCJS891Afmu1rE1Ws6cvph7YHqebWtt7KRFqh8c"
|
|
||||||
ApprovalTpIdRefund = "C4UE6NT3ZE7XzER9TBk2ynHEeqA11NE2GGCuBq5yH"
|
|
||||||
ApprovalTpIdVacation = "3WLJF6naF5jhnXvwisuPmE85wVMYcy1S1ZvYibkw"
|
|
||||||
ApprovalTpIdPayment = "C4WqcQBRQZoB5d15uKtjwuG6k32mc7ykJYuLF1ois"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type ApprovalRefund struct {
|
type ApprovalRefund struct {
|
||||||
Id int64
|
Id int64
|
||||||
|
CorpId int64
|
||||||
Username string
|
Username string
|
||||||
Month string
|
Month string
|
||||||
SpNo string
|
SpNo string
|
||||||
|
|
|
@ -12,6 +12,7 @@ var ()
|
||||||
|
|
||||||
type ApprovalVacation struct {
|
type ApprovalVacation struct {
|
||||||
Id int64
|
Id int64
|
||||||
|
CorpId int64
|
||||||
Username string
|
Username string
|
||||||
Month string
|
Month string
|
||||||
SpNo string
|
SpNo string
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
package model
|
||||||
|
|
||||||
|
import "encoding/json"
|
||||||
|
|
||||||
|
type CorpConfig struct {
|
||||||
|
CorpId string `json:"corpid"`
|
||||||
|
EnterpriseAgent string `json:"enterprise_agent"`
|
||||||
|
EnterpriseSecret string `json:"enterprise_secret"`
|
||||||
|
ApproveAgent string `json:"approve_agent"`
|
||||||
|
ApproveSecret string `json:"approve_secret"`
|
||||||
|
PaySecret string `json:"pay_secret"`
|
||||||
|
PayAgent string `json:"pay_agent"`
|
||||||
|
TplIdCheckin string `json:"tplid_checkin"`
|
||||||
|
TplIdRefund string `json:"tplid_refund"`
|
||||||
|
TplIdVacation string `json:"tplid_vacation"`
|
||||||
|
TplIdPayment string `json:"tplid_payment"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Corp struct {
|
||||||
|
Id int64
|
||||||
|
Name string
|
||||||
|
Config string
|
||||||
|
CreateTime int64
|
||||||
|
UpdateTime int64
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Corp) GetConfig() *CorpConfig {
|
||||||
|
var cfg CorpConfig
|
||||||
|
json.Unmarshal([]byte(c.Config), &cfg)
|
||||||
|
|
||||||
|
return &cfg
|
||||||
|
}
|
|
@ -23,14 +23,6 @@ addr="127.0.0.1:6379"
|
||||||
db=0
|
db=0
|
||||||
password=""
|
password=""
|
||||||
|
|
||||||
[qyweixin]
|
|
||||||
corpid = "ww43c49db2e88a17f8"
|
|
||||||
enterprise_agent = "1000009"
|
|
||||||
enterprise_secret = "oMB24UhKe50-XPTg7vhnwoTuhEXaq5XeiHPAUtF4hOs"
|
|
||||||
approve_agent = "3010040"
|
|
||||||
approve_secret = "xJOClC5V2pPon1azgrAzf5kq1TB72xZ3ScR7O5G3lQo"
|
|
||||||
pay_secret = "JCGsxntR4E7wrEEQvWGr8_wdKtRlw48n-W6zd8lbwc4"
|
|
||||||
pay_agent = "3010046"
|
|
||||||
|
|
||||||
|
|
||||||
[wxpay]
|
[wxpay]
|
||||||
|
|
|
@ -2,6 +2,7 @@ package controller
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"enterprise/common/config"
|
"enterprise/common/config"
|
||||||
|
"enterprise/common/dao"
|
||||||
"enterprise/common/global"
|
"enterprise/common/global"
|
||||||
"enterprise/server/service"
|
"enterprise/server/service"
|
||||||
"enterprise/server/session"
|
"enterprise/server/session"
|
||||||
|
@ -21,8 +22,10 @@ type QyWeixin struct {
|
||||||
|
|
||||||
func (q *QyWeixin) Approve(ctx *gin.Context) {
|
func (q *QyWeixin) Approve(ctx *gin.Context) {
|
||||||
cfg := config.GetConfig()
|
cfg := config.GetConfig()
|
||||||
|
cid := cast.ToInt64(ctx.Param("cid"))
|
||||||
|
|
||||||
reply := new(service.Approve).Reply
|
approve := service.NewApprove(cid)
|
||||||
|
reply := approve.Reply
|
||||||
qyApp := qyweixin.NewApp(&qyweixin.AppConfig{
|
qyApp := qyweixin.NewApp(&qyweixin.AppConfig{
|
||||||
Corpid: cfg.QyWeixin.Corpid,
|
Corpid: cfg.QyWeixin.Corpid,
|
||||||
Secret: cfg.QyWeixin.ApproveSecret,
|
Secret: cfg.QyWeixin.ApproveSecret,
|
||||||
|
@ -36,6 +39,7 @@ func (q *QyWeixin) Approve(ctx *gin.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *QyWeixin) Pay(ctx *gin.Context) {
|
func (q *QyWeixin) Pay(ctx *gin.Context) {
|
||||||
|
cid := cast.ToInt64(ctx.Param("cid"))
|
||||||
userid := ctx.Query("userid")
|
userid := ctx.Query("userid")
|
||||||
amount := cast.ToInt64(ctx.Query("amount"))
|
amount := cast.ToInt64(ctx.Query("amount"))
|
||||||
title := ctx.Query("title")
|
title := ctx.Query("title")
|
||||||
|
@ -43,11 +47,21 @@ func (q *QyWeixin) Pay(ctx *gin.Context) {
|
||||||
if pass != "1c9dea1fb85cf06ab0b4d946d49aa92f" {
|
if pass != "1c9dea1fb85cf06ab0b4d946d49aa92f" {
|
||||||
panic("password error")
|
panic("password error")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
corp, err := dao.NewCorpDao().Get(cid)
|
||||||
|
if err != nil {
|
||||||
|
panic(config.ErrDb.New().Append(err))
|
||||||
|
}
|
||||||
|
if corp == nil {
|
||||||
|
panic(config.ErrInternal.New())
|
||||||
|
}
|
||||||
|
cfg := corp.GetConfig()
|
||||||
|
|
||||||
// 获取openid
|
// 获取openid
|
||||||
approve := qyweixin.NewAppApprove(&qyweixin.AppConfig{
|
approve := qyweixin.NewAppApprove(&qyweixin.AppConfig{
|
||||||
Corpid: config.GetConfig().QyWeixin.Corpid,
|
Corpid: cfg.CorpId,
|
||||||
Secret: config.GetConfig().QyWeixin.EnterpriseSecret,
|
Secret: cfg.EnterpriseSecret,
|
||||||
Agent: config.GetConfig().QyWeixin.EnterpriseAgent,
|
Agent: cfg.EnterpriseAgent,
|
||||||
})
|
})
|
||||||
openid, err := approve.GetOpenid(userid)
|
openid, err := approve.GetOpenid(userid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -61,9 +75,9 @@ func (q *QyWeixin) Pay(ctx *gin.Context) {
|
||||||
req.Openid = openid
|
req.Openid = openid
|
||||||
req.TotalAmount = amount
|
req.TotalAmount = amount
|
||||||
qyPay := qyweixin.NewAppPay(&qyweixin.PayConfig{
|
qyPay := qyweixin.NewAppPay(&qyweixin.PayConfig{
|
||||||
Corpid: config.GetConfig().QyWeixin.Corpid,
|
Corpid: cfg.CorpId,
|
||||||
Secret: config.GetConfig().QyWeixin.PaySecret,
|
Secret: cfg.PaySecret,
|
||||||
Agent: config.GetConfig().QyWeixin.PayAgent,
|
Agent: cfg.PayAgent,
|
||||||
SerialNumber: config.GetConfig().WxPay.PaySerialNumber,
|
SerialNumber: config.GetConfig().WxPay.PaySerialNumber,
|
||||||
ApiKey: config.GetConfig().WxPay.PayApiKeyV2,
|
ApiKey: config.GetConfig().WxPay.PayApiKeyV2,
|
||||||
MchId: config.GetConfig().WxPay.PayMchId,
|
MchId: config.GetConfig().WxPay.PayMchId,
|
||||||
|
|
|
@ -14,8 +14,8 @@ func initRoutge(engine *gin.Engine) {
|
||||||
group := engine.Group("/")
|
group := engine.Group("/")
|
||||||
apiGroup.Use(base.Recovery)
|
apiGroup.Use(base.Recovery)
|
||||||
group.Use(base.Recovery)
|
group.Use(base.Recovery)
|
||||||
apiGroup.Any("/qyweixin/approve", qyweixin.Approve)
|
apiGroup.Any("/qyweixin/approve/:cid", qyweixin.Approve)
|
||||||
apiGroup.Any("/qyweixin/pay", qyweixin.Pay)
|
apiGroup.Any("/qyweixin/pay/:cid", qyweixin.Pay)
|
||||||
|
|
||||||
group.GET("/staff/salary", staff.Salary)
|
group.GET("/staff/salary", staff.Salary)
|
||||||
group.GET("/staff/salary/history", staff.SalaryHistory)
|
group.GET("/staff/salary/history", staff.SalaryHistory)
|
||||||
|
|
|
@ -19,23 +19,33 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
SpStatusCreated = 1
|
SpStatusCreated = 1
|
||||||
SpStatusPassed = 2
|
SpStatusPassed = 2
|
||||||
SpStatusRefused = 3
|
SpStatusRefused = 3
|
||||||
SpStatusCanceled = 4
|
SpStatusCanceled = 4
|
||||||
|
SpStatusPassedCanceled = 6
|
||||||
)
|
)
|
||||||
|
|
||||||
type Approve struct {
|
type Approve struct {
|
||||||
|
corp *model.Corp
|
||||||
|
corpConfig *model.CorpConfig
|
||||||
approveClient *qyweixin.AppApprove
|
approveClient *qyweixin.AppApprove
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewApprove(cid int64) *Approve {
|
||||||
|
corp, _ := dao.NewCorpDao().Get(cid)
|
||||||
|
return &Approve{
|
||||||
|
corp: corp,
|
||||||
|
corpConfig: corp.GetConfig(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (b *Approve) Reply(msg message.MixMessage) *message.Reply {
|
func (b *Approve) Reply(msg message.MixMessage) *message.Reply {
|
||||||
if b.approveClient == nil {
|
if b.approveClient == nil {
|
||||||
cfg := config.GetConfig()
|
|
||||||
b.approveClient = qyweixin.NewAppApprove(&qyweixin.AppConfig{
|
b.approveClient = qyweixin.NewAppApprove(&qyweixin.AppConfig{
|
||||||
Corpid: cfg.QyWeixin.Corpid,
|
Corpid: b.corpConfig.CorpId,
|
||||||
Secret: cfg.QyWeixin.ApproveSecret,
|
Secret: b.corpConfig.ApproveSecret,
|
||||||
Agent: cfg.QyWeixin.ApproveAgent,
|
Agent: b.corpConfig.ApproveAgent,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
go b.handle(&msg)
|
go b.handle(&msg)
|
||||||
|
@ -63,6 +73,8 @@ func (a *Approve) handleApprovalChange(msg *message.MixMessage) {
|
||||||
spStatus := msg.ApprovalInfo.SpStatus
|
spStatus := msg.ApprovalInfo.SpStatus
|
||||||
spNo := msg.ApprovalInfo.SpNo
|
spNo := msg.ApprovalInfo.SpNo
|
||||||
templateId := msg.ApprovalInfo.TemplateId
|
templateId := msg.ApprovalInfo.TemplateId
|
||||||
|
|
||||||
|
// && spStatus != SpStatusPassedCanceled
|
||||||
if spStatus != SpStatusPassed {
|
if spStatus != SpStatusPassed {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -74,13 +86,13 @@ func (a *Approve) handleApprovalChange(msg *message.MixMessage) {
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Infof("spno: %s detail: %s", spNo, goutil.EncodeJSON(detail))
|
log.Infof("spno: %s detail: %s", spNo, goutil.EncodeJSON(detail))
|
||||||
if templateId == model.ApprovalTpIdRefund {
|
if templateId == a.corpConfig.TplIdRefund {
|
||||||
a.handleRefund(detail)
|
a.handleRefund(detail)
|
||||||
} else if templateId == model.ApprovalTpIdVacation {
|
} else if templateId == a.corpConfig.TplIdVacation {
|
||||||
a.handleVacation(detail)
|
a.handleVacation(detail)
|
||||||
} else if templateId == model.ApprovalTpIdCheckin {
|
} else if templateId == a.corpConfig.TplIdCheckin {
|
||||||
a.handleCheckin(detail)
|
a.handleCheckin(detail)
|
||||||
} else if templateId == model.ApprovalTpIdPayment {
|
} else if templateId == a.corpConfig.TplIdPayment {
|
||||||
a.handlePayment(detail)
|
a.handlePayment(detail)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -88,6 +100,7 @@ func (a *Approve) handleApprovalChange(msg *message.MixMessage) {
|
||||||
func (a *Approve) handlePayment(detail *qyweixin.ApproveDetail) {
|
func (a *Approve) handlePayment(detail *qyweixin.ApproveDetail) {
|
||||||
newData := new(model.ApprovalPayment)
|
newData := new(model.ApprovalPayment)
|
||||||
newData.From(detail)
|
newData.From(detail)
|
||||||
|
newData.CorpId = a.corp.Id
|
||||||
dbDao := dao.NewApprovalPaymentDao()
|
dbDao := dao.NewApprovalPaymentDao()
|
||||||
|
|
||||||
old, err := dbDao.GetBySpNo(detail.SpNo)
|
old, err := dbDao.GetBySpNo(detail.SpNo)
|
||||||
|
@ -112,6 +125,7 @@ func (a *Approve) handlePayment(detail *qyweixin.ApproveDetail) {
|
||||||
func (a *Approve) handleVacation(detail *qyweixin.ApproveDetail) {
|
func (a *Approve) handleVacation(detail *qyweixin.ApproveDetail) {
|
||||||
newData := new(model.ApprovalVacation)
|
newData := new(model.ApprovalVacation)
|
||||||
newData.From(detail)
|
newData.From(detail)
|
||||||
|
newData.CorpId = a.corp.Id
|
||||||
dbDao := dao.NewApprovalVacationDao()
|
dbDao := dao.NewApprovalVacationDao()
|
||||||
|
|
||||||
old, err := dbDao.GetBySpNo(detail.SpNo)
|
old, err := dbDao.GetBySpNo(detail.SpNo)
|
||||||
|
@ -136,6 +150,7 @@ func (a *Approve) handleVacation(detail *qyweixin.ApproveDetail) {
|
||||||
func (a *Approve) handleCheckin(detail *qyweixin.ApproveDetail) {
|
func (a *Approve) handleCheckin(detail *qyweixin.ApproveDetail) {
|
||||||
newData := new(model.ApprovalCheckin)
|
newData := new(model.ApprovalCheckin)
|
||||||
newData.From(detail)
|
newData.From(detail)
|
||||||
|
newData.CorpId = a.corp.Id
|
||||||
dbDao := dao.NewApprovalCheckinDao()
|
dbDao := dao.NewApprovalCheckinDao()
|
||||||
|
|
||||||
old, err := dbDao.GetBySpNo(detail.SpNo)
|
old, err := dbDao.GetBySpNo(detail.SpNo)
|
||||||
|
@ -170,9 +185,9 @@ func (a *Approve) handleRefundWxpay(data *model.ApprovalRefund) error {
|
||||||
req.Openid = openid
|
req.Openid = openid
|
||||||
req.TotalAmount = int64(100 * data.RefundAmount)
|
req.TotalAmount = int64(100 * data.RefundAmount)
|
||||||
qyPay := qyweixin.NewAppPay(&qyweixin.PayConfig{
|
qyPay := qyweixin.NewAppPay(&qyweixin.PayConfig{
|
||||||
Corpid: config.GetConfig().QyWeixin.Corpid,
|
Corpid: a.corpConfig.CorpId,
|
||||||
Secret: config.GetConfig().QyWeixin.PaySecret,
|
Secret: a.corpConfig.PaySecret,
|
||||||
Agent: config.GetConfig().QyWeixin.PayAgent,
|
Agent: a.corpConfig.PayAgent,
|
||||||
SerialNumber: config.GetConfig().WxPay.PaySerialNumber,
|
SerialNumber: config.GetConfig().WxPay.PaySerialNumber,
|
||||||
ApiKey: config.GetConfig().WxPay.PayApiKeyV2,
|
ApiKey: config.GetConfig().WxPay.PayApiKeyV2,
|
||||||
MchId: config.GetConfig().WxPay.PayMchId,
|
MchId: config.GetConfig().WxPay.PayMchId,
|
||||||
|
@ -215,6 +230,7 @@ func (a *Approve) handleRefundAlipay(staff *model.StaffInfo, data *model.Approva
|
||||||
func (a *Approve) handleRefund(detail *qyweixin.ApproveDetail) {
|
func (a *Approve) handleRefund(detail *qyweixin.ApproveDetail) {
|
||||||
newData := new(model.ApprovalRefund)
|
newData := new(model.ApprovalRefund)
|
||||||
newData.From(detail)
|
newData.From(detail)
|
||||||
|
newData.CorpId = a.corp.Id
|
||||||
dbDao := dao.NewApprovalRefundDao()
|
dbDao := dao.NewApprovalRefundDao()
|
||||||
|
|
||||||
old, err := dbDao.GetBySpNo(detail.SpNo)
|
old, err := dbDao.GetBySpNo(detail.SpNo)
|
||||||
|
@ -235,6 +251,10 @@ func (a *Approve) handleRefund(detail *qyweixin.ApproveDetail) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//只有八条科技才自动付款
|
||||||
|
if a.corp.Id != 1000 {
|
||||||
|
return
|
||||||
|
}
|
||||||
staff, err := dao.NewStaffInfoDao().GetByUsername(newData.Username)
|
staff, err := dao.NewStaffInfoDao().GetByUsername(newData.Username)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("db error :%s", err.Error())
|
log.Errorf("db error :%s", err.Error())
|
||||||
|
|
|
@ -10,15 +10,25 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type Approval struct {
|
type Approval struct {
|
||||||
|
corp *model.Corp
|
||||||
|
corpConfig *model.CorpConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewApproval(corp *model.Corp) *Approval {
|
||||||
|
return &Approval{
|
||||||
|
corp: corp,
|
||||||
|
corpConfig: corp.GetConfig(),
|
||||||
|
}
|
||||||
|
}
|
||||||
func (s *Approval) getTemplateId(tp string) string {
|
func (s *Approval) getTemplateId(tp string) string {
|
||||||
if tp == model.ApprovalTypeCheckin {
|
if tp == model.ApprovalTypeCheckin {
|
||||||
return model.ApprovalTpIdCheckin
|
return s.corpConfig.TplIdCheckin
|
||||||
} else if tp == model.ApprovalTypeRefund {
|
} else if tp == model.ApprovalTypeRefund {
|
||||||
return model.ApprovalTpIdRefund
|
return s.corpConfig.TplIdRefund
|
||||||
} else if tp == model.ApprovalTypeVacation {
|
} else if tp == model.ApprovalTypeVacation {
|
||||||
return model.ApprovalTpIdVacation
|
return s.corpConfig.TplIdVacation
|
||||||
|
} else if tp == model.ApprovalTypePayment {
|
||||||
|
return s.corpConfig.TplIdPayment
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
@ -50,6 +60,8 @@ func (s *Approval) Sync(month, tp string) {
|
||||||
s.saveRefund(detail)
|
s.saveRefund(detail)
|
||||||
} else if tp == model.ApprovalTypeVacation {
|
} else if tp == model.ApprovalTypeVacation {
|
||||||
s.saveVacation(detail)
|
s.saveVacation(detail)
|
||||||
|
} else if tp == model.ApprovalTypePayment {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package worker
|
package worker
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"enterprise/common/dao"
|
||||||
"enterprise/common/model"
|
"enterprise/common/model"
|
||||||
"github.com/go-co-op/gocron"
|
"github.com/go-co-op/gocron"
|
||||||
"time"
|
"time"
|
||||||
|
@ -11,7 +12,6 @@ func Init() error {
|
||||||
cron := gocron.NewScheduler(timezone)
|
cron := gocron.NewScheduler(timezone)
|
||||||
staff := new(Staff)
|
staff := new(Staff)
|
||||||
checkIn := new(Checkin)
|
checkIn := new(Checkin)
|
||||||
approve := new(Approval)
|
|
||||||
|
|
||||||
// 每天同步企业人事信息
|
// 每天同步企业人事信息
|
||||||
cron.Every(1).Day().At("01:00").Do(func() {
|
cron.Every(1).Day().At("01:00").Do(func() {
|
||||||
|
@ -33,9 +33,13 @@ func Init() error {
|
||||||
cron.Every(1).Month(1).At("05:30").Do(func() {
|
cron.Every(1).Month(1).At("05:30").Do(func() {
|
||||||
lastMonth := time.Now().AddDate(0, -1, 0).Format("200601")
|
lastMonth := time.Now().AddDate(0, -1, 0).Format("200601")
|
||||||
checkIn.SyncCheckinMonth("")
|
checkIn.SyncCheckinMonth("")
|
||||||
|
|
||||||
|
corp, _ := dao.NewCorpDao().Get(1000)
|
||||||
|
approve := NewApproval(corp)
|
||||||
approve.Sync(lastMonth, model.ApprovalTypeCheckin)
|
approve.Sync(lastMonth, model.ApprovalTypeCheckin)
|
||||||
approve.Sync(lastMonth, model.ApprovalTypeVacation)
|
approve.Sync(lastMonth, model.ApprovalTypeVacation)
|
||||||
approve.Sync(lastMonth, model.ApprovalTypeRefund)
|
approve.Sync(lastMonth, model.ApprovalTypeRefund)
|
||||||
|
approve.Sync(lastMonth, model.ApprovalTypePayment)
|
||||||
})
|
})
|
||||||
|
|
||||||
// 1号计算工资信息
|
// 1号计算工资信息
|
||||||
|
|
Loading…
Reference in New Issue