|
@@ -529,3 +529,130 @@ func (this *WechatCommonController) Notify() {
|
|
|
this.Ctx.WriteString(echostr)
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+//type DataOpenidArr struct {
|
|
|
+// Data OpenidArr `json:"data"`
|
|
|
+//}
|
|
|
+//
|
|
|
+//type OpenidArr struct {
|
|
|
+// Openid []string `json:"openid"`
|
|
|
+//}
|
|
|
+//
|
|
|
+//func init() {
|
|
|
+// access_token := "87_vfOIH2qwWI6cYG584J-SQklN5r5_HelQeLToq-ZNbb4LOl3SnxKSIH6qMfbljvOI9tTWTv0e9t2Gq41-u_WJhYyFzm7rH7bhRYaMhqaU713Wx9qhPfpbTb506GYXMLcAFAODC"
|
|
|
+// url := "https://api.weixin.qq.com/cgi-bin/user/get?access_token=" + access_token
|
|
|
+// method := "GET"
|
|
|
+// client := &http.Client{}
|
|
|
+// req, err := http.NewRequest(method, url, nil)
|
|
|
+//
|
|
|
+// if err != nil {
|
|
|
+// fmt.Println(err)
|
|
|
+// return
|
|
|
+// }
|
|
|
+// res, err := client.Do(req)
|
|
|
+// if err != nil {
|
|
|
+// fmt.Println(err)
|
|
|
+// return
|
|
|
+// }
|
|
|
+// defer res.Body.Close()
|
|
|
+//
|
|
|
+// body, err := ioutil.ReadAll(res.Body)
|
|
|
+// if err != nil {
|
|
|
+// fmt.Println(err)
|
|
|
+// return
|
|
|
+// }
|
|
|
+// item := new(DataOpenidArr)
|
|
|
+// err = json.Unmarshal(body, &item)
|
|
|
+// fmt.Println(len(item.Data.Openid))
|
|
|
+//
|
|
|
+// //var condition string
|
|
|
+// //var pars []interface{}
|
|
|
+// //
|
|
|
+// //condition = ` AND open_id IN (` + utils.GetOrmInReplace(len(item.Data.Openid)) + `) `
|
|
|
+// //pars = append(pars, item.Data.Openid)
|
|
|
+// //
|
|
|
+// //listUserRecord, err := models.GetUserRecordList(condition, pars)
|
|
|
+// //if err != nil {
|
|
|
+// // fmt.Println(err)
|
|
|
+// // return
|
|
|
+// //}
|
|
|
+// accessToken, err := services.GetWxAccessTokenByGzh()
|
|
|
+// for k, v := range item.Data.Openid {
|
|
|
+// //if k > 1 {
|
|
|
+// // return
|
|
|
+// //}
|
|
|
+//
|
|
|
+// fmt.Println(k, "___", v)
|
|
|
+// openId := v
|
|
|
+//
|
|
|
+// wxUserInfo, err := services.WxGetUserInfo(openId, accessToken)
|
|
|
+// if err != nil {
|
|
|
+// utils.FileLog.Info("accessToken:" + err.Error())
|
|
|
+// return
|
|
|
+// }
|
|
|
+// SubscribeTime := time.Unix(int64(wxUserInfo.SubscribeTime), 0).Format(utils.FormatDateTime)
|
|
|
+// fmt.Println(SubscribeTime)
|
|
|
+// if wxUserInfo.Errcode != 0 {
|
|
|
+// userInfoJson, _ := json.Marshal(wxUserInfo)
|
|
|
+// fmt.Println("获取用户信息失败,err:" + string(userInfoJson))
|
|
|
+// }
|
|
|
+// unionId := wxUserInfo.Unionid
|
|
|
+// wxUser, err := models.GetUserRecordByUnionId(unionId)
|
|
|
+// if err != nil {
|
|
|
+// utils.FileLog.Info("GetUserDetailBuOpenid:" + err.Error())
|
|
|
+// }
|
|
|
+// if wxUser == nil {
|
|
|
+// continue
|
|
|
+// }
|
|
|
+// if wxUser.UserId == 0 {
|
|
|
+// continue
|
|
|
+// }
|
|
|
+//
|
|
|
+// items := new(models.CygxMfyxGzhUserRecord)
|
|
|
+// items.OpenId = openId
|
|
|
+// items.UnionId = unionId
|
|
|
+// items.NickName = wxUserInfo.Nickname
|
|
|
+// items.Sex = wxUserInfo.Sex
|
|
|
+// items.Province = wxUserInfo.Province
|
|
|
+// items.City = wxUserInfo.City
|
|
|
+// items.Country = wxUserInfo.Country
|
|
|
+// items.Headimgurl = wxUserInfo.Headimgurl
|
|
|
+// items.CreateTime = time.Now()
|
|
|
+// items.Subscribe = 1
|
|
|
+// items.SubscribeTime = time.Unix(int64(wxUserInfo.SubscribeTime), 0)
|
|
|
+// items.CygxUserId = wxUser.UserId
|
|
|
+// items.CygxBindAccount = wxUser.BindAccount
|
|
|
+//
|
|
|
+// total, err := models.GetCygxUserRecordCount(openId)
|
|
|
+// if total == 0 {
|
|
|
+// _, err = models.AddMfyxGzhUserRecord(items)
|
|
|
+// }
|
|
|
+//
|
|
|
+// userRecord := &models.UserRecord{
|
|
|
+// OpenId: openId, //用户open_id
|
|
|
+// UnionId: unionId, //用户union_id
|
|
|
+// Subscribe: 1,
|
|
|
+// NickName: wxUserInfo.Nickname, //用户昵称,最大长度:32
|
|
|
+// RealName: "", //用户实际名称,最大长度:32
|
|
|
+// Sex: wxUserInfo.Sex, //普通用户性别,1为男性,2为女性
|
|
|
+// Province: wxUserInfo.Province, //普通用户个人资料填写的省份,最大长度:30
|
|
|
+// City: wxUserInfo.City, //普通用户个人资料填写的城市,最大长度:30
|
|
|
+// Country: wxUserInfo.Country, //国家,如中国为CN,最大长度:30
|
|
|
+// Headimgurl: wxUserInfo.Headimgurl, //用户第三方(微信)头像,最大长度:512
|
|
|
+// CreateTime: time.Now(), //创建时间,关系添加时间、用户授权时间
|
|
|
+// CreatePlatform: 12, //注册平台,1:日度点评公众号,2:管理后台,3:pc端网站,4:查研观向小程序;默认:1
|
|
|
+// SessionKey: wxUserInfo.SessionKey, //微信小程序会话密钥,最大长度:255
|
|
|
+// }
|
|
|
+// userRecord.UserId = wxUser.UserId
|
|
|
+// totalUserRecord, err := models.GetUserRecordCount(openId)
|
|
|
+// if totalUserRecord == 0 {
|
|
|
+// _, err = models.AddUserRecord(userRecord)
|
|
|
+// }
|
|
|
+//
|
|
|
+// fmt.Println("关注")
|
|
|
+// models.UserSubscribeInit(1, wxUser.UserId, SubscribeTime)
|
|
|
+// //go models.CygxUserSubscribe(1, unionId)
|
|
|
+// }
|
|
|
+//
|
|
|
+// fmt.Println("end")
|
|
|
+//}
|