Example #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string code = WEBRequest.GetQueryString("code");

            if (!IsPostBack)
            {
                ThirdLoginSDK sdkApi = new ThirdLoginSDK();
                sdkApi.InitSDK(ThirdLoginSDK.ThirdLoginType.WeiXin);
                string SelfOpenId = sdkApi.GetCookieOpenId(code);
            }
        }
Example #2
0
        protected void InitFormData()
        {
            ThirdLoginSDK sdkApi = new ThirdLoginSDK();

            sdkApi.InitSDK(ThirdLoginSDK.ThirdLoginType.WeiXin);
            SelfOpenId = sdkApi.GetCookieOpenId("");

            WealthPage.GodWealthRecordInfo wealthInfo = WealthPage.GetUserGodWealthInfo(SelfOpenId);
            if (wealthInfo != null)
            {
                GodShowName = wealthInfo.ShowName;
            }
            RedPackedStatus = WealthPage.CheckRedPacketStatus().ToString();
        }
Example #3
0
        //获取当前用户的OpenId
        private string GetCurrentOpenId(string code)
        {
            ThirdLoginSDK sdkApi = new ThirdLoginSDK();

            sdkApi.InitSDK(ThirdLoginSDK.ThirdLoginType.WeiXin);
            string HostOpenId = sdkApi.GetCookieOpenId(code);

            //if (GlobalUtils.OpenId.ToText().IsNotEmpty())
            //{
            //    HostOpenId = GlobalUtils.OpenId;
            //}
            //else
            //{
            //    HostOpenId = WeiXin.GetOpenid(code);
            //    GlobalUtils.WriteOpenIdToCookie(HostOpenId);
            //}
            return(HostOpenId);
        }
Example #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            code = WEBRequest.GetQueryString("code");
            if (!IsPostBack)
            {
                if (code.IsEmpty())
                {
                    HttpContext.Current.Response.Redirect(GlobalUtils.WebURL + "/Activity/20150901Vote/AuthIndex.aspx", true);

                    return;
                }
                ThirdLoginSDK sdkApi = new ThirdLoginSDK();
                sdkApi.InitSDK(ThirdLoginSDK.ThirdLoginType.WeiXin);
                HostOpenId = sdkApi.GetCookieOpenId(code);

                GetHadVoterCount();
            }
        }
Example #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            code      = WEBRequest.GetQueryString("code");
            ExtendKey = WEBRequest.GetQueryString("ExtendKey");
            IsLogin   = WebUserAuth.IsAuthenticated ? 1 : 0;


            if (!IsPostBack)
            {
                WeiXinApi jssdk = new WeiXinApi();
                jssdk.InitApi();
                System.Collections.Hashtable hs = jssdk.getSignPackage();
                AppId     = hs["appId"].ToString();
                NonceStr  = hs["nonceStr"].ToString();
                TimeStamp = hs["timestamp"].ToInt(0);
                Signature = hs["signature"].ToString();
            }
            ThirdLoginSDK sdkApi = new ThirdLoginSDK();

            sdkApi.InitSDK(ThirdLoginSDK.ThirdLoginType.WeiXin);
            HostOpenId = sdkApi.GetCookieOpenId(code);

            if (!IsPostBack)
            {
                //判断有没帮好友做过,假如有为好友过时,则显示出自已领蛋糕的界面。 Allen 2015-07-13
                if (ExtendKey.IsNotEmpty())
                {
                    //帮好友做蛋糕
                    bool isDoCake = AjaxHandler.CheckUserHasDoCake(ExtendKey, HostOpenId);
                    if (isDoCake)
                    {
                        ExtendKey = "";//清空推广人
                    }
                }
            }
        }
