Skip to content

Commit

Permalink
Merge pull request #151 from decert-me/fix/collection-claim-status
Browse files Browse the repository at this point in the history
Fix 合集挑战领取状态
  • Loading branch information
0xdwong authored Jul 25, 2024
2 parents d85ed34 + 95155ae commit 745fc6e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
8 changes: 0 additions & 8 deletions internal/app/dao/claim_badge_tweet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
3 changes: 2 additions & 1 deletion internal/app/dao/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
15 changes: 14 additions & 1 deletion internal/app/dao/user_challenge_claim.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 745fc6e

Please sign in to comment.