Skip to content

Commit 0c91349

Browse files
Merge pull request #91 from liteseed/main
small idiomatic code fix
2 parents 1c6b311 + 86a9c5f commit 0c91349

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

wdb.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,19 +91,13 @@ func (w *Wdb) GetExpiredOrders() ([]schema.Order, error) {
9191
func (w *Wdb) ExistPaidOrd(itemId string) bool {
9292
ord := &schema.Order{}
9393
err := w.Db.Model(&schema.Order{}).Where("item_id = ? and payment_status = ?", itemId, schema.SuccPayment).First(ord).Error
94-
if err == gorm.ErrRecordNotFound {
95-
return false
96-
}
97-
return true
94+
return err != gorm.ErrRecordNotFound
9895
}
9996

10097
func (w *Wdb) IsLatestUnpaidOrd(itemId string, CurExpiredTime int64) bool {
10198
ord := &schema.Order{}
10299
err := w.Db.Model(&schema.Order{}).Where("item_id = ? and payment_status = ? and payment_expired_time > ?", itemId, schema.UnPayment, CurExpiredTime).First(ord).Error
103-
if err == gorm.ErrRecordNotFound {
104-
return true
105-
}
106-
return false
100+
return err == gorm.ErrRecordNotFound
107101
}
108102

109103
func (w *Wdb) UpdateOrdToExpiredStatus(id uint) error {

0 commit comments

Comments
 (0)