Example #6
0
        //登录后自动领取奖品
        private bool AwardMyPrize(string code)
        {
            ThirdLoginSDK sdkApi = new ThirdLoginSDK();

            sdkApi.InitSDK(ThirdLoginSDK.ThirdLoginType.WeiXin);
            string OpenId = sdkApi.GetCookieOpenId(code);

//            using (SqlConnection connection = CelebHelper.OpenConnection(2))
//            {
//                string strSQL = "select * from Activity_ThreeYearGame_Record where WXOpenId=@WXOpenId";
//                DynamicParameters dyParams = new DynamicParameters();
//                dyParams.Add("@WXOpenId", OpenId);
//                GameRecordInfo recordInfo = connection.Query<GameRecordInfo>(strSQL, dyParams).FirstOrDefault();
//                if (recordInfo == null)
//                    return false;
//                //此处先屏蔽掉。因为考滤到之前没有领取红包失败的数据
//                //if (recordInfo.UserId.ToText().IsNotEmpty())
//                //    return true;


//                //非过期时才改为当前用户Id
//                //if (recordInfo.ExpirationDate.HasValue && recordInfo.ExpirationDate > DateTime.Now)
//                //{
//                UserBLL userbll = new UserBLL();
//                UserBasicInfoInfo userInfo = userbll.GetUserBasicInfoModelById(WebUserAuth.UserId.Value);

//                //判断同一个用户ID是否有领取奖品 Allen 2015-07-14
//                strSQL = " SELECT count(1) as cnt FROM Activity_ThreeYearGame_Record  WHERE UserId=@UserId";
//                dyParams = new DynamicParameters();
//                dyParams.Add("@UserId", userInfo.Id);
//                int iCount = connection.Query<Int32>(strSQL, dyParams).Sum();
//                if (iCount > 2)
//                {
//                    return false;
//                }

//                strSQL = @"update Activity_ThreeYearGame_Record set
//                                UserId=@UserId, UserName=@UserName, NickName=@NickName,
//                                ExpirationDate=@ExpirationDate, GetPrizeDate=@GetPrizeDate
//                                where WXOpenId=@WXOpenId";
//                dyParams = new DynamicParameters();
//                dyParams.Add("@WXOpenId", OpenId);
//                dyParams.Add("@UserId", userInfo.Id);
//                dyParams.Add("@UserName", userInfo.UserName);
//                dyParams.Add("@NickName", userInfo.NickName);
//                dyParams.Add("@ExpirationDate", null); //已获取奖品后这里清空
//                dyParams.Add("@GetPrizeDate", DateTime.Now); //领取时间

//                int iSuc = connection.Execute(strSQL, dyParams);

//                if (iSuc > 0)
//                {
//                    //判断团宝箱中有没发放过10元投资红包
//                    bool isSendRedPacket = CelebHelper.CheckInvestRedPrizeIsExists(WebUserAuth.UserId.Value);
//                    if (isSendRedPacket == false)
//                    {
//                        GamePrizeInfo prizeInfo = CelebHelper.GetPrizeInfor("RedPacket");
//                        if (prizeInfo != null)
//                        {
//                            //发送团宝箱
//                            CelebHelper.AddToMyPrize(prizeInfo, WebUserAuth.UserId.Value, false);
//                        }
//                    }
//                }

//                //修改已登录标识
//                strSQL = "update Activity_ThreeYearGame_Friend set IsLogin=1 where  FriendOpenId=@FriendOpenId";
//                dyParams = new DynamicParameters();
//                dyParams.Add("@FriendOpenId", OpenId);
//                connection.Execute(strSQL, dyParams);
//                // }
//            }
            return(true);
        }
