public IHttpActionResult GetVipCoupon(string openId = "") { var vip = _vipService.GetVipInfo(openId); var coupon = _couponService.GetVipCoupon(vip); if (coupon != null) { return(Json(new { success = true, message = coupon })); } return(Json(new { success = false, message = "发生错误!" })); }
public IHttpActionResult GetVipPoint(string openId = "") { var vip = _vipService.GetVipInfo(openId); var point = _pointService.GetVipPoint(vip); if (point != null) { var pointRecord = _pointService.GetVipPointRecord(vip); return(Json(new { success = true, message = new { score = point.VipPoint, pointRecord = pointRecord } })); } return(Json(new { success = false, message = "发生错误!" })); }
public IHttpActionResult GetVip(string openId = "") { var vip = _vipService.GetVipInfo(openId); if (vip != null) { return(Json(new { success = true, message = vip })); } return(Json(new { success = false, message = "未注册,请注册后登录!" })); }
public IHttpActionResult BaseCallback(string code, string state, string backUrl = "") { var result = OAuthApi.GetAccessToken(Config.AppId, Config.Secret, code); if (result.errcode == Senparc.Weixin.ReturnCode.请求成功) { if (_loginService.WeChatLogin(result.openid)) { var vip = _vipService.GetVipInfo(result.openid); return(Json(new { success = true, message = new { success = true, message = new { token = Utils.MD5Encrypt(result.openid), openId = result.openid, vipCode = vip.VipCode } } })); } else { state = "UserInfo-" + DateTime.Now.Millisecond;//随机数,用于识别请求可靠性 var BackUrl = Config.BackUrl + backUrl; string WeChatUrl = OAuthApi.GetAuthorizeUrl(Config.AppId, BackUrl, state, OAuthScope.snsapi_userinfo); return(Json(new { success = true, message = new { success = false, message = WeChatUrl } })); } } else { return(Json(new { success = false, message = "错误:" + result.errmsg })); } }