This commit is contained in:
jiangyong27 2024-01-22 23:06:30 +08:00
parent c8634d17f9
commit 74c4076714
5 changed files with 79 additions and 48 deletions

View File

@ -1,5 +1,25 @@
package model
import (
"github.com/smbrave/goutil"
"github.com/spf13/cast"
"gitlab.batiao8.com/open/gosdk/qyweixin"
"strings"
"time"
)
func (ac *ApprovalCheckin) From(d *qyweixin.ApproveDetail) {
value := strings.SplitN(d.GetValue("补卡"), ",", 3)
ac.SpNo = d.SpNo
ac.Username = d.GetUserid()
ac.ApplyTime = goutil.TimeToDateTime(d.ApplyTime)
ac.CheckinRemark = d.GetValue("补卡事由")
ac.CheckinDate = goutil.TimeToDate(cast.ToInt64(value[0]))
ac.Month = time.Unix(cast.ToInt64(value[0]), 0).Format("200601")
ac.CheckinTime = goutil.TimeToDateTime(cast.ToInt64(value[1]))
ac.CheckinType = value[2]
}
type ApprovalCheckin struct {
Id int64
Username string

View File

@ -1,5 +1,12 @@
package model
import (
"github.com/smbrave/goutil"
"github.com/spf13/cast"
"gitlab.batiao8.com/open/gosdk/qyweixin"
"time"
)
var (
ApprovalRefundStatusCreated = 1
ApprovalRefundStatusPayed = 2
@ -26,3 +33,16 @@ type ApprovalRefund struct {
CreateTime int64
UpdateTime int64
}
func (refund *ApprovalRefund) From(d *qyweixin.ApproveDetail) {
refund.SpNo = d.SpNo
refund.Username = d.GetUserid()
refund.ApplyTime = goutil.TimeToDateTime(d.ApplyTime)
refund.Status = ApprovalRefundStatusCreated
refund.RefundType = d.GetValue("报销类型")
refundTime := cast.ToInt64(d.GetValue("发生时间"))
refund.Month = time.Unix(refundTime, 0).Format("200601")
refund.RefundDate = goutil.TimeToDateTime(refundTime)
refund.RefundAmount = cast.ToFloat64(d.GetValue("报销费用"))
refund.RefundRemark = d.GetValue("报销说明")
}

View File

@ -1,5 +1,13 @@
package model
import (
"github.com/smbrave/goutil"
"github.com/spf13/cast"
"gitlab.batiao8.com/open/gosdk/qyweixin"
"strings"
"time"
)
var ()
type ApprovalVacation struct {
@ -17,3 +25,19 @@ type ApprovalVacation struct {
CreateTime int64
UpdateTime int64
}
func (vacation *ApprovalVacation) From(d *qyweixin.ApproveDetail) {
vacation.SpNo = d.SpNo
vacation.Username = d.GetUserid()
vacation.ApplyTime = goutil.TimeToDateTime(d.ApplyTime)
fields := strings.SplitN(d.GetValue("请假类型"), ",", 4)
dTime := cast.ToInt64(fields[1])
vacation.VacationType = fields[0]
vacation.VacationDate = goutil.TimeToDate(dTime)
vacation.VacationStartTime = goutil.TimeToDateTime(cast.ToInt64(fields[1]))
vacation.VacationEndTime = goutil.TimeToDateTime(cast.ToInt64(fields[2]))
vacation.VacationDuration = float64(cast.ToInt64(fields[3])) / float64(3600*8)
vacation.VacationRemark = d.GetValue("请假事由")
vacation.Month = time.Unix(dTime, 0).Format("200601")
}

View File

@ -6,7 +6,6 @@ import (
"enterprise/common/dao"
"enterprise/common/global"
"enterprise/common/model"
"enterprise/common/weixin"
"fmt"
log "github.com/sirupsen/logrus"
"github.com/smbrave/goutil"
@ -23,13 +22,17 @@ var (
)
type Approve struct {
approveClient *weixin.QyWeixinApprove
approveClient *qyweixin.AppApprove
}
func (b *Approve) Reply(msg message.MixMessage) *message.Reply {
if b.approveClient == nil {
cfg := config.GetConfig()
b.approveClient = weixin.NewQyWeixinApprove(cfg.QyWeixin.Corpid, cfg.QyWeixin.ApproveSecret, cfg.QyWeixin.ApproveAgent)
b.approveClient = qyweixin.NewAppApprove(&qyweixin.AppConfig{
Corpid: cfg.QyWeixin.Corpid,
Secret: cfg.QyWeixin.ApproveSecret,
Agent: cfg.QyWeixin.ApproveAgent,
})
}
go b.handle(&msg)
return &message.Reply{message.MsgTypeText, message.NewText("")}
@ -74,8 +77,9 @@ func (a *Approve) handleApprovalChange(msg *message.MixMessage) {
}
}
func (a *Approve) handleVacation(detail *weixin.ApproveDetail) {
newData := detail.ToVacation()
func (a *Approve) handleVacation(detail *qyweixin.ApproveDetail) {
newData := new(model.ApprovalVacation)
newData.From(detail)
dbDao := dao.NewApprovalVacationDao()
old, err := dbDao.GetBySpNo(detail.SpNo)
@ -97,8 +101,9 @@ func (a *Approve) handleVacation(detail *weixin.ApproveDetail) {
}
}
func (a *Approve) handleCheckin(detail *weixin.ApproveDetail) {
newData := detail.ToCheckin()
func (a *Approve) handleCheckin(detail *qyweixin.ApproveDetail) {
newData := new(model.ApprovalCheckin)
newData.From(detail)
dbDao := dao.NewApprovalCheckinDao()
old, err := dbDao.GetBySpNo(detail.SpNo)
@ -119,8 +124,9 @@ func (a *Approve) handleCheckin(detail *weixin.ApproveDetail) {
return
}
}
func (a *Approve) handleRefund(detail *weixin.ApproveDetail) {
newData := detail.ToRefund()
func (a *Approve) handleRefund(detail *qyweixin.ApproveDetail) {
newData := new(model.ApprovalRefund)
newData.From(detail)
dbDao := dao.NewApprovalRefundDao()
old, err := dbDao.GetBySpNo(detail.SpNo)

View File

@ -1,39 +0,0 @@
package service
import (
"enterprise/common/weixin"
"fmt"
log "github.com/sirupsen/logrus"
"testing"
)
func TestApprove_Reply(t *testing.T) {
approveClient := weixin.NewQyWeixinApprove("ww43c49db2e88a17f8", "xJOClC5V2pPon1azgrAzf5kq1TB72xZ3ScR7O5G3lQo", "3010040")
fmt.Println("1")
detail, err := approveClient.GetDetail("202308130004")
fmt.Println("1")
if err != nil {
log.Errorf("error:%s", err.Error())
}
fmt.Println("1")
for _, content := range detail.ApplyData.Contents {
var value string
if content.Control == "Selector" {
value = content.Value.Selector.Options[0].Value[0].Text
} else if content.Control == "Text" || content.Control == "Textarea" {
value = content.Value.Text
} else if content.Control == "Date" {
value = content.Value.Date.Timestamp
} else if content.Control == "Money" {
value = content.Value.NewMoney
} else if content.Control == "File" {
value = content.Value.Files[0].FileId
}
fmt.Println(content.Title[0].Text, value)
}
fmt.Println("2")
}