Esempio n. 1
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            //context.Response.Write("Hello World");
            string oper = context.Request["oper"].ConvertTo <string>("");

            if (oper != "")
            {
                if (oper == "dzp_choujiang")
                {
                    var Id     = context.Request["Id"].ConvertTo <int>(0);
                    var openid = context.Request["openid"].ConvertTo <string>("");
                    var ygj    = context.Request["ygj"].ConvertTo <string>("");

                    ERNIE_Record Recorduser = new ERNIE_Record()
                    {
                        ERNIE_id     = Id,
                        ERNIE_openid = openid,
                    };
                    var data = PromotionJsonDate.ERNIEChoujiang(Recorduser);
                    context.Response.Write(data);
                }

                if (oper == "huodong_tel")
                {
                    var Id      = context.Request["Id"].ConvertTo <int>(0);
                    var openid  = context.Request["openid"].ConvertTo <string>("");
                    var ygj     = context.Request["ygj"].ConvertTo <string>("");
                    var udid    = context.Request["udid"].ConvertTo <int>(0);
                    var hdtel   = context.Request["hdtel"].ConvertTo <string>("");
                    var hduname = context.Request["hduname"].ConvertTo <string>("");



                    ERNIE_Record Recorduser = new ERNIE_Record()
                    {
                        ERNIE_id     = Id,
                        ERNIE_openid = openid,
                        Name         = hduname,
                        Phone        = hdtel,
                        Id           = udid,
                    };
                    var data = PromotionJsonDate.ERNIEZhongjiang(Recorduser);
                    context.Response.Write(data);
                }

                if (oper == "huojiang")
                {
                    var Id     = context.Request["Id"].ConvertTo <int>(0);
                    var openid = context.Request["openid"].ConvertTo <string>("");

                    var data = PromotionJsonDate.Huojiangmingdan(Id, openid);
                    context.Response.Write(data);
                }
            }
        }
Esempio n. 2
0
        public int ERNIEZhongjiang(ERNIE_Record Recordinfo)
        {
            const string sqltxt = @"update [Member_Act_ERNIE_Record] set Name=@Name,Phone=@Phone where ERNIE_id = @ERNIE_id and id=@Id and ERNIE_openid= @ERNIE_openid ";
            var          cmd    = this.sqlHelper.PrepareTextSqlCommand(sqltxt);

            cmd.AddParam("@Id", Recordinfo.Id);
            cmd.AddParam("@ERNIE_openid", Recordinfo.ERNIE_openid);
            cmd.AddParam("@ERNIE_id", Recordinfo.ERNIE_id);
            cmd.AddParam("@Name", Recordinfo.Name);
            cmd.AddParam("@Phone", Recordinfo.Phone);
            return(cmd.ExecuteNonQuery());
        }
Esempio n. 3
0
        public int InsertChoujiang(ERNIE_Record Recordinfo)
        {
            const string sqltxt = @"insert [Member_Act_ERNIE_Record] (ERNIE_id,ERNIE_uid,ERNIE_openid,ERNIE_code,ERNIE_time,ip)values(@ERNIE_id,@ERNIE_uid,@ERNIE_openid,@ERNIE_code,@ERNIE_time,@Ip) ;select @@identity;";
            var          cmd    = this.sqlHelper.PrepareTextSqlCommand(sqltxt);

            cmd.AddParam("@ERNIE_id", Recordinfo.ERNIE_id);
            cmd.AddParam("@ERNIE_uid", Recordinfo.ERNIE_uid);
            cmd.AddParam("@ERNIE_openid", Recordinfo.ERNIE_openid);
            cmd.AddParam("@ERNIE_code", Recordinfo.ERNIE_code);
            cmd.AddParam("@ERNIE_time", Recordinfo.ERNIE_time);
            cmd.AddParam("@Ip", Recordinfo.Ip);
            object o     = cmd.ExecuteScalar();
            int    newId = o == null ? 0 : int.Parse(o.ToString());

            return(newId);
        }
Esempio n. 4
0
        public static int ERNIEZhongjiang(ERNIE_Record Recordinfo)
        {
            using (var sql = new SqlHelper())
            {
                try
                {
                    var internalData = new InternalMemberERNIED(sql);
                    int result       = internalData.ERNIEZhongjiang(Recordinfo);

                    return(result);
                }
                catch
                {
                    throw;
                }
            }
        }
Esempio n. 5
0
        public static int SearchChoujiang(ERNIE_Record Recordinfo, int ERNIE_Limit)
        {
            using (var sql = new SqlHelper())
            {
                try
                {
                    var internalData = new InternalMemberERNIED(sql);
                    int result       = internalData.SearchChoujiang(Recordinfo, ERNIE_Limit);

                    return(result);
                }
                catch
                {
                    throw;
                }
            }
        }
Esempio n. 6
0
        public int SearchChoujiang(ERNIE_Record Recordinfo, int ERNIE_Limit)
        {
            string sqltxt = @"select count(id) as num from [Member_Act_ERNIE_Record] where (ERNIE_uid= " + Recordinfo.ERNIE_uid + "  or ERNIE_openid='" + Recordinfo.ERNIE_openid + "') and ERNIE_id=" + Recordinfo.ERNIE_id + "";

            if (ERNIE_Limit == 1)
            {
                sqltxt = sqltxt + " and ERNIE_time>='" + DateTime.Today + "'";
            }
            var cmd = this.sqlHelper.PrepareTextSqlCommand(sqltxt);

            using (var reader = cmd.ExecuteReader())
            {
                if (reader.Read())
                {
                    int num = reader.GetValue <int>("num");

                    return(num);
                }
            }
            return(0);
        }
Esempio n. 7
0
        public static string ERNIEZhongjiang(ERNIE_Record Recordinfo)
        {
            MemberERNIEData ernieddate = new MemberERNIEData();
            string          rtstr      = "";//返回文字

            try
            {
                var pror = ernieddate.ERNIERecordInfo(Recordinfo.Id);//查询中奖纪录
                if (pror != null)
                {
                    if (pror.Process_state == 0)
                    {
                        var pro = MemberERNIEData.ERNIEZhongjiang(Recordinfo);//中奖提交

                        if (pro > 0)
                        {
                            var proernie = MemberERNIEData.ERNIEGetActById(Recordinfo.ERNIE_id);//查询活动
                            if (proernie != null)
                            {
                                var prow = MemberERNIEData.ERNIEGetAwardById(pror.Awardid);//查询奖品纪录,成功状态修改为中奖奖品级别

                                if (prow != null)
                                {
                                    if (prow.Award_type == 2)//必须是赠送积分的才会自动赠送
                                    {
                                        //中奖状态修改,为已处理
                                        var prochuli = MemberERNIEData.ERNIEZhongjiangChuli(Recordinfo.Id);
                                        if (prochuli > 0)
                                        {
                                            //插入积分
                                            MemberIntegralData intdate = new MemberIntegralData();
                                            Member_Integral    Intinfo = new Member_Integral()
                                            {
                                                Id        = pror.ERNIE_uid,
                                                Comid     = proernie.Com_id,
                                                Acttype   = "add_integral",       //操作类型
                                                Money     = prow.Award_Get_Num,   //交易金额
                                                Admin     = proernie.Title,
                                                Ip        = CommonFunc.GetRealIP(),
                                                Ptype     = 1,
                                                Oid       = 0,
                                                Remark    = "",
                                                OrderId   = 0,
                                                OrderName = ""
                                            };
                                            pro = intdate.InsertOrUpdate(Intinfo);
                                            //抽奖赠送等积分
                                            B2bcrm_dengjifenlog djflog = new B2bcrm_dengjifenlog
                                            {
                                                id        = 0,
                                                crmid     = pror.ERNIE_uid,
                                                dengjifen = prow.Award_Get_Num,
                                                ptype     = 1,
                                                opertor   = "抽奖赠送等积分",
                                                opertime  = DateTime.Now,
                                                orderid   = 0,
                                                ordername = "抽奖赠送等积分",
                                                remark    = "抽奖赠送等积分"
                                            };
                                            new B2bCrmData().Adjust_dengjifen(djflog, pror.ERNIE_uid, proernie.Com_id, prow.Award_Get_Num);

                                            if (pro > 0)
                                            {
                                                rtstr = "您中奖的" + prow.Award_Get_Num + "元,已经打入您的积分中,请查收!";
                                            }
                                            else
                                            {
                                                rtstr = "中奖信息已经提交成功!";
                                            }
                                        }
                                        else
                                        {
                                            rtstr = "中奖信息已经提交成功!";
                                        }
                                    }
                                    else
                                    {
                                        rtstr = "中奖信息已经提交成功!";
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        return(JsonConvert.SerializeObject(new { rt = -1, msg = "中奖信息提交失败" }));
                    }
                    return(JsonConvert.SerializeObject(new { rt = 1, msg = rtstr }));
                }
                else
                {
                    return(JsonConvert.SerializeObject(new { rt = -1, msg = "中奖信息提交失败!" }));
                }
            }
            catch (Exception ex)
            {
                return(JsonConvert.SerializeObject(new { rt = -1, msg = ex.Message }));

                throw;
            }
        }
Esempio n. 8
0
        public static string ERNIEChoujiang(ERNIE_Record recordinfo)
        {
            //先产生个随机码超出范围的随机号,后面根据活动设定重新获得随机号,防止没有查询到活动时无返回随机码
            Random ra   = new Random();
            var    code = ra.Next(98888888, 99888888);

            try
            {
                //先判断活动
                var erniedate = MemberERNIEData.ERNIEGetActById(recordinfo.ERNIE_id);
                if (erniedate != null)
                {
                    if (erniedate.Runstate == 1 && erniedate.Online == 1 && erniedate.ERNIE_star < DateTime.Now)
                    {                                                      //运行中,在起始时间内
                        if (erniedate.ERNIE_end.AddDays(1) < DateTime.Now) //超出日期则显示活动已经结束,时间按结束日期的23:59:59秒
                        {
                            return(JsonConvert.SerializeObject(new { error = "此次活动已经结束", sn = code, success = false }));
                        }



                        code = ra.Next((98888888 - erniedate.ERNIE_RateNum), 98888888);
                        recordinfo.ERNIE_code = code;                   //赋值随机码
                        recordinfo.Ip         = CommonFunc.GetRealIP(); //记录IP
                        recordinfo.ERNIE_time = DateTime.Now;           //记录时间

                        //读取用户信息
                        B2bCrmData crmmodel   = new B2bCrmData();
                        B2b_crm    memberinfo = crmmodel.b2b_crmH5(recordinfo.ERNIE_openid, erniedate.Com_id);
                        if (memberinfo != null)
                        {
                            recordinfo.ERNIE_uid = memberinfo.Id;                                      //读取用户ID,必须是已关注用户才能抽奖

                            var ERNIE_Limit = erniedate.ERNIE_Limit;                                   //抽奖频率
                            var Limit_Num   = erniedate.Limit_Num;                                     //抽奖次数

                            var searchdate = MemberERNIEData.SearchChoujiang(recordinfo, ERNIE_Limit); //查询是否抽过奖
                            if (searchdate < Limit_Num)
                            {
                                var insertdate = MemberERNIEData.InsertChoujiang(recordinfo);//插入抽奖

                                //判断是否中奖。可以重复,按指定
                                var panduanchoujiang = MemberERNIEData.ChoujiangSearchAwardcode(insertdate, recordinfo.ERNIE_id);
                                if (panduanchoujiang > 0)
                                { //如果中奖,
                                    //处理中奖,返回中奖级别
                                    var zhongjiang = MemberERNIEData.ZhongjiangAwardcode(insertdate, panduanchoujiang, memberinfo.Id);
                                    if (zhongjiang > 0)
                                    {
                                        return(JsonConvert.SerializeObject(new { error = "", insert_id = insertdate, success = true, prizetype = zhongjiang, sn = code }));
                                    }
                                }
                            }
                            else
                            {
                                return(JsonConvert.SerializeObject(new { error = "您已经参加过抽奖活动", sn = code, success = false }));
                            }
                        }
                        else
                        {
                            return(JsonConvert.SerializeObject(new { error = "只有关注微信用户才能参与抽奖", sn = code, success = false }));
                        }
                    }
                    else
                    {
                        return(JsonConvert.SerializeObject(new { error = "活动尚未开始,请稍后再关注", sn = code, success = false }));
                    }
                }

                return(JsonConvert.SerializeObject(new { error = "", sn = code, success = false }));
            }
            catch (Exception ex)
            {
                return(JsonConvert.SerializeObject(new { error = "", sn = code, success = false }));

                throw;
            }
        }
Esempio n. 9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            shijianchuo = DateTime.Now.ToString("yyyyMMddhhmmssfff");

            string u  = Request.ServerVariables["HTTP_USER_AGENT"];
            bool   bo = detectmobilebrowser.HttpUserAgent(u);

            RequestUrl = Request.ServerVariables["SERVER_NAME"].ToLower();
            try
            {
                //根据域名读取商户ID,如果没有绑定域名直接跳转后台
                if (Domain_def.Domain_yanzheng(RequestUrl))//如果符合shop101.etown.cn的格式,则从多微信商户基本信息表中获取comid
                {
                    //先通过正则表达式获取COMid
                    comid = Int32.Parse(Domain_def.Domain_Huoqu(RequestUrl).ToString());
                    if (comid == 0)
                    {
                        comid = new WeiXinBasicData().GetWeiXinBasicByDomain(RequestUrl).Comid;
                    }
                }
                else
                {
                    B2b_company_info companyinfo = B2bCompanyData.GetComId(RequestUrl);
                    if (companyinfo != null)
                    {
                        comid = companyinfo.Com_id;
                    }
                }
            }
            catch
            {
                errlog += "1,";
            }


            if (comid != 0)
            {
                if (bo == false)
                {
                    if (comid == 101)
                    {
                        // Response.Redirect("http://vctrip.etown.cn/");
                    }
                    // Response.Redirect("http://shop" + comid + ".etown.cn");
                }



                //获取微信平台端code
                weixincode = Request["code"].ConvertTo <string>("");
                openid     = Request["openid"].ConvertTo <string>("");
                weixinpass = Request["weixinpass"].ConvertTo <string>("");

                GetMemberCard(openid, weixincode, weixinpass, comid);//登陆或得到会员信息
            }


            //得到活动ID
            actid = Request["actid"].ConvertTo <int>(0);
            //非班车抽奖活动,则得到最新运行的上线活动id(现在只是班车抽奖传递ntime参数)
            if (actid == 0 && Request["ntime"].ConvertTo <string>("") == "")
            {
                //得到最新运行的,上线的活动ID
                actid = MemberERNIEData.ERNIETOPgetid(comid);
            }

            if (actid == 0)
            {
                actstate = 0;
            }
            else
            {
                actstate = 1;
            }


            //抽奖活动
            Member_ERNIE erniemodel = new Member_ERNIE();
            //奖项
            Member_ERNIE_Award Awardmodel = new Member_ERNIE_Award();

            var pro = MemberERNIEData.ERNIEGetActById(actid);

            if (pro != null)
            {
                Com_id        = pro.Com_id;
                Title         = pro.Title;
                ERNIE_type    = pro.ERNIE_type;  //摇奖类型,大转盘
                ERNIE_star    = pro.ERNIE_star;
                ERNIE_end     = pro.ERNIE_end;
                ERNIE_RateNum = pro.ERNIE_RateNum; //摇奖基数
                ERNIE_Limit   = pro.ERNIE_Limit;   //摇奖限定,每个账户一次,还是每天一次或多次
                Limit_Num     = pro.Limit_Num;     //摇奖限定次数
                Runstate      = pro.Runstate;
                Remark        = pro.Remark;
            }
            //获取一等奖
            var Awardpro1 = MemberERNIEData.ERNIEAwardget(actid, 1);

            if (Awardpro1 != null)
            {
                Award_title1 = Awardpro1.Award_title;
                Award_num1   = Awardpro1.Award_num;
                Award_class1 = Awardpro1.Award_class;
                Id1          = Awardpro1.Id;
            }
            //获取二等奖
            var Awardpro2 = MemberERNIEData.ERNIEAwardget(actid, 2);

            if (Awardpro2 != null)
            {
                Award_title2 = Awardpro2.Award_title;
                Award_num2   = Awardpro2.Award_num;
                Award_class2 = Awardpro2.Award_class;
                Id1          = Awardpro2.Id;
            }
            //获取三等奖
            var Awardpro3 = MemberERNIEData.ERNIEAwardget(actid, 3);

            if (Awardpro3 != null)
            {
                Award_title3 = Awardpro3.Award_title;
                Award_num3   = Awardpro3.Award_num;
                Award_class3 = Awardpro3.Award_class;
                Id1          = Awardpro3.Id;
            }

            //读取活动信息
            var erniedate = MemberERNIEData.ERNIEGetActById(actid);

            if (erniedate != null)
            {
                if (erniedate.Runstate == 1 && erniedate.Online == 1 && erniedate.ERNIE_star < DateTime.Now && erniedate.ERNIE_end.AddDays(1) > DateTime.Now)
                {
                    var ERNIE_Limit = erniedate.ERNIE_Limit; //抽奖类型
                    var Limit_Num   = erniedate.Limit_Num;   //可抽奖次数
                    //读取用户信息
                    B2bCrmData crmmodel   = new B2bCrmData();
                    B2b_crm    memberinfo = crmmodel.b2b_crmH5(openid, erniedate.Com_id);
                    if (memberinfo != null)
                    {
                        if (memberinfo != null)
                        {
                            ERNIE_Record recordinfo = new ERNIE_Record();
                            recordinfo.ERNIE_openid = openid;
                            recordinfo.ERNIE_uid    = 0;
                            recordinfo.ERNIE_id     = actid;

                            var searchdate = MemberERNIEData.SearchChoujiang(recordinfo, ERNIE_Limit);//查询是否抽过奖
                            if (searchdate < Limit_Num)
                            {
                                if (AccountWeixin != "")//判断登陆状态并有微信号
                                {
                                    choujiangcishu = Limit_Num - searchdate;
                                }
                                else
                                {
                                    openid = "";
                                }
                            }
                        }
                    }
                }
            }


            string ntime    = Request["ntime"].ConvertTo <string>("");
            string md5ntime = Request["md5ntime"].ConvertTo <string>("");

            string tmd5ntime = EncryptionHelper.ToMD5(ntime + "lixh1210", "UTF-8");

            if (ntime != "")
            {
                if (md5ntime == tmd5ntime)
                {
                    if (DateTime.Parse(ntime).ToString("yyyy-MM-dd") == DateTime.Now.ToString("yyyy-MM-dd"))
                    {
                    }
                    else
                    {
                        //非当日抽奖
                        actstate = 0;
                    }
                }
                else
                {
                    actstate = 0;
                }
            }
        }