123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- package activity
- import (
- "app.yhyue.com/moapp/message/config"
- "encoding/json"
- "fmt"
- "io/ioutil"
- "net/http"
- url2 "net/url"
- "strconv"
- )
- //ActivityLottery 获取活动下的奖券 receivingLocation 奖券形式0落地页 1付款页 999全部 3 我的奖券 productCode 活动code
- func ActivityLottery(userId, appId, receivingLocation, productCode string) (map[string]interface{}, error) {
- //url := config.PushConfig.ActivityUrl + "/activityLottery?userId=" + userId + "&appId=" + appId + "&activityId=" + activityId + "&receivingLocation=" + receivingLocation + "&productCode=" + productCode
- url := config.PushConfig.ActivityUrl + "/activityLottery?userId=" + userId + "&appId=" + appId + "&receivingLocation=" + receivingLocation + "&productCode=" + productCode
- fmt.Println(url)
- request, err := http.NewRequest("GET", url, nil)
- client := http.Client{}
- resp, err := client.Do(request)
- if err != nil {
- return nil, err
- }
- defer resp.Body.Close()
- var info map[string]interface{}
- result, _ := ioutil.ReadAll(resp.Body)
- if err := json.Unmarshal(result, &info); err == nil {
- fmt.Println("==============json str 转map=======================", info)
- }
- return info, nil
- }
- //LotteryReceive 奖卷领取 LotteryIdArr 奖券id 支持多个逗号拼接
- func LotteryReceive(lotteryRep config.LotteryReceiveReq) (int, string) {
- userNameStr := url2.PathEscape(lotteryRep.UserName)
- url := config.PushConfig.ActivityUrl + "/lotteryReceive?userName=" + userNameStr + "&userId=" + lotteryRep.UserId + "&appId=" + lotteryRep.AppId + "&lotteryIdArr=" + lotteryRep.LotteryIdArr
- fmt.Println(url)
- request, err := http.NewRequest("POST", url, nil)
- client := http.Client{}
- resp, err := client.Do(request)
- if err != nil {
- return 0, "奖券领取失败"
- }
- defer resp.Body.Close()
- var info map[string]interface{}
- result, _ := ioutil.ReadAll(resp.Body)
- if err := json.Unmarshal([]byte(result), &info); err == nil {
- fmt.Println("==============json str 转map=======================", info)
- }
- codeInt, err := strconv.Atoi(fmt.Sprint(info["Code"]))
- return codeInt, fmt.Sprint(info["Message"])
- }
|