Ejemplo n.º 1
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();
        }
Ejemplo n.º 2
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
            }
        }
Ejemplo n.º 3
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();
            }
        }