github.com/chanxuehong/wechat@v0.0.0-20230222024006-36f0325263cd/mp/card/user/getcardlist.go (about) 1 package user 2 3 import ( 4 "github.com/chanxuehong/wechat/mp/card/code" 5 "github.com/chanxuehong/wechat/mp/core" 6 ) 7 8 // 获取用户已领取卡券接口 9 // 10 // openid: 需要查询的用户openid 11 // cardid: 卡券ID。不填写时默认查询当前appid下的卡券。 12 func GetCardList(clt *core.Client, openid, cardid string) (list []code.CardItemIdentifier, err error) { 13 request := struct { 14 OpenId string `json:"openid"` 15 CardId string `json:"card_id,omitempty"` 16 }{ 17 OpenId: openid, 18 CardId: cardid, 19 } 20 21 var result struct { 22 core.Error 23 CardList []code.CardItemIdentifier `json:"card_list"` 24 } 25 26 incompleteURL := "https://api.weixin.qq.com/card/user/getcardlist?access_token=" 27 if err = clt.PostJSON(incompleteURL, &request, &result); err != nil { 28 return 29 } 30 31 if result.ErrCode != core.ErrCodeOK { 32 err = &result.Error 33 return 34 } 35 list = result.CardList 36 return 37 }