public async Task<HttpResponseMessage> PostComplement([FromBody]ComplementParameter registerParam, [FromUri]string type) { string openid = registerParam.openID; string university = registerParam.university; string faculty = registerParam.faculty; int researchFieldId = registerParam.researchFieldId; short degree = registerParam.degree; short enrollment = registerParam.enrollment; string gender = registerParam.Gender; string name = registerParam.name; string position = registerParam.position; short isBusiness = registerParam.isBusiness; if (string.IsNullOrEmpty(openid) || string.IsNullOrEmpty(university) || string.IsNullOrEmpty(faculty) || researchFieldId == 0 || string.IsNullOrEmpty(gender) || string.IsNullOrEmpty(name)) { return WebApiHelper.HttpRMtoJson(null, HttpStatusCode.OK, customStatus.InvalidArguments); } if (string.IsNullOrEmpty(position) && isBusiness == 0) { return WebApiHelper.HttpRMtoJson(null, HttpStatusCode.OK, customStatus.InvalidArguments); } if (isBusiness == 2 && enrollment == 0) { return WebApiHelper.HttpRMtoJson(null, HttpStatusCode.OK, customStatus.InvalidArguments); } var preRegisterRedis = await UserInfoControllerHelper.GetUserInfoRedisByOpenid(openid); string preRegisterAccount = preRegisterRedis.PreRegisterAccount; pre_register preRegister = null; if (type != "update") { using (UserRepository userRepository = new UserRepository()) { userinfo = await userRepository.GetUserInfoByAccount(preRegisterAccount); preRegister = await userRepository.GetPreRegisterByOpenid(openid); } if (userinfo != null) return WebApiHelper.HttpRMtoJson(null, HttpStatusCode.OK, customStatus.AccountExist); if (preRegister == null) return WebApiHelper.HttpRMtoJson(null, HttpStatusCode.OK, customStatus.NotFound); } //更新数据库的userinfo bool result = await UserInfoControllerHelper.SaveUserInfo(registerParam, preRegister); if (result) { //更新redis的性别 UserInfoRedis redisUser = new UserInfoRedis(); redisUser.Openid = openid; redisUser.Sex = gender; await RedisManager.SaveObjectAsync(redisUser); using (UserRepository userRepository = new UserRepository()) { userinfo = await userRepository.GetUserInfoByOpenid(openid); } if (await ComplexLocationManager.UpdateComplexLocationAsync(openid, userinfo.IsBusiness ?? 0, int.Parse(userinfo.Gender), userinfo.ResearchFieldId ?? 0)) { //位置索引添加供筛选字段 } return WebApiHelper.HttpRMtoJson(null, HttpStatusCode.OK, customStatus.Success); } else { return WebApiHelper.HttpRMtoJson(null, HttpStatusCode.OK, customStatus.Fail); } }
public async Task<HttpResponseMessage> PostInitialize([FromBody]RegisterParameter registerParam, [FromUri]string type) { string openid = registerParam.openID; if(string.IsNullOrEmpty(openid)) { return WebApiHelper.HttpRMtoJson(null, HttpStatusCode.OK, customStatus.InvalidArguments); } pre_register prereg = null; using(UserRepository userRepository = new UserRepository()) { var userinfoRedis = await BK.CommonLib.Weixin.User.WXAuthHelper.GetUserInfoByOPenId(openid); if(type != "update") { prereg = await userRepository.GetPreRegisterByOpenid(openid); if(prereg == null) { return WebApiHelper.HttpRMtoJson(null, HttpStatusCode.OK, customStatus.NotFound); } userinfo = new UserInfo() { Photo = userinfoRedis.HeadImageUrl.Substring(0, userinfoRedis.HeadImageUrl.LastIndexOf("/0")) + "/96", Name = prereg.name, Gender = userinfoRedis.Sex, }; } else { userinfo = await userRepository.GetUserInfoByOpenid(openid); userinfo.Gender = userinfoRedis.Sex; } return WebApiHelper.HttpRMtoJson(userinfo, HttpStatusCode.OK, customStatus.Success); } }