From 86a9c5fa693ca4aa81045a6dae6483b8f3fe57e5 Mon Sep 17 00:00:00 2001 From: saklani <50768838+saklani@users.noreply.github.com> Date: Wed, 21 Feb 2024 12:46:23 +0530 Subject: [PATCH] small idiomatic code fix --- wdb.go | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/wdb.go b/wdb.go index a2f07f5..5b6e1bb 100644 --- a/wdb.go +++ b/wdb.go @@ -91,19 +91,13 @@ func (w *Wdb) GetExpiredOrders() ([]schema.Order, error) { func (w *Wdb) ExistPaidOrd(itemId string) bool { ord := &schema.Order{} err := w.Db.Model(&schema.Order{}).Where("item_id = ? and payment_status = ?", itemId, schema.SuccPayment).First(ord).Error - if err == gorm.ErrRecordNotFound { - return false - } - return true + return err != gorm.ErrRecordNotFound } func (w *Wdb) IsLatestUnpaidOrd(itemId string, CurExpiredTime int64) bool { ord := &schema.Order{} err := w.Db.Model(&schema.Order{}).Where("item_id = ? and payment_status = ? and payment_expired_time > ?", itemId, schema.UnPayment, CurExpiredTime).First(ord).Error - if err == gorm.ErrRecordNotFound { - return true - } - return false + return err == gorm.ErrRecordNotFound } func (w *Wdb) UpdateOrdToExpiredStatus(id uint) error {