From 566a03e1e3533a334fe6b8ecaf38a3c7991dc8ac Mon Sep 17 00:00:00 2001 From: jiangyong27 Date: Wed, 8 Jan 2025 12:48:43 +0800 Subject: [PATCH] delete approval --- server/service/qyweixin_approve.go | 52 ++++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 10 deletions(-) diff --git a/server/service/qyweixin_approve.go b/server/service/qyweixin_approve.go index 8923fc3..1654335 100644 --- a/server/service/qyweixin_approve.go +++ b/server/service/qyweixin_approve.go @@ -74,8 +74,8 @@ func (a *Approve) handleApprovalChange(msg *message.MixMessage) { spNo := msg.ApprovalInfo.SpNo templateId := msg.ApprovalInfo.TemplateId - // && spStatus != SpStatusPassedCanceled - if spStatus != SpStatusPassed { + // 支出里审批通过的 或者审批通过撤销的 + if spStatus != SpStatusPassed && spStatus != SpStatusPassedCanceled { return } @@ -87,17 +87,17 @@ func (a *Approve) handleApprovalChange(msg *message.MixMessage) { log.Infof("spno: %s detail: %s", spNo, goutil.EncodeJSON(detail)) if templateId == a.corpConfig.TplIdRefund { - a.handleRefund(detail) + a.handleRefund(detail, spStatus) } else if templateId == a.corpConfig.TplIdVacation { - a.handleVacation(detail) + a.handleVacation(detail, spStatus) } else if templateId == a.corpConfig.TplIdCheckin { - a.handleCheckin(detail) + a.handleCheckin(detail, spStatus) } else if templateId == a.corpConfig.TplIdPayment { - a.handlePayment(detail) + a.handlePayment(detail, spStatus) } } -func (a *Approve) handlePayment(detail *qyweixin.ApproveDetail) { +func (a *Approve) handlePayment(detail *qyweixin.ApproveDetail, spStatus int) { newData := new(model.ApprovalPayment) newData.From(detail) newData.CorpId = a.corp.Id @@ -108,6 +108,14 @@ func (a *Approve) handlePayment(detail *qyweixin.ApproveDetail) { log.Errorf("db error :%s", err.Error()) return } + + if spStatus == SpStatusPassedCanceled { + if old != nil { + dbDao.Delete(old.Id) + } + return + } + if old != nil { newData.Id = old.Id newData.CreateTime = old.CreateTime @@ -122,7 +130,7 @@ func (a *Approve) handlePayment(detail *qyweixin.ApproveDetail) { } } -func (a *Approve) handleVacation(detail *qyweixin.ApproveDetail) { +func (a *Approve) handleVacation(detail *qyweixin.ApproveDetail, spStatus int) { newData := new(model.ApprovalVacation) newData.From(detail) newData.CorpId = a.corp.Id @@ -133,6 +141,14 @@ func (a *Approve) handleVacation(detail *qyweixin.ApproveDetail) { log.Errorf("db error :%s", err.Error()) return } + + if spStatus == SpStatusPassedCanceled { + if old != nil { + dbDao.Delete(old.Id) + } + return + } + if old != nil { newData.Id = old.Id newData.CreateTime = old.CreateTime @@ -147,7 +163,7 @@ func (a *Approve) handleVacation(detail *qyweixin.ApproveDetail) { } } -func (a *Approve) handleCheckin(detail *qyweixin.ApproveDetail) { +func (a *Approve) handleCheckin(detail *qyweixin.ApproveDetail, spStatus int) { newData := new(model.ApprovalCheckin) newData.From(detail) newData.CorpId = a.corp.Id @@ -158,6 +174,14 @@ func (a *Approve) handleCheckin(detail *qyweixin.ApproveDetail) { log.Errorf("db error :%s", err.Error()) return } + + if spStatus == SpStatusPassedCanceled { + if old != nil { + dbDao.Delete(old.Id) + } + return + } + if old != nil { newData.Id = old.Id newData.CreateTime = old.CreateTime @@ -227,7 +251,7 @@ func (a *Approve) handleRefundAlipay(staff *model.StaffInfo, data *model.Approva return nil } -func (a *Approve) handleRefund(detail *qyweixin.ApproveDetail) { +func (a *Approve) handleRefund(detail *qyweixin.ApproveDetail, spStatus int) { newData := new(model.ApprovalRefund) newData.From(detail) newData.CorpId = a.corp.Id @@ -238,6 +262,14 @@ func (a *Approve) handleRefund(detail *qyweixin.ApproveDetail) { log.Errorf("db error :%s", err.Error()) return } + + if spStatus == SpStatusPassedCanceled { + if old != nil { + dbDao.Delete(old.Id) + } + return + } + if old != nil { newData.Id = old.Id newData.CreateTime = old.CreateTime