Ejemplo n.º 1
0
        public void ProcessRequest(HttpContext context)
        {
            string autoIds   = context.Request["uids"];
            string lotteryId = context.Request["lottery_id"];

            if (string.IsNullOrEmpty(lotteryId))
            {
                apiResp.msg  = "活动抽奖id为空";
                apiResp.code = (int)BLLJIMP.Enums.APIErrCode.IsNotFound;
                bllUser.ContextResponse(context, apiResp);
                return;
            }

            string[] ids    = autoIds.Split(',');
            bool     result = false;

            foreach (var item in ids)
            {
                UserInfo userInfo = bllUser.GetUserInfoByAutoID(int.Parse(item));
                if (userInfo == null)
                {
                    continue;
                }
                BLLJIMP.Model.LotteryUserInfo model = bllUser.Get <BLLJIMP.Model.LotteryUserInfo>(string.Format(" WebsiteOwner='{0}' AND LotteryId={1} AND UserId='{2}' ", bllUser.WebsiteOwner, lotteryId, userInfo.UserID));
                if (model == null)
                {
                    model = new BLLJIMP.Model.LotteryUserInfo();
                    model.WebsiteOwner = bllUser.WebsiteOwner;
                    model.WXHeadimgurl = !string.IsNullOrEmpty(userInfo.WXHeadimgurl) ? userInfo.WXHeadimgurl : "http://file.comeoncloud.net/img/europejobsites.png";
                    model.WXNickname   = bllUser.GetUserDispalyName(userInfo);
                    model.UserId       = userInfo.UserID;
                    model.CreateDate   = DateTime.Now;
                    model.WinnerDate   = DateTime.Now;
                    model.LotteryId    = Convert.ToInt32(lotteryId);
                    result             = bllUser.Add(model);
                }
                else
                {
                    result = true;
                }
            }
            if (result)
            {
                int count = bllUser.GetCount <BLLJIMP.Model.LotteryUserInfo>(string.Format(" WebsiteOwner='{0}' AND LotteryID={1}", bllUser.WebsiteOwner, lotteryId));
                bllUser.UpdateByKey <WXLotteryV1>("LotteryID", lotteryId, "WinnerCount", count.ToString());
                apiResp.msg    = "添加参与者成功";
                apiResp.status = true;
            }
            else
            {
                apiResp.msg  = "添加参与者失败";
                apiResp.code = (int)BLLJIMP.Enums.APIErrCode.OperateFail;
            }
            bllUser.ContextResponse(context, apiResp);
        }
Ejemplo n.º 2
0
        public void ProcessRequest(HttpContext context)
        {
            string lotteryId = context.Request["lottery_id"];

            curUser = bllUser.GetCurrentUserInfo();

            if (string.IsNullOrEmpty(lotteryId))
            {
                apiResp.msg  = "抽奖活动id为空";
                apiResp.code = (int)BLLJIMP.Enums.APIErrCode.IsNotFound;
                bllUser.ContextResponse(context, apiResp);
                return;
            }

            BLLJIMP.Model.LotteryUserInfo model = bllUser.Get <BLLJIMP.Model.LotteryUserInfo>(string.Format(" WebsiteOwner='{0}' AND LotteryId={1} AND UserId='{2}' ", bllUser.WebsiteOwner, lotteryId, curUser.UserID));
            if (model != null)
            {
                apiResp.msg  = "您已参加抽奖";
                apiResp.code = (int)BLLJIMP.Enums.APIErrCode.IsRepeat;
                bllUser.ContextResponse(context, apiResp);
                return;
            }
            model = new BLLJIMP.Model.LotteryUserInfo();
            model.WebsiteOwner = bllUser.WebsiteOwner;
            model.CreateDate   = DateTime.Now;
            model.WinnerDate   = DateTime.Now;
            model.IsWinning    = 0;
            model.LotteryId    = Convert.ToInt32(lotteryId);
            model.UserId       = curUser.UserID;
            model.WXHeadimgurl = curUser.WXHeadimgurl;
            model.WXNickname   = bllUser.GetUserDispalyName(curUser);
            if (model.WXNickname.Trim() == string.Empty)
            {
                apiResp.msg  = "无昵称不能加入";
                apiResp.code = (int)BLLJIMP.Enums.APIErrCode.OperateFail;
                bllUser.ContextResponse(context, apiResp);
                return;
            }
            if (bllUser.Add(model))
            {
                int count = bllUser.GetCount <BLLJIMP.Model.LotteryUserInfo>(string.Format(" WebsiteOwner='{0}' AND LotteryID={1}", bllUser.WebsiteOwner, lotteryId));
                bllUser.UpdateByKey <WXLotteryV1>("LotteryID", lotteryId, "WinnerCount", count.ToString());
                apiResp.msg    = "加入成功";
                apiResp.status = true;
            }
            else
            {
                apiResp.msg  = "加入失败";
                apiResp.code = (int)BLLJIMP.Enums.APIErrCode.OperateFail;
            }
            bllUser.ContextResponse(context, apiResp);
        }
Ejemplo n.º 3
0
        public void ProcessRequest(HttpContext context)
        {
            string id        = context.Request["id"];
            string lotteryId = context.Request["lottery_id"];

            if (string.IsNullOrEmpty(id))
            {
                apiResp.msg  = "id不能为空";
                apiResp.code = (int)BLLJIMP.Enums.APIErrCode.IsNotFound;
                bllUser.ContextResponse(context, apiResp);
                return;
            }

            BLLJIMP.Model.LotteryUserInfo model = bllUser.Get <BLLJIMP.Model.LotteryUserInfo>(string.Format(" WebsiteOwner='{0}' AND AutoId={1}", bllUser.WebsiteOwner, id));
            if (model == null)
            {
                apiResp.msg  = "抽奖用户不存在";
                apiResp.code = (int)BLLJIMP.Enums.APIErrCode.IsNotFound;
                bllUser.ContextResponse(context, apiResp);
                return;
            }
            model.IsWinning  = 1;
            model.WinnerDate = DateTime.Now;
            int count = bllUser.GetCount <BLLJIMP.Model.LotteryUserInfo>(string.Format(" WebsiteOwner='{0}' AND LotteryId={1} AND IsWinning=1", bllUser.WebsiteOwner, lotteryId));

            model.Number = count + 1;
            if (bllUser.Update(model))
            {
                apiResp.msg    = model.Number.ToString();
                apiResp.status = true;
            }
            else
            {
                apiResp.msg  = "中奖失败";
                apiResp.code = (int)BLLJIMP.Enums.APIErrCode.OperateFail;;
            }
            bllUser.ContextResponse(context, apiResp);
        }