From 95155aeef054ca0291475cf645bf6aed85cf1f10 Mon Sep 17 00:00:00 2001 From: liangjies <1139629972@qq.com> Date: Thu, 25 Jul 2024 00:01:11 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=90=88=E9=9B=86=E6=8C=91=E6=88=98?= =?UTF-8?q?=E9=A2=86=E5=8F=96=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/app/dao/claim_badge_tweet.go | 8 -------- internal/app/dao/collection.go | 3 ++- internal/app/dao/user_challenge_claim.go | 15 ++++++++++++++- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/internal/app/dao/claim_badge_tweet.go b/internal/app/dao/claim_badge_tweet.go index b0ff988..cd96ec8 100644 --- a/internal/app/dao/claim_badge_tweet.go +++ b/internal/app/dao/claim_badge_tweet.go @@ -68,14 +68,6 @@ func (d *Dao) UpdateAirdroppedOne(tokenId string, receivers string, hash string) } func (d *Dao) HasAirdrop(address string, tokenId string) bool { - //var total int64 - //err := d.db.Model(&model.ClaimBadgeTweet{}). - // Where("address = ? AND token_id = ? AND status=1", address, tokenId). - // Count(&total).Error - //if err != nil { - // log.Errorv("HasAirdrop error", zap.Error(err)) - // return false - //} var total int64 err := d.db.Model(&model.UserChallenges{}). Where("address = ? AND token_id = ?", address, tokenId). diff --git a/internal/app/dao/collection.go b/internal/app/dao/collection.go index 71e7228..059b4d4 100644 --- a/internal/app/dao/collection.go +++ b/internal/app/dao/collection.go @@ -88,8 +88,9 @@ func (d *Dao) GetCollectionQuest(r request.GetCollectionQuestRequest) (questList Joins("left join quest_translated as tr ON quest.token_id = tr.token_id AND tr.language = ?", r.Language). Where("collection_relate.collection_id = ? AND quest.status=1", collection.ID) if r.Address != "" { - db.Select("quest.*,c.claimed,COALESCE(tr.title,quest.title) as title,COALESCE(tr.description,quest.description) as description") + db.Select("quest.*,NOT (c.claimed = false AND zc.quest_id IS NULL) as claimed,COALESCE(tr.title,quest.title) as title,COALESCE(tr.description,quest.description) as description") db.Joins("LEFT JOIN user_challenges c ON quest.token_id = c.token_id AND c.address = ?", r.Address) + db.Joins("LEFT JOIN zcloak_card zc ON zc.address = ? AND zc.quest_id=quest.id AND zc.deleted_at IS NULL", r.Address) } else { db.Select("quest.*,COALESCE(tr.title,quest.title) as title,COALESCE(tr.description,quest.description) as description") } diff --git a/internal/app/dao/user_challenge_claim.go b/internal/app/dao/user_challenge_claim.go index f6e36a2..dcd0596 100644 --- a/internal/app/dao/user_challenge_claim.go +++ b/internal/app/dao/user_challenge_claim.go @@ -28,11 +28,24 @@ func (d *Dao) HasClaimed(address string, tokenID string) (status uint8, err erro // HasClaimedFinish 查询claim是否成功 func (d *Dao) HasClaimedFinish(address string, tokenID string) (status uint8, err error) { + quest, err := d.GetQuestByTokenID(tokenID) + if err != nil { + return 0, err + } var userChallenges model.UserChallenges err = d.db.Model(&model.UserChallenges{}).Where("address = ? AND token_id = ?", address, tokenID).First(&userChallenges).Error if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { - return 0, nil + var zcloakCard model.ZcloakCard + err = d.db.Model(&model.ZcloakCard{}).Where("address = ? AND quest_id = ?", address, quest.ID).First(&zcloakCard).Error + if err != nil { + if errors.Is(err, gorm.ErrRecordNotFound) { + return 0, nil + } else { + return 0, err + } + } + return 2, nil } else { return 0, err }