Example #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string type = WEBRequest.GetQueryString("type");
            string code = "";

            switch (type.Trim().ToLower())
            {
            case "":
                string ReturnUrl = WEBRequest.GetQueryString("ReturnUrl");
                code = WEBRequest.GetQueryString("code");
                string goBackUrl = ReturnUrl;
                if (ReturnUrl.IndexOf("?") != -1)
                {
                    goBackUrl += "&code=" + code;
                }
                else
                {
                    goBackUrl += "?code=" + code;
                }

                Response.Redirect(goBackUrl);
                break;

            //获取微细OpenId
            case "getopenid":
                #region
                Response.ContentType = "application/json";
                try
                {
                    code = WEBRequest.GetQueryString("code");
                    ThirdLoginSDK sdkApi = new ThirdLoginSDK();
                    sdkApi.InitSDK(ThirdLoginSDK.ThirdLoginType.WeiXin);
                    string wxOpenId = sdkApi.GetCookieOpenId(code);
                    TuanDai.LogSystem.LogClient.LogClients.TraceLog(TdConfig.ApplicationName, "getopenid", "", wxOpenId);
                    this.PrintJson("1", wxOpenId);
                }
                catch (Exception ex)
                {
                    this.PrintJson("-100", "程序异常:" + ex.Message);
                }
                finally
                {
                    Response.End();
                }
                break;

                #endregion
            //获取微信用户信息
            case "getuserinfor":
                #region
                Response.ContentType = "application/json";
                try
                {
                    DateTime beginTime = DateTime.Now;
                    code = WEBRequest.GetQueryString("code");
                    //写入openid 因为code被使用过一次后,就会失效,缓存的openid就取不到。
                    string openId = WEBRequest.GetQueryString("openid");
                    if (openId.IsNotEmpty())
                    {
                        GlobalUtils.WriteOpenIdToCookie(openId);
                    }

                    ThirdLoginSDK sdk = new ThirdLoginSDK();
                    sdk.InitSDK(ThirdLoginSDK.ThirdLoginType.WeiXin);
                    //获取微信上用户信息
                    TuanDai.WXApiWeb.Common.ThirdLoginSDK.WXOAuthUser wxUserInfo = sdk.GetWXUserSubscribeInfor(code, openId.ToText());

                    var jsonStr = JsonHelper.ToJson(wxUserInfo);
                    this.PrintJson("1", jsonStr);
                    DateTime endTime = DateTime.Now;

                    LogClients.TraceLog("WXTouch", "微信授权时间差", openId, (endTime - beginTime).TotalMilliseconds.ToString());
                }
                catch (Exception ex)
                {
                    this.PrintJson("-100", "程序异常:" + ex.Message);
                    LogClients.ErrorLog("WXTouch", "微信授权错误", "", ex.Message + ex.StackTrace);
                }
                finally
                {
                    Response.End();
                }
                break;

                #endregion
            //获取Token
            case "getaccesstoken":
                #region
                string token       = WEBRequest.GetQueryString("Token");
                string configToken = ConfigHelper.getConfigString("APIKey");
                Response.ContentType = "application/json";
                try
                {
                    if (configToken != token)
                    {
                        this.PrintJson("99", "验证不通过!");
                        return;
                    }
                    //从同一个缓存中读取全局的Token
                    ThirdLoginSDK sdkApi = new ThirdLoginSDK();
                    sdkApi.InitSDK(ThirdLoginSDK.ThirdLoginType.WeiXin);
                    TuanDai.WXApiWeb.Common.ThirdLoginSDK.WXOAuth_Token accessToken = sdkApi.GetWXUserOpenIdByCgi(code);
                    var jsonStr = JsonHelper.ToJson(accessToken);
                    this.PrintJson("1", jsonStr);
                }
                catch (Exception ex)
                {
                    this.PrintJson("-100", "程序异常:" + ex.Message);
                }
                finally
                {
                    Response.End();
                }
                break;

                #endregion
            //App中活动登录
            case "appajaxlogin":
                #region
                Response.ContentType = "application/json";
                try
                {
                    string appActivityToken = WEBRequest.GetFormString("appActivityToken");
                    if (!string.IsNullOrEmpty(appActivityToken))
                    {
                        TuanDai.PortalSystem.Model.UserBasicInfoInfo model = new TuanDai.PortalSystem.BLL.AppUserTokenRecBLL().GetAppActivityUser(appActivityToken);
                        if (model != null)
                        {
                            string DOMAINNAME = ConfigurationManager.AppSettings["CookieDomain"];
                            Tool.CookieHelper.WriteCookie("TDW_WapUserName", model.UserName);
                            string strLastLoginDate = DateTime.Now.ToString("yyyy-MM-dd") + model.UserName;
                            if (string.IsNullOrEmpty(CookieHelper.GetCookie("TDLastLoginDate")) || CookieHelper.GetCookie("TDLastLoginDate") != strLastLoginDate)
                            {
                                TuanDai.PortalSystem.BLL.VipGetWorthBLL.AddGetWorth(model.Id, (int)ConstString.UserGrowthType.EveryDayFirstLogin, null, 0);
                            }

                            Tool.CookieHelper.WriteCookie(DOMAINNAME, "TDLastLoginDate", strLastLoginDate);
                            WebUserAuth.SignIn(model.Id.ToString());
                        }
                        else
                        {
                            WebUserAuth.SignOut();
                        }
                    }
                    this.PrintJson("1", "登录成功!");
                }
                catch (Exception ex)
                {
                    this.PrintJson("-1", ex.Message);
                }
                finally
                {
                    Response.End();
                }
                #endregion
                break;

            //获取用户推送开关设置
            case "getwxpushswitch":
                #region
                token       = WEBRequest.GetQueryString("Token");
                configToken = ConfigHelper.getConfigString("APIKey");
                string pushtype = WEBRequest.GetQueryString("PushType");
                Response.ContentType = "application/json";
                try
                {
                    if (configToken != token)
                    {
                        this.PrintJson("99", "验证不通过!");
                        return;
                    }
                    string strSQL = "SELECT DISTINCT OpenId FROM dbo.UserWXNotice WHERE ISNULL(OpenId,'')!=''";
                    if (pushtype.ToLower() == "wexnotice")
                    {
                        strSQL += " and  IsWeXNotice=1";
                    }
                    else if (pushtype.ToLower() == "actnotice")
                    {
                        strSQL += " and  IsActivityNotice=1";
                    }
                    else
                    {
                        strSQL += " and 1=0";
                    }
                    Dapper.DynamicParameters dyParams   = new Dapper.DynamicParameters();
                    List <string>            OpenIDList = PublicConn.QueryBySql <string>(strSQL, ref dyParams);
                    var jsonStr = JsonHelper.ToJson(OpenIDList);
                    this.PrintJson("1", jsonStr);
                }
                catch (Exception ex)
                {
                    this.PrintJson("-100", "程序异常:" + ex.Message);
                }
                finally
                {
                    Response.End();
                }
                #endregion
                break;
            }
        }
