This commit is contained in:
jiangyong27 2023-08-13 21:56:53 +08:00
parent 00346c2212
commit bd04e1b9f0
1 changed files with 18 additions and 3 deletions

View File

@ -75,7 +75,17 @@ func (a *Approve) handleRefund(spNo string) {
return
}
var refund model.ApprovalRefund
refund, err := dao.NewApprovalRefundDao().GetBySpNo(spNo)
if err != nil {
log.Errorf("db error :%s", err.Error())
return
}
isUpdate := true
if refund == nil {
refund = new(model.ApprovalRefund)
isUpdate = false
}
refund.Username = detail.Applyer.Userid
refund.SpNo = detail.SpNo
refund.ApplyTime = detail.ApplyTime
@ -104,7 +114,12 @@ func (a *Approve) handleRefund(spNo string) {
refund.RefundRemark = value
}
}
if _, err := dao.NewApprovalRefundDao().Create(&refund); err != nil {
if isUpdate {
err = dao.NewApprovalRefundDao().Update(refund)
} else {
_, err = dao.NewApprovalRefundDao().Create(refund)
}
if err != nil {
log.Errorf("db error :%s", err.Error())
return
}
@ -131,7 +146,7 @@ func (a *Approve) handleRefund(spNo string) {
}
refund.Status = model.ApprovalRefundStatusPayed
if err := dao.NewApprovalRefundDao().Update(&refund); err != nil {
if err := dao.NewApprovalRefundDao().Update(refund); err != nil {
log.Errorf("db error :%s", err.Error())
}
}