github.com/chanxuehong/wechat@v0.0.0-20230222024006-36f0325263cd/mp/datacube/card/getcardcardinfo.go (about)

     1  package card
     2  
     3  import (
     4  	"github.com/chanxuehong/wechat/mp/core"
     5  )
     6  
     7  // 免费券数据
     8  type CardData struct {
     9  	RefDate      string `json:"ref_date"`     // 日期信息, YYYY-MM-DD
    10  	CardId       string `json:"card_id"`      // 卡券ID
    11  	CardType     int    `json:"card_type"`    // cardtype:0:折扣券,1:代金券,2:礼品券,3:优惠券,4:团购券(暂不支持拉取特殊票券类型数据,电影票、飞机票、会议门票、景区门票)
    12  	IsPay        int    `json:"is_pay"`       // 是否付费券。0为非付费券,1为付费券
    13  	ViewCount    int    `json:"view_cnt"`     // 浏览次数
    14  	ViewUser     int    `json:"view_user"`    // 浏览人数
    15  	ReceiveCount int    `json:"receive_cnt"`  // 领取次数
    16  	ReceiveUser  int    `json:"receive_user"` // 领取人数
    17  	VerifyCount  int    `json:"verify_cnt"`   // 使用次数
    18  	VerifyUser   int    `json:"verify_user"`  // 使用人数
    19  	GivenCount   int    `json:"given_cnt"`    // 转赠次数
    20  	GivenUser    int    `json:"given_user"`   // 转赠人数
    21  	ExpireCount  int    `json:"expire_cnt"`   // 过期次数
    22  	ExpireUser   int    `json:"expire_user"`  // 过期人数
    23  }
    24  
    25  // 获取免费券数据接口
    26  func GetCardInfo(clt *core.Client, req *Request) (list []CardData, err error) {
    27  	var result struct {
    28  		core.Error
    29  		List []CardData `json:"list"`
    30  	}
    31  
    32  	incompleteURL := "https://api.weixin.qq.com/datacube/getcardcardinfo?access_token="
    33  	if err = clt.PostJSON(incompleteURL, req, &result); err != nil {
    34  		return
    35  	}
    36  
    37  	if result.ErrCode != core.ErrCodeOK {
    38  		err = &result.Error
    39  		return
    40  	}
    41  	list = result.List
    42  	return
    43  }