/// <summary> /// 删除小票信息 /// </summary> /// <param name="param"></param> /// <returns></returns> public object Do_DelTicket(object param) { TicketParam listParam = JsonConvert.DeserializeObject <TicketParam>(param.ToString()); if (listParam == null) { throw new ApiException(CodeMessage.InvalidParam, "InvalidParam"); } #if DEBUG var openId = listParam.token; #endif #if !DEBUG AppBag appBag = AppContainer.GetAppBag(listParam.token); if (appBag == null) { throw new ApiException(CodeMessage.GetUserError, "GetUserError"); } var openId = appBag.Values; #endif TicketDao ticketDao = new TicketDao(); CodeMessage s = ticketDao.deleteTicket(openId, listParam); if (s.ToString() == "deleteTicketSuccess") { return("deleteTicketSuccess"); } else { throw new ApiException(s, s.ToString()); } }
/// <summary> /// 获取小票列表 /// </summary> /// <param name="param"></param> /// <returns></returns> public object Do_GetTicketList(object param) { ListParam listParam = JsonConvert.DeserializeObject <ListParam>(param.ToString()); if (listParam == null) { throw new ApiException(CodeMessage.InvalidParam, "InvalidParam"); } #if DEBUG var openId = listParam.token; #endif #if !DEBUG AppBag appBag = AppContainer.GetAppBag(listParam.token); if (appBag == null) { throw new ApiException(CodeMessage.GetUserError, "GetUserError"); } var openId = appBag.Values; #endif UserDao userDao = new UserDao(); userDao.insertUser(openId); TicketDao ticketDao = new TicketDao(); ListResult listResult = ticketDao.getListByOpenId(openId); return(listResult); }
/// <summary> /// 根据小票编号获取小票信息 /// </summary> /// <param name="param"></param> /// <returns></returns> public object Do_UpdateQRCoder(object param) { ItemParam itemParam = JsonConvert.DeserializeObject <ItemParam>(param.ToString()); if (itemParam == null) { throw new ApiException(CodeMessage.InvalidParam, "InvalidParam"); } #if DEBUG var openId = itemParam.token; #endif #if !DEBUG AppBag appBag = AppContainer.GetAppBag(itemParam.token); if (appBag == null) { throw new ApiException(CodeMessage.GetUserError, "GetUserError"); } var openId = appBag.Values; #endif UserDao userDao = new UserDao(); UserResult ur = new UserResult(); ur.url = userDao.updateQRCode(openId); return(ur); }
/// <summary> /// 获取二维码 /// </summary> /// <param name="param"></param> /// <returns></returns> public object Do_GetQRCoder(object param) { ListParam listParam = JsonConvert.DeserializeObject <ListParam>(param.ToString()); if (listParam == null) { throw new ApiException(CodeMessage.InvalidParam, "InvalidParam"); } #if DEBUG var openId = listParam.token; #endif #if !DEBUG AppBag appBag = AppContainer.GetAppBag(listParam.token); if (appBag == null) { throw new ApiException(CodeMessage.GetUserError, "GetUserError"); } var openId = appBag.Values; #endif UserDao userDao = new UserDao(); string s = userDao.getQRCoder(openId); if (s != "") { UserResult ur = new UserResult(); ur.url = s; return(ur); } else { throw new ApiException(CodeMessage.QRCoderError, "QRCoderError"); } }
public ActionResult OAuthCallBack(string code, string state, string returnUrl) { if (string.IsNullOrEmpty(code)) { return(Content("您拒绝了授权!")); } var checkBag = AppContainer.GetAppBag(state); if (checkBag.Values != returnUrl) { return(Content("验证错误!")); } AppContainer.UpdateAppBag(checkBag.Key, "", null); OAuthAccessTokenResult result = null; try { result = Senparc.Weixin.MP.AdvancedAPIs.OAuthApi.GetAccessToken(Global.APPID, Global.APPSECRET, code); } catch (Exception ex) { return(Content(ex.Message)); } if (result.errcode != ReturnCode.请求成功) { return(Content("错误:" + result.errmsg)); } try { if (string.IsNullOrEmpty(returnUrl)) { return(Content("目标页面无效")); } OAuthUserInfo userInfo = Senparc.Weixin.MP.AdvancedAPIs.OAuthApi.GetUserInfo(result.access_token, result.openid); string jsonUser = JsonConvert.SerializeObject(userInfo); var appBag = AppContainer.UpdateAppBag(null, userInfo.openid, jsonUser); return(Redirect(returnUrl + "#/?token=" + appBag.Key)); } catch (ErrorJsonResultException ex) { return(Content(ex.Message)); } }
/// <summary> /// 检查token判断执行权限 /// </summary> /// <param name="apiType"></param> /// <param name="token"></param> /// <returns></returns> private bool CheckToken(ApiType apiType, string token) { bool b = true; #if !DEBUG if (bussList[apiType].NeedCheck()) { var appBag = AppContainer.GetAppBag(token); if (appBag == null) { b = false; } } #endif return(b); }
/// <summary> /// 根据小票编号获取小票信息 /// </summary> /// <param name="param"></param> /// <returns></returns> public object Do_GetTicketItem(object param) { ItemParam itemParam = JsonConvert.DeserializeObject <ItemParam>(param.ToString()); if (itemParam == null) { throw new ApiException(CodeMessage.InvalidParam, "InvalidParam"); } #if DEBUG var openId = itemParam.token; #endif #if !DEBUG AppBag appBag = AppContainer.GetAppBag(itemParam.token); if (appBag == null) { throw new ApiException(CodeMessage.GetUserError, "GetUserError"); } var openId = appBag.Values; #endif TicketDao ticketDao = new TicketDao(); return(ticketDao.getTicketItem(openId, itemParam.ticketNum)); }
public object Do_GetUser(object param) { //try //{ UserParam userParam = JsonConvert.DeserializeObject <UserParam>(param.ToString()); if (userParam == null) { Console.WriteLine("InvalidParam"); Console.WriteLine(param.ToString()); throw new ApiException(CodeMessage.InvalidParam, "InvalidParam"); } var appBag = AppContainer.GetAppBag(userParam.token); OAuthUserInfo userInfo = JsonConvert.DeserializeObject <OAuthUserInfo>(appBag.AppObj.ToString()); if (appBag != null) { return(userInfo); } else { Console.WriteLine("InvalidToken"); Console.WriteLine(userParam.token); throw new ApiException(CodeMessage.InvalidToken, "InvalidToken"); } //} //catch(Exception ex) //{ // Console.WriteLine(ex.Message); // Console.WriteLine(ex.StackTrace); // Console.WriteLine(ex.InnerException.Message); // Console.WriteLine(ex.InnerException.StackTrace); // throw new ApiException(CodeMessage.InnerError, "InnerError"); //} }