Example #8
0
        //领取红包
        private void AwardToGetPrize()
        {
            try
            {
                ThirdLoginSDK sdkApi = new ThirdLoginSDK();
                sdkApi.InitSDK(ThirdLoginSDK.ThirdLoginType.WeiXin);
                string OpenId = sdkApi.GetCookieOpenId("");
                Guid   userId = WebUserAuth.UserId.Value;
                //判断为空时不可领取
                if (userId == Guid.Empty || OpenId.ToText().IsEmpty())
                {
                    return;
                }

//                using (SqlConnection connection = WealthPage.OpenConnection(2))
//                {
//                    //判断是否有领取过
//                    string strSQL = "SELECT COUNT(1) AS cnt  FROM Activity_GodWealth_Record   WHERE  IsGetPrize=1 AND (WXOpenId=@WXOpenId OR UserId=@UserId)";
//                    DynamicParameters dyParams = new DynamicParameters();
//                    dyParams.Add("@WXOpenId", OpenId);
//                    dyParams.Add("@UserId", userId);
//                    int iCount = connection.Query<Int32>(strSQL, dyParams).FirstOrDefault();
//                    if (iCount > 0)
//                        return;
//                    //判断奖品是否已发送完毕
//                    WealthPage.ActivityConfigInfo configInfo = WealthPage.GetActivityConfig();
//                    if (configInfo == null || configInfo.UsePrizeNum >= configInfo.TotalPrizeNum)
//                        return;

//                    WealthPage.GodWealthRecordInfo recordInfo = WealthPage.GetUserGodWealthInfo(OpenId);
//                    //非过期时才可领取红包
//                    if (recordInfo.ExpirationDate.HasValue && recordInfo.ExpirationDate > DateTime.Now)
//                    {
//                        UserBLL userbll = new UserBLL();
//                        UserBasicInfoInfo userInfo = userbll.GetUserBasicInfoModelById(userId);
//                        strSQL = @" update Activity_GodWealth_Record set
//                                UserId=@UserId, UserName=@UserName,
//                                ExpirationDate=@ExpirationDate,
//                                GetPrizeDate=@GetPrizeDate, IsGetPrize=@IsGetPrize
//                                where WXOpenId=@WXOpenId";
//                        dyParams = new DynamicParameters();
//                        dyParams.Add("@WXOpenId", OpenId);
//                        dyParams.Add("@UserId", userInfo.Id);
//                        dyParams.Add("@UserName", userInfo.UserName);
//                        dyParams.Add("@ExpirationDate", null); //已获取奖品后这里清空
//                        dyParams.Add("@GetPrizeDate", DateTime.Now); //领取时间
//                        dyParams.Add("@IsGetPrize", 1); //标记已领取

//                        int iSuc = connection.Execute(strSQL, dyParams);
//                        if (iSuc > 0)
//                        {
//                            int outStatus = 0;
//                            SendUserPrizeInfo prizeInfo = new SendUserPrizeInfo();
//                            prizeInfo.UserId = userId;
//                            prizeInfo.PrizeName = "10元投资红包";
//                            prizeInfo.PrizeValue = 10;
//                            //规则: 新用户要投资500元才能使用10元,老用户投资1000元才能使用
//                            if (userInfo.AddDate >= configInfo.ActivityStartDate)
//                            {
//                                prizeInfo.RuleId = Guid.Parse("9dd159c3-712a-4bee-8857-640de08b9a9e");
//                                prizeInfo.Description = "团贷网&财神爷派红包活动-单笔投资满500元即可使用10元,过期时间为:" + DateTime.Today.AddMonths(1).AddDays(-1).ToString("yyyy/MM/dd");
//                            }
//                            else
//                            {
//                                prizeInfo.RuleId = Guid.Parse("918f88a9-f3f7-4687-b239-8db70c4e483b");//规则Id
//                                prizeInfo.Description = "团贷网&财神爷派红包活动-单笔投资满1000元即可使用10元,过期时间为:" + DateTime.Today.AddMonths(1).AddDays(-1).ToString("yyyy/MM/dd");
//                            }
//                            userbll.SendUserPrizeNew(prizeInfo, out  outStatus);
//                            //更新奖品数量
//                            if (outStatus == 1)
//                                WealthPage.UpdateUsedPrizeNum();
//                        }
//                    }
//                }
            }
            catch (Exception ex) {
                BusinessDll.NetLog.WriteLoginHandler("财神爷派红包活动领取奖品失败", ExceptionHelper.GetExceptionMessage(ex), "触屏版");
            }
        }
Example #9
0
        /*
         * 进来时逻辑判断:
         * 1.第一次直接扫码进来时,就显示上传图片界面。
         * 2.第二次扫码进来时,显示自已头像,显示好友个数。
         * 2.从第一位好友分享进来时。显示好友头像,再做相片
         * 3.从第二次好友分享进来时,显示自已头像,再加提示“红包已领取过”
         * 4. 活动已结束时,任何动作进来直接 显示自已头像,显示“活动已结束,感谢参与”
         * 5. 领取奖品结束时,自已进来时,显示“红包已过期”
         */

        private void InitPageData()
        {
            //读取活动的配置信息
            ActivityConfigInfo configInfo = GetActivityConfig();

            if (configInfo != null)
            {
                WealthPage.ActivityStartDate = configInfo.ActivityStartDate;
                WealthPage.ActivityEndDate   = configInfo.ActivityEndDate;
            }

            ThirdLoginSDK sdkApi = new ThirdLoginSDK();

            sdkApi.InitSDK(ThirdLoginSDK.ThirdLoginType.WeiXin);
            SelfOpenId = sdkApi.GetCookieOpenId(code);

            WealthPage.GodWealthRecordInfo wealthInfo = WealthPage.GetUserGodWealthInfo(SelfOpenId);
            #region 活动已结束情况
            if (WealthPage.ActivityEndDate <= DateTime.Now)
            {
                this.UserStatus = "1";
                //活动已结束时,这里显示自已的头像,姓名
                this.GetCaiShengInfo(wealthInfo);
                return;
            }
            #endregion

            //判断奖品是否已发送完毕 (前提自已没有当过财神进来时才提示)
            if (configInfo == null || (wealthInfo == null && configInfo.UsePrizeNum >= configInfo.TotalPrizeNum))
            {
                //活动已结束时,这里显示自已的头像,姓名
                wealthInfo = WealthPage.GetUserGodWealthInfo(ExtendKey != "" ? ExtendKey : SelfOpenId);
                this.GetCaiShengInfo(wealthInfo);
                this.UserStatus = "6";
                return;
            }

            //自已直接进来或点自已分享链接时
            if (ExtendKey.IsEmpty() || ExtendKey == SelfOpenId)
            {
                #region 自已做财神
                wealthInfo = WealthPage.GetUserGodWealthInfo(SelfOpenId);
                if (wealthInfo == null)
                {
                    this.UserStatus = "2";
                    return;
                }
                else
                {
                    this.UserStatus = "3";
                    this.GetCaiShengInfo(wealthInfo);
                    RedPackedStatus = CheckRedPacketStatus().ToString();
                }
                #endregion
            }
            else
            {
                #region 好友派发红包时
                WealthPage.GodWealthRecordInfo selfWealthInfo = WealthPage.GetUserGodWealthInfo(SelfOpenId);
                if (selfWealthInfo != null)
                {
                    //第二个好友分享后,点进来判断有领过红包
                    this.GetCaiShengInfo(selfWealthInfo);
                    this.UserStatus = "5";
                }
                else
                {
                    wealthInfo = WealthPage.GetUserGodWealthInfo(ExtendKey);
                    //如果财神爷数据找不到,就跳转
                    if (wealthInfo == null)
                    {
                        Response.Redirect(GlobalUtils.WebURL + "/Activity/GodWealth/AuthorIndex.aspx");
                        return;
                    }
                    this.UserStatus = "4";
                    this.GetCaiShengInfo(wealthInfo);
                }
                #endregion
            }
        }
Example #10
0
        public void GetGodSendRedPacket()
        {
            try
            {
                Response.ContentType = "application/json";
                string ExtendOpenId = WEBRequest.GetFormString("extendkey"); //财神爷OpenId

                if (DateTime.Now < WealthPage.ActivityStartDate)
                {
                    PrintJson("-3", "您来得太早了,活动还未开始!");
                    return;
                }
                if (DateTime.Now > WealthPage.ActivityEndDate)
                {
                    PrintJson("-3", "您来得太晚了,活动已结束了!");
                    return;
                }

                if (ExtendOpenId.IsNotEmpty())
                {
                    if (!WealthPage.CheckGodIsExists(ExtendOpenId))
                    {
                        PrintJson("-3", "对不起,该财神爷不存在!");
                        return;
                    }
                }
                ThirdLoginSDK sdkApi = new ThirdLoginSDK();
                sdkApi.InitSDK(ThirdLoginSDK.ThirdLoginType.WeiXin);
                string OpenId = sdkApi.GetCookieOpenId("");

                bool isGetHisPrize = WealthPage.CheckUserHasGetRedPacket(ExtendOpenId, OpenId);
                if (isGetHisPrize)
                {
                    //这里必须要判断自已是否有做过财神,不然没法得到红包
                    WealthPage.GodWealthRecordInfo wealthInfo = WealthPage.GetUserGodWealthInfo(SelfOpenId);
                    if (wealthInfo != null)
                    {
                        PrintJson("-2", "对不起,您已经领过他派的红包!");
                    }
                    else
                    {
                        PrintJson("1", "");
                    }
                    return;
                }
//                using (SqlConnection connection = WealthPage.OpenConnection(2))
//                {
//                    string strSQL = @"insert into Activity_GodWealth_Friend(Id,WXOpenId,FriendOpenId,UserAgent,AddDate)
//                                  values(@Id,@WXOpenId,@FriendOpenId,@UserAgent,@AddDate)";

//                    DynamicParameters dyParams = new DynamicParameters();
//                    dyParams.Add("@Id", Guid.NewGuid());
//                    dyParams.Add("@WXOpenId", ExtendOpenId);
//                    dyParams.Add("@FriendOpenId", OpenId);
//                    //获取用户浏览器信息
//                    string strAgent = "";
//                    strAgent += string.Format("用户IP: {0}\r\n", Tool.WebFormHandler.GetIP());
//                    strAgent += string.Format("用户浏览器: {0}\r\n", HttpContext.Current.Request.UserAgent);
//                    dyParams.Add("@UserAgent", strAgent);
//                    dyParams.Add("@AddDate", DateTime.Now);
//                    int iCount = connection.Execute(strSQL, dyParams);
//                    //领取成功时,更新财神爷派发个数
//                    if (iCount > 0)
//                    {
//                        strSQL = " update Activity_GodWealth_Record set FriendNum=isnull(FriendNum,0)+1 where WXOpenId=@WXOpenId";
//                        dyParams = new DynamicParameters();
//                        dyParams.Add("@WXOpenId", ExtendOpenId);
//                        connection.Execute(strSQL, dyParams);
//                    }
//                }
                PrintJson("1", "");
            }
            catch (Exception ex)
            {
                BusinessDll.NetLog.WriteLoginHandler("财神爷活动上传图片出错", Tool.ExceptionHelper.GetExceptionMessage(ex), "触屏版");
                PrintJson("0", "获取红包失败!");
            }
            finally
            {
                Response.End();
            }
        }
Example #11
0
        public void DoMakeWealthGod()
        {
            try
            {
                Response.ContentType = "application/json";
                string nickName  = this.Request.Form["nickName"];
                string base64Img = this.Request.Form["base64Img"];

                string godImagePath = "";
                //上传头像
                bool saveImg = SaveHeadImage(base64Img, ref godImagePath);
                if (!saveImg)
                {
                    PrintJson("-1", "上传头像失败!");
                    return;
                }

                if (DateTime.Now < WealthPage.ActivityStartDate)
                {
                    PrintJson("-3", "您来得太早了,活动还未开始!");
                    return;
                }
                if (DateTime.Now > WealthPage.ActivityEndDate)
                {
                    PrintJson("-3", "您来得太晚了,活动已结束了!");
                    return;
                }


                ThirdLoginSDK sdkApi = new ThirdLoginSDK();
                sdkApi.InitSDK(ThirdLoginSDK.ThirdLoginType.WeiXin);
                string OpenId = sdkApi.GetCookieOpenId("");
                if (OpenId.IsEmpty())
                {
                    PrintJson("-2", "微信授权失败,请重试!");
                    return;
                }
                bool isLogin = WebUserAuth.IsAuthenticated;
                Guid?userId  = WebUserAuth.UserId;
//                using (SqlConnection connection = WealthPage.OpenConnection(2))
//                {
//                    string strSQL = " select count(1) as cnt from Activity_GodWealth_Record where WXOpenId=@WXOpenId";
//                    DynamicParameters dyParams = new DynamicParameters();
//                    dyParams.Add("@WXOpenId", OpenId);
//                    int iCount = connection.Query<Int32>(strSQL, dyParams).FirstOrDefault();
//                    if (iCount > 0)
//                    {
//                        PrintJson("-1", "您已做过一回财神!");
//                        return;
//                    }

//                    strSQL = @" insert into Activity_GodWealth_Record(Id,UserId,UserName,WXOpenId,ShowName,GodImage,FriendNum,AddDate,ExpirationDate,GetPrizeDate,IsGetPrize)
//                                values(@Id,@UserId,@UserName,@WXOpenId,@ShowName,@GodImage,@FriendNum,@AddDate,@ExpirationDate,@GetPrizeDate,@IsGetPrize)";
//                    dyParams = new DynamicParameters();
//                    dyParams.Add("@Id", Guid.NewGuid());
//                    dyParams.Add("@UserId", null);
//                    dyParams.Add("@UserName", "");
//                    dyParams.Add("@WXOpenId", OpenId);
//                    dyParams.Add("@ShowName", nickName);
//                    dyParams.Add("@GodImage", godImagePath);
//                    dyParams.Add("@FriendNum", 0);
//                    dyParams.Add("@AddDate", DateTime.Now);
//                    dyParams.Add("@ExpirationDate", DateTime.Today.AddMonths(1));
//                    dyParams.Add("@GetPrizeDate", null);
//                    dyParams.Add("@IsGetPrize", 0);
//                    bool isSuccess = connection.Execute(strSQL, dyParams) > 0;
//                    if (isSuccess)
//                    {
//                        var responseObj = new { result = "1", NickName = nickName, GodImage = godImagePath };
//                        PrintJson(responseObj);
//                        return;
//                    }
//                    else
//                    {
//                        PrintJson("-1", "做财神失败,请重试!");
//                        return;
//                    }
//                }
            }
            catch (Exception ex)
            {
                PrintJson("-1", "做财神失败,请重试!");
                BusinessDll.NetLog.WriteLoginHandler("财神爷活动上传图片出错", Tool.ExceptionHelper.GetExceptionMessage(ex), "触屏版");
            }
            finally {
                Response.End();
            }
        }
Example #12
0
        public static string SeekMyLover(string base64Img)
        {
            try
            {
                string HeadImage = "";
                //上传头像
                bool saveImg = SaveHeadImage(base64Img, ref HeadImage);
                if (!saveImg)
                {
                    return(PrintJson("-1", "上传头像失败!"));
                }

                Dictionary <string, string> templateDict = GetLoverTemplate();
                int rIndex = rand.Next(templateDict.Count);
                if (rIndex < 1 || rIndex > templateDict.Count)
                {
                    rIndex = 0;
                }
                string seekLover    = templateDict.ElementAt(rIndex).Key;//匹配到的情人
                string seekLoverImg = templateDict.ElementAt(rIndex).Value;

                int    MatchMark  = GetRandomMark();
                int    BeautyMark = GetRandomMark();
                string SelfOpenId = "";
                try
                {
                    ThirdLoginSDK sdkApi = new ThirdLoginSDK();
                    sdkApi.InitSDK(ThirdLoginSDK.ThirdLoginType.WeiXin);
                    SelfOpenId = sdkApi.GetCookieOpenId("");
                }
                catch {
                    SelfOpenId = "";
                }

                //using (SqlConnection connection = new SqlConnection(TuanDai.Config.BaseConfig.ActivityConnectionString))
//                {
//                    string strSQL = @"insert into Activity_SeekLover_Record(Id,UserId,UserName,WXOpenId,HeadImage,MatchMark,BeautyMark,SeekLover,AddDate,UserAgent)
//                                     values(@Id,@UserId,@UserName,@WXOpenId,@HeadImage,@MatchMark,@BeautyMark,@SeekLover,@AddDate,@UserAgent)";

//                    DynamicParameters dyParams = new DynamicParameters();
//                    dyParams.Add("@Id", Guid.NewGuid());

//                    #region 用户数据
//                    if (WebUserAuth.IsAuthenticated)
//                    {
//                        UserBLL userbll = new UserBLL();
//                        UserBasicInfoInfo userInfo = userbll.GetUserBasicInfoModelById(WebUserAuth.UserId.Value);
//                        if (userInfo != null)
//                        {
//                            dyParams.Add("@UserId", userInfo.Id);
//                            dyParams.Add("@UserName", userInfo.UserName);
//                        }
//                        else
//                        {
//                            dyParams.Add("@UserId", null);
//                            dyParams.Add("@UserName", "");
//                        }
//                    }
//                    else
//                    {
//                        dyParams.Add("@UserId", null);
//                        dyParams.Add("@UserName", "");
//                    }
//                    #endregion
//                    dyParams.Add("@WXOpenId", SelfOpenId);
//                    dyParams.Add("@HeadImage", HeadImage);
//                    dyParams.Add("@MatchMark", MatchMark);
//                    dyParams.Add("@BeautyMark", BeautyMark);
//                    dyParams.Add("@SeekLover", seekLover);
//                    dyParams.Add("@AddDate", DateTime.Now);
//                    //获取用户浏览器信息
//                    string strAgent = "";
//                    strAgent += string.Format("用户IP: {0}\r\n", Tool.WebFormHandler.GetIP());
//                    strAgent += string.Format("用户浏览器: {0}\r\n", HttpContext.Current.Request.UserAgent);
//                    dyParams.Add("@UserAgent", strAgent);
//                    int iSuc = connection.Execute(strSQL, dyParams);

//                    if (iSuc > 0)
//                    {
//                        LoverInfo infor = new LoverInfo();
//                        infor.result = "1";
//                        infor.LoverName = seekLover;
//                        infor.LoverImage = seekLoverImg;
//                        infor.HeadImage = HeadImage;
//                        infor.MatchMark = MatchMark;
//                        infor.BeautyMark = BeautyMark;
//                        return PrintJson(infor);
//                    }
//                    else
//                    {
//                        return PrintJson("0", "保存头像失败!");
//                    }
//                }
                return("");
            }
            catch (Exception ex)
            {
                NetLog.WriteLoginHandler("速配情人活动出错", Tool.ExceptionHelper.GetExceptionMessage(ex), "触屏版");
                return(PrintJson("-100", "程序异常"));
            }
        }