business_apply.go 758 B

123456789101112131415161718192021222324252627282930313233
  1. package models
  2. import "github.com/beego/beego/v2/client/orm"
  3. func BusinessTripApplyStatusOutTime(returnDate string) (err error) {
  4. o := orm.NewOrm()
  5. tx, err := o.Begin()
  6. if err != nil {
  7. return err
  8. }
  9. defer func() {
  10. if err != nil {
  11. tx.Rollback()
  12. } else {
  13. tx.Commit()
  14. }
  15. }()
  16. //客户产品状态变更
  17. sql := `UPDATE business_apply SET status='已过期',modify_time=NOW() WHERE status='待审批' AND arrive_date <= ? `
  18. _, err = tx.Raw(sql, returnDate).Exec()
  19. if err != nil {
  20. return
  21. }
  22. // 将历史的任务给标记删除掉
  23. sql = `UPDATE business_apply_peer SET status='已过期',modify_time=NOW() WHERE status='待审批' AND arrive_date <= ? `
  24. _, err = tx.Raw(sql, returnDate).Exec()
  25. if err != nil {
  26. return
  27. }
  28. return
  29. }