Commit d5aaa06dd0f99ec5d086b567132862746eb566fd

Authored by 陆恒
1 parent 2decca18
Exists in master

登陆部分代码

src/HttpServer/logic/datadef.go
@@ -577,6 +577,7 @@ type UserData struct { @@ -577,6 +577,7 @@ type UserData struct {
577 Scene int 577 Scene int
578 Regtime int 578 Regtime int
579 InviteUid int 579 InviteUid int
580 - 580 + LoginTime int
  581 + LoginDay int
581 } 582 }
582 583
src/HttpServer/logic/function.go
@@ -209,13 +209,13 @@ func SaveUserExt(extdata * UserData) error { @@ -209,13 +209,13 @@ func SaveUserExt(extdata * UserData) error {
209 return err 209 return err
210 } 210 }
211 211
212 -func GetUserExt(uuid int) (*UserExtData,error) { 212 +func GetUserExt(uuid int) (*UserData,error) {
213 strval,err := redishandler.GetRedisClient().HGet(redis.USER_EXT_DATA, strconv.Itoa(uuid)) 213 strval,err := redishandler.GetRedisClient().HGet(redis.USER_EXT_DATA, strconv.Itoa(uuid))
214 if err != nil { 214 if err != nil {
215 logger.Error("GetUserExt failed,err=%v",err) 215 logger.Error("GetUserExt failed,err=%v",err)
216 return nil,err 216 return nil,err
217 } 217 }
218 - ext := new(UserExtData) 218 + ext := new(UserData)
219 err = json.Unmarshal([]byte(strval), ext) 219 err = json.Unmarshal([]byte(strval), ext)
220 return ext,err 220 return ext,err
221 } 221 }
@@ -589,9 +589,9 @@ func GetFfiendData(frienduuid int) *GetRecommendListInfo { @@ -589,9 +589,9 @@ func GetFfiendData(frienduuid int) *GetRecommendListInfo {
589 tmpinfo := new(GetRecommendListInfo) 589 tmpinfo := new(GetRecommendListInfo)
590 tmpinfo.Hot = tmpext.Hot 590 tmpinfo.Hot = tmpext.Hot
591 tmpinfo.Bean = tmpext.Bean 591 tmpinfo.Bean = tmpext.Bean
592 - tmpinfo.Userid = tmpext.User_id 592 + tmpinfo.Userid = tmpext.Userid
593 tmpinfo.Coin = tmpext.Coin 593 tmpinfo.Coin = tmpext.Coin
594 - tmpinfo.Reg_time = tmpext.Reg_time 594 + tmpinfo.Reg_time = tmpext.Regtime
595 tmpinfo.Lv = tmpext.Lv 595 tmpinfo.Lv = tmpext.Lv
596 tmpinfo.Exp = tmpext.Exp 596 tmpinfo.Exp = tmpext.Exp
597 tmpinfo.Nickname = tmpbasic.User_nickname 597 tmpinfo.Nickname = tmpbasic.User_nickname
@@ -599,8 +599,8 @@ func GetFfiendData(frienduuid int) *GetRecommendListInfo { @@ -599,8 +599,8 @@ func GetFfiendData(frienduuid int) *GetRecommendListInfo {
599 tmpinfo.Cat_num = 0 599 tmpinfo.Cat_num = 0
600 tmpinfo.City = tmpbasic.User_city 600 tmpinfo.City = tmpbasic.User_city
601 tmpinfo.Gender = tmpbasic.User_gender 601 tmpinfo.Gender = tmpbasic.User_gender
602 - tmpinfo.Love_exp = tmpext.LoveExp  
603 - tmpinfo.Shop_num = tmpext.ShopNum 602 + tmpinfo.Love_exp = tmpext.Loevexp
  603 + tmpinfo.Shop_num = tmpext.Shopnum
604 return tmpinfo 604 return tmpinfo
605 } 605 }
606 606
@@ -700,9 +700,9 @@ func (flist *FriendList)GetRecommandFriendList(uuid,friendnum int) (*GetRecommen @@ -700,9 +700,9 @@ func (flist *FriendList)GetRecommandFriendList(uuid,friendnum int) (*GetRecommen
700 var tmpinfo GetRecommendListInfo 700 var tmpinfo GetRecommendListInfo
701 tmpinfo.Hot = tmpext.Hot 701 tmpinfo.Hot = tmpext.Hot
702 tmpinfo.Bean = tmpext.Bean 702 tmpinfo.Bean = tmpext.Bean
703 - tmpinfo.Userid = tmpext.User_id 703 + tmpinfo.Userid = tmpext.Userid
704 tmpinfo.Coin = tmpext.Coin 704 tmpinfo.Coin = tmpext.Coin
705 - tmpinfo.Reg_time = tmpext.Reg_time 705 + tmpinfo.Reg_time = tmpext.Regtime
706 tmpinfo.Lv = tmpext.Lv 706 tmpinfo.Lv = tmpext.Lv
707 tmpinfo.Exp = tmpext.Exp 707 tmpinfo.Exp = tmpext.Exp
708 tmpinfo.Nickname = tmpbasic.User_nickname 708 tmpinfo.Nickname = tmpbasic.User_nickname
@@ -710,8 +710,8 @@ func (flist *FriendList)GetRecommandFriendList(uuid,friendnum int) (*GetRecommen @@ -710,8 +710,8 @@ func (flist *FriendList)GetRecommandFriendList(uuid,friendnum int) (*GetRecommen
710 tmpinfo.Cat_num = 0 710 tmpinfo.Cat_num = 0
711 tmpinfo.City = tmpbasic.User_city 711 tmpinfo.City = tmpbasic.User_city
712 tmpinfo.Gender = tmpbasic.User_gender 712 tmpinfo.Gender = tmpbasic.User_gender
713 - tmpinfo.Love_exp = tmpext.LoveExp  
714 - tmpinfo.Shop_num = tmpext.ShopNum 713 + tmpinfo.Love_exp = tmpext.Loevexp
  714 + tmpinfo.Shop_num = tmpext.Shopnum
715 realrt.Recommend_list = append(realrt.Recommend_list,tmpinfo) 715 realrt.Recommend_list = append(realrt.Recommend_list,tmpinfo)
716 716
717 } 717 }
src/HttpServer/logic/logic.go
@@ -59,6 +59,8 @@ func InitUserExt(req *UserLoginReq,resp *UserLoginResp,uuid int) { @@ -59,6 +59,8 @@ func InitUserExt(req *UserLoginReq,resp *UserLoginResp,uuid int) {
59 udata.Userid = extdata.User_id 59 udata.Userid = extdata.User_id
60 udata.UserInviteId = extdata.User_invite_uid 60 udata.UserInviteId = extdata.User_invite_uid
61 udata.Userregtime = extdata.User_reg_time 61 udata.Userregtime = extdata.User_reg_time
  62 + udata.LoginTime = int(time.Now().Unix())
  63 + udata.LoginDay = 1
62 64
63 SaveUserExt(udata) 65 SaveUserExt(udata)
64 } 66 }
@@ -136,11 +138,42 @@ func InitWeChatUser(req *WechatLoginReq,resp *UserLoginResp,uinfo *WxUserInfo) { @@ -136,11 +138,42 @@ func InitWeChatUser(req *WechatLoginReq,resp *UserLoginResp,uinfo *WxUserInfo) {
136 udata.Userid = extdata.User_id 138 udata.Userid = extdata.User_id
137 udata.UserInviteId = extdata.User_invite_uid 139 udata.UserInviteId = extdata.User_invite_uid
138 udata.Userregtime = extdata.User_reg_time 140 udata.Userregtime = extdata.User_reg_time
  141 + udata.LoginTime = int(time.Now().Unix())
  142 + udata.LoginDay = 1
139 143
140 SaveUserExt(udata) 144 SaveUserExt(udata)
141 145
142 } 146 }
143 147
  148 +//处理登陆数据
  149 +func HandleLoginTime(ext *UserData) {
  150 + ext.LoginTime = int(time.Now().Unix())
  151 + timeStr := time.Now().Format("2006-01-02")
  152 + t, _ := time.Parse("2006-01-02", timeStr)
  153 + timeNumber := int(t.Unix() - 8*3600)
  154 + if timeNumber <= ext.LoginTime {
  155 + ext.LoginDay += 1
  156 + }
  157 +}
  158 +
  159 +func TransmitUserData(in *UserData ,out *UserExtData) {
  160 + out.LoveExp = in.Loevexp
  161 + out.User_id = in.Userid
  162 + out.ShopNum = in.Shopnum
  163 + out.Exp = in.Exp
  164 + out.Lv = in.Lv
  165 + out.Reg_time = in.Regtime
  166 + out.Coin = in.Coin
  167 + out.Bean = in.Bean
  168 + out.Hot = in.Hot
  169 + out.User_reg_time = in.Userregtime
  170 + out.User_invite_uid = in.UserInviteId
  171 + out.User_is_black = in.Isblack
  172 + out.User_scene = in.Scene
  173 + out.User_channel = in.Channel
  174 + out.Invite_uid = in.InviteUid
  175 +}
  176 +
144 //处理微信登录 177 //处理微信登录
145 func HandleWechatlogin(w http.ResponseWriter, data string) { 178 func HandleWechatlogin(w http.ResponseWriter, data string) {
146 179
@@ -186,11 +219,19 @@ func HandleWechatlogin(w http.ResponseWriter, data string) { @@ -186,11 +219,19 @@ func HandleWechatlogin(w http.ResponseWriter, data string) {
186 resp.Result.Code = ERROR_GETUSEREXTFAILED 219 resp.Result.Code = ERROR_GETUSEREXTFAILED
187 break 220 break
188 } 221 }
189 - resp.Result.Data.Extdata = *ext 222 + TransmitUserData(ext,&resp.Result.Data.Extdata)
  223 + //resp.Result.Data.Extdata = *ext
190 224
191 - m_userInfo.Set(uint32(ext.User_id),ext) 225 + //需要处理登录数据
  226 + HandleLoginTime(ext)
  227 +
  228 + m_userInfo.Set(uint32(ext.Userid),ext)
  229 + SaveUserExt(ext)
192 } 230 }
193 231
  232 +
  233 +
  234 +
194 resp.Result.Code = ERROR_OK 235 resp.Result.Code = ERROR_OK
195 break 236 break
196 } 237 }
@@ -226,9 +267,11 @@ func HandleTouristLogin(w http.ResponseWriter, req *UserLoginReq,resp *UserLogin @@ -226,9 +267,11 @@ func HandleTouristLogin(w http.ResponseWriter, req *UserLoginReq,resp *UserLogin
226 resp.Result.Code = ERROR_GETUSEREXTFAILED 267 resp.Result.Code = ERROR_GETUSEREXTFAILED
227 break 268 break
228 } 269 }
229 - resp.Result.Data.Extdata = *ext 270 + //resp.Result.Data.Extdata = *ext
  271 + TransmitUserData(ext,&resp.Result.Data.Extdata)
230 272
231 - m_userInfo.Set(uint32(ext.User_id),ext) 273 + m_userInfo.Set(uint32(ext.Userid),ext)
  274 + SaveUserExt(ext)
232 } 275 }
233 276
234 resp.Result.Code = ERROR_OK 277 resp.Result.Code = ERROR_OK
@@ -317,7 +360,8 @@ func HandleSaveUserData(w http.ResponseWriter, data string) { @@ -317,7 +360,8 @@ func HandleSaveUserData(w http.ResponseWriter, data string) {
317 resp.Result.Code = ERROR_GETUSEREXTFAILED 360 resp.Result.Code = ERROR_GETUSEREXTFAILED
318 break 361 break
319 } 362 }
320 - resp.Result.Data.Extdata = *ext 363 + //resp.Result.Data.Extdata = *ext
  364 + TransmitUserData(ext,&resp.Result.Data.Extdata)
321 365
322 resp.Result.Code = ERROR_OK 366 resp.Result.Code = ERROR_OK
323 break 367 break
@@ -1154,8 +1198,8 @@ func HandleGetDataByUserId(w http.ResponseWriter, data string) { @@ -1154,8 +1198,8 @@ func HandleGetDataByUserId(w http.ResponseWriter, data string) {
1154 1198
1155 resp.Result.Data.Base_data = base 1199 resp.Result.Data.Base_data = base
1156 resp.Result.Data.User_base_data = *basic 1200 resp.Result.Data.User_base_data = *basic
1157 - resp.Result.Data.Extdata = *ext  
1158 - 1201 + //resp.Result.Data.Extdata = *ext
  1202 + TransmitUserData(ext,&resp.Result.Data.Extdata)
1159 resp.Result.Code = ERROR_OK 1203 resp.Result.Code = ERROR_OK
1160 break 1204 break
1161 } 1205 }