public ActionResult GetLuckyTicketLogList()
        {
            GetCampaign_LuckyTicketLogListByMemberArgs args = RequestArgs <GetCampaign_LuckyTicketLogListByMemberArgs>();

            if (args == null)
            {
                return(RespondResult(false, "参数无效。"));
            }

            args.MemberId = MemberContext.Member.Id;
            args.DomainId = DomainContext.Domain.Id;
            args.AppId    = DomainContext.AppId;

            GetItemListResult result = _campaignManager.LuckyTicket.GetMemberLuckyTicketLogList(args);

            //为自己生成一个
            if (result.Page == 1 && result.TotalCount == 0)
            {
                Campaign_LuckyTicketLogEntity createLuckyTicketLogArgs = new Campaign_LuckyTicketLogEntity();
                createLuckyTicketLogArgs.CampaignId = args.CampaignId;
                createLuckyTicketLogArgs.Domain     = DomainContext.Domain.Id;
                createLuckyTicketLogArgs.Member     = MemberContext.Member.Id;
                createLuckyTicketLogArgs.FromOpenId = MemberContext.Member.OpenId;
                _campaignManager.LuckyTicket.CreateLuckyTicketLog(createLuckyTicketLogArgs);
                result = _campaignManager.LuckyTicket.GetMemberLuckyTicketLogList(args);
            }

            return(RespondDataResult(result));
        }
        /// <summary>
        /// 创建一个抽奖号码
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        public bool CreateLuckyTicketLog(Campaign_LuckyTicketLogEntity args)
        {
            if (args == null)
            {
                return(false);
            }

            //先判断指定的的OpenId有没有帮MemberId生成过
            List <CommandParameter> parameterList = new List <CommandParameter>();

            parameterList.Add(new CommandParameter("@campaignId", args.CampaignId));
            parameterList.Add(new CommandParameter("@memberId", args.Member));
            parameterList.Add(new CommandParameter("@fromOpenId", args.FromOpenId));

            int intStatus = 0;

            _campaignManager.DataBase.ExecuteScalar <int>(
                "SELECT Count(1) FROM [Campaign_LuckyTicketLog] WHERE [CampaignId] = @campaignId AND [Member] = @memberId AND [FromOpenId] = @fromOpenId",
                parameterList, (scalarValue) => { intStatus = scalarValue; });

            if (intStatus > 0)
            {
                return(false);
            }

            //生成一个抽奖号码
            args.CreateTime   = DateTime.Now;
            args.TicketNumber = _campaignManager.DomainManager.GetRandomSerialNumber("Campaign_LuckyTicket");

            if (String.IsNullOrEmpty(args.TicketNumber))
            {
                _campaignManager.Log.Write("抽奖号码生成失败。", JsonHelper.Serializer(args), TraceEventType.Warning);
                return(false);
            }

            _campaignManager.DataBase.Insert(args);

            return(true);
        }
        public ActionResult LuckyTicketShare()
        {
            string strCampaignId = Request.QueryString["campaignId"];
            string strMemberId   = Request.QueryString["memberId"];

            if (String.IsNullOrEmpty(strCampaignId) || String.IsNullOrEmpty(strMemberId))
            {
                return(RespondResult(false, "参数无效。"));
            }

            Guid campaignId = Guid.Parse(strCampaignId);

            //递增活动页面PV
            _campaignManager.PageVisit(campaignId);

            //为原分享人创建一个抽奖号码
            Campaign_LuckyTicketLogEntity createLuckyTicketLogArgs = new Campaign_LuckyTicketLogEntity();

            createLuckyTicketLogArgs.CampaignId = campaignId;
            createLuckyTicketLogArgs.Domain     = DomainContext.Domain.Id;
            createLuckyTicketLogArgs.Member     = Guid.Parse(strMemberId);
            createLuckyTicketLogArgs.FromOpenId = OpenId;
            _campaignManager.LuckyTicket.CreateLuckyTicketLog(createLuckyTicketLogArgs);

            //判断当前访问者是否已关注
            //已关注引导到活动页面,未关注引导到引导关注页面
            if (MemberContext != null)
            {
                return(RedirectToAction("LuckyTicket",
                                        new { domainId = DomainContext.Domain.Id, campaignId = strCampaignId }));
            }
            else
            {
                return(new RedirectResult(String.Format(
                                              "~/Home/CampaignGuideSubscribe/{0}?campaignId={1}", DomainContext.Domain.Id, strCampaignId)));
            }
        }