public string Process(RequestMsgModel msg)
        {
            SubscribeEventRequestMsgModel msgMode = msg as SubscribeEventRequestMsgModel;

            if (msgMode != null)
            {
                SiteActivityDAL dal      = new SiteActivityDAL();
                SiteActivity    activity = dal.GetSiteAct(Params["SiteCode"].ToString(), "Coupon");
                if (activity != null)
                {
                    CouponDAL cdal = new CouponDAL();
                    if (!cdal.ExistCoupon(Params["SiteCode"].ToString(), activity.ID, msgMode.FromUserName))
                    {
                        Coupon coupon = new Coupon()
                        {
                            SiteCode       = Params["SiteCode"].ToString(),
                            SiteActivityID = activity.ID,
                            OpenID         = msgMode.FromUserName,
                            CouponCode     = GetCouponCode(msgMode.FromUserName),
                            CouponStatus   = 0
                        };
                        cdal.InsertInfo(coupon);
                    }
                }
            }
            return(string.Empty);
        }
예제 #2
0
        protected override void AddTempData(JinianNet.JNTemplate.TemplateContext context)
        {
            CouponDAL dal = new CouponDAL();
            DataSet   ds  = dal.GetCouponInfo(CouponID);

            MyCouponInfo model = new MyCouponInfo();

            if (null != ds && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                model = DataConvert.DataRowToModel <MyCouponInfo>(ds.Tables[0].Rows[0]);
            }

            this.SetQRCode(context, model.ID);
            context.TempData["pDetail"] = model;
            if (model.CouponStatus == "已经使用")
            {
                context.TempData["RemainDay"] = "";
            }
            else
            {
                if (int.Parse(model.RemainDay) > -1)
                {
                    context.TempData["RemainDay"] = "有效期:还剩" + model.RemainDay + "天";
                }
                else
                {
                    context.TempData["RemainDay"] = "有效期:此券已经过期!";
                }
            }
        }
예제 #3
0
 public CartController(Cart cart, TourDAL tourDAL, CouponDAL couponDAL, IConfiguration configuration)
 {
     this.cart      = cart;
     this.tourDAL   = tourDAL;
     this.couponDAL = couponDAL;
     this.logger    = new LoggerConfiguration()
                      .WriteTo.AzureBlobStorage(configuration["Data:StorageAccount"], Serilog.Events.LogEventLevel.Information, $"logs", "{yyyy}/{MM}/{dd}/log.txt").CreateLogger();
 }
예제 #4
0
        public void CheckOutCoupon(string strCouponID)
        {
            CouponDAL dal = new CouponDAL();

            if (dal.UpdateCouponState(strCouponID))
            {
                strCouponInfo = "优惠券已经提交使用。";
            }
        }
예제 #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string strSiteCode = string.Empty;
                string strOpenID   = string.Empty;

                //MyCoupon.aspx?sitecode=$sitecode&openid=$openid
                if (null == Request.QueryString["sitecode"])
                {
                    return;
                }
                else
                {
                    strSiteCode            = Common.Common.NoHtml(Request.QueryString["sitecode"].ToString());
                    Session["strSiteCode"] = strSiteCode;
                }

                if (null == Request.QueryString["openid"])
                {
                    return;
                }
                else
                {
                    if (Request.QueryString["openid"].ToString().Length > 29 || Request.QueryString["openid"].ToString().Length < 25)
                    {
                        strOpenID = Common.Common.NoHtml(Request.QueryString["openid"].ToString());
                    }
                    else
                    {
                        strOpenID = Request.QueryString["openid"].ToString();
                    }
                    Session["openid"] = strOpenID;
                }

                //取所有参加的活动列表
                List <MyCouponInfo> liCoupon = new List <MyCouponInfo>();
                CouponDAL           dalCoup  = new CouponDAL();
                DataSet             ds       = dalCoup.GetCouponInfoList(strSiteCode, strOpenID);

                if (null != ds && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow row in ds.Tables[0].Rows)
                    {
                        MyCouponInfo model = DataConvert.DataRowToModel <MyCouponInfo>(row);
                        liCoupon.Add(model);
                    }
                }

                string text = System.IO.File.ReadAllText(Server.MapPath("../ShopPage/MyCoupon.html"));
                JinianNet.JNTemplate.TemplateContext context = new JinianNet.JNTemplate.TemplateContext();
                context.TempData["coupon_list"] = liCoupon;
                context.TempData["OpenID"]      = strOpenID;
                JinianNet.JNTemplate.Template t = new JinianNet.JNTemplate.Template(context, text);
                t.Render(Response.Output);
            }
        }
예제 #6
0
        /// <summary>
        /// 获取兑奖SN码
        /// </summary>
        void GetSNcode()
        {
            string sncode  = string.Empty;
            string peizeid = string.Empty;

            if (Request["peizeid"] != null && Request["peizeid"] != "")
            {
                peizeid = Common.Common.NoHtml(Request["peizeid"].ToString());
            }
            if (strOpenID.Trim() != null && strOpenID.Trim() != "")
            {
                if (!AwardUserDal.ExistAwardUser(strOpenID, "", "", peizeid, strActID))
                {
                    sncode = GenerateCheckCode(7);
                    if (AwardUserDal.UpdateUserSNCode(strOpenID, peizeid, strActID, sncode))
                    {
                        string           strGuid = Guid.NewGuid().ToString("N");
                        CouponDAL        cdal    = new CouponDAL();
                        Model.ACT.Coupon coupon  = null;
                        coupon = new Model.ACT.Coupon()
                        {
                            ID             = strGuid,
                            SiteCode       = strSiteCode,
                            SiteActivityID = strActID,
                            OpenID         = strOpenID,
                            CouponCode     = sncode,
                            CouponStatus   = 0
                        };
                        cdal.InsertInfo(coupon);
                        Response.Write("{\"success\":true,\"sn\":\"" + sncode + "\"}");
                    }
                    else
                    {
                        Response.Write("{\"error\":\"invalid\"}");
                    }
                }
                else
                {
                    sncode = AwardUserDal.GetSNCodeByPhone(strOpenID, "", "", strActID);
                    if (sncode.Trim() != null && sncode.Trim() != "")
                    {
                        Response.Write("{\"error\":\"getsn\",\"sn\":\"" + sncode + "\"}");
                    }
                    else
                    {
                        Response.Write("{\"error\":\"isdoing\"}");
                    }
                }
            }
            else
            {
                Response.Write("{\"error\":true,\"msg\":\"操作失败,请重新操作\"}"); return;
            }
        }
예제 #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string strCouponID = string.Empty;
            string strSiteCode = string.Empty;
            string strAction   = string.Empty;

            if (null == Request.QueryString["id"])
            {
                return;
            }
            if (null != Request.QueryString["action"])
            {
                strCouponID = Common.Common.NoHtml(Request.QueryString["id"].ToString());
                strAction   = Common.Common.NoHtml(Request.QueryString["action"].ToString());
                if (strAction == "checkout")
                {
                    CheckOutCoupon(strCouponID);
                }
            }
            strCouponID = Common.Common.NoHtml(Request.QueryString["id"].ToString());
            CouponDAL dal = new CouponDAL();
            DataSet   ds  = dal.GetCouponInfo(strCouponID);

            MyCouponInfo model = new MyCouponInfo();

            if (null != ds && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                model = DataConvert.DataRowToModel <MyCouponInfo>(ds.Tables[0].Rows[0]);
            }

            string text = System.IO.File.ReadAllText(Server.MapPath("QRNotUse.html"));

            //读取模板内容
            if (model.CouponStatus == "未使用")
            {
                text = System.IO.File.ReadAllText(Server.MapPath("QRNotUse.html"));
            }
            else
            {
                text = System.IO.File.ReadAllText(Server.MapPath("QRIsUse.html"));
            }

            JinianNet.JNTemplate.TemplateContext context = new JinianNet.JNTemplate.TemplateContext();
            context.TempData["title"]   = "奥琦微商易优惠券";
            context.TempData["note"]    = model.ActTitle;
            context.TempData["id"]      = strCouponID;
            context.TempData["content"] = model.Remark;
            context.TempData["errinfo"] = strCouponInfo;
            context.TempData["footer"]  = "奥琦微商易";
            JinianNet.JNTemplate.Template t = new JinianNet.JNTemplate.Template(context, text);
            t.Render(Response.Output);
        }
예제 #8
0
        protected override bool BeforeLoad()
        {
            if (null == Request.QueryString["id"])
            {
                return(false);
            }
            CouponID = Common.Common.NoHtml(Request.QueryString["id"].ToString());
            string strGuid = string.Empty;

            if (null != Request.QueryString["sitecode"] && null != Request.QueryString["openid"])
            {
                SiteCode = Common.Common.NoHtml(Request.QueryString["sitecode"].ToString());
                OpenID   = Common.Common.NoHtml(Request.QueryString["openid"].ToString());
                //插入优惠券
                SiteActivityDAL dalActive = new SiteActivityDAL();
                DataSet         dsActive  = dalActive.GetActivityDetail(CouponID);
                if (null != dsActive && dsActive.Tables.Count > 0 && dsActive.Tables[0].Rows.Count > 0)
                {
                    strGuid = Guid.NewGuid().ToString("N");
                    CouponDAL cdal = new CouponDAL();
                    if (!cdal.ExistCoupon(SiteCode, CouponID, OpenID))
                    {
                        Coupon coupon = new Coupon()
                        {
                            ID             = strGuid,
                            SiteCode       = SiteCode,
                            SiteActivityID = CouponID,
                            OpenID         = OpenID,
                            CouponStatus   = 0
                        };
                        cdal.InsertInfo(coupon);
                    }
                }
                CouponID = strGuid;
            }
            else
            {
                SiteActivityDAL dalActive = new SiteActivityDAL();
                DataSet         dsActive  = dalActive.GetActivityDetail(CouponID);
                if (null != dsActive && dsActive.Tables.Count > 0 && dsActive.Tables[0].Rows.Count > 0)
                {
                    SiteCode = dsActive.Tables[0].Rows[0]["SIteCode"].ToString();
                }
            }
            return(base.BeforeLoad());
        }
예제 #9
0
        protected override void AddTempData(JinianNet.JNTemplate.TemplateContext context)
        {
            base.AddTempData(context);
            //取最新抢购的优惠活动
            List <Model.ACT.SiteActivity> liActive = new List <Model.ACT.SiteActivity>();

            DAL.ACT.SiteActivityDAL dalActive = new SiteActivityDAL();

            List <MyCouponInfo> liCoupon = new List <MyCouponInfo>();
            CouponDAL           dalCoup  = new CouponDAL();

            DataSet dsActive = dalActive.GetActivityList(" SiteCode = '" + SiteCode + "' AND ActStatus = 1 AND ActType = 'RushCoupon' AND StartTime < GETDATE() AND EndTime > GETDATE() ");

            if (null != dsActive && dsActive.Tables.Count > 0 && dsActive.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow row in dsActive.Tables[0].Rows)
                {
                    if (!dalCoup.ExistCoupon(SiteCode, row["ID"].ToString(), OpenID))
                    {
                        Model.ACT.SiteActivity modelActive = DataConvert.DataRowToModel <Model.ACT.SiteActivity>(row);
                        liActive.Add(modelActive);
                    }
                }
            }

            DataSet ds      = dalCoup.GetCouponInfoList(SiteCode, OpenID);
            string  strInfo = string.Empty;

            if (null != ds && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    MyCouponInfo model = DataConvert.DataRowToModel <MyCouponInfo>(row);
                    liCoupon.Add(model);
                }
            }
            else
            {
                strInfo = "亲,你还没有参加过活动哦,多多关注我们的新活动!";
            }
            context.TempData["openid"]          = OpenID;
            context.TempData["rushcoupon_list"] = liActive;
            context.TempData["coupon_list"]     = liCoupon;
            context.TempData["couponinfo"]      = strInfo;
        }
예제 #10
0
        protected void btnCoupon_Click(object sender, EventArgs e)
        {
            string strWhere = "  ";

            if (Session["strRoleCode"].ToString() != "ADMIN")
            {
                strWhere = " a.SiteCode = '" + Session["strSiteCode"].ToString() + "' ";
            }

            if (ddlselectName.SelectedValue.Trim() != null && ddlselectName.SelectedValue.Trim() != "" &&
                ddlselectName.SelectedValue.Trim() != "0")
            {
                if (strWhere.Trim() != null && strWhere.Trim() != "")
                {
                    strWhere = strWhere + " AND ";
                }
                strWhere = strWhere + " b.ID='" + ddlselectName.SelectedValue + "' ";
            }

            if (ddlselectName.SelectedValue.Trim() != null && ddlselectName.SelectedValue.Trim() != "" &&
                ddlselectName.SelectedValue.Trim() != "0")
            {
                if (strWhere.Trim() != null && strWhere.Trim() != "")
                {
                    strWhere = strWhere + " AND ";
                }
                string arrow = GetLoseWin(ddlselectName.SelectedValue);

                if (arrow == "0")
                {
                    MessageBox.Show(this, "请设置正确的比赛结果再做统计!");
                    return;
                }

                strWhere = strWhere + " [dbo].[split](GuessScore,':',0) " + arrow + " [dbo].[split](GuessScore,':',1) ";
            }
            else
            {
                MessageBox.Show(this, "操作失败,请选择相应的赛事!"); return;
            }

            JC_ScoreDAL dal = new JC_ScoreDAL();
            DataSet     ds  = dal.GetJCScoreListByStateNO(strWhere);

            //取正确比分

            foreach (DataRow row in ds.Tables[0].Rows)
            {
                string strOpenID     = row["OpenID"].ToString();
                string strScoreID    = row["ID"].ToString();
                string strGuessScore = row["GuessScore"].ToString();
                string strRightScore = row["RightScore"].ToString();
                //修改竞猜状态;
                dal.UpdateJCScoreState(strScoreID);
                //写入优惠券
                //AC87CE288FC24F23B7B68CE8F3D93D13
                string           strGuid     = Guid.NewGuid().ToString("N");
                CouponDAL        cdal        = new CouponDAL();
                string           strSiteCode = Session["strSiteCode"].ToString();
                Model.ACT.Coupon coupon      = null;
                if (strGuessScore == strRightScore)
                {
                    coupon = new Model.ACT.Coupon()
                    {
                        ID             = strGuid,
                        SiteCode       = Session["strSiteCode"].ToString(),
                        SiteActivityID = "AC87CE288FC24F23B7B68CE8F3D93D18",
                        OpenID         = strOpenID,
                        CouponStatus   = 0
                    };
                }
                else
                {
                    coupon = new Model.ACT.Coupon()
                    {
                        ID             = strGuid,
                        SiteCode       = Session["strSiteCode"].ToString(),
                        SiteActivityID = "AC87CE288FC24F23B7B68CE8F3D93D22",
                        OpenID         = strOpenID,
                        CouponStatus   = 0
                    };
                }
                cdal.InsertInfo(coupon);
            }

            MessageBox.Show(this, "优惠券发放完成!");
        }
예제 #11
0
        /// <summary>
        /// 处理回复消息
        /// "text":回复文本消息处理,MsgValue对应回复的文本
        /// "sub_auto_coupon":回复订阅自动优惠券处理,MsgValue对应回复的图文消息ID
        /// "auto_news_article":根据文章自动生成图文消息进行回复,MsgValue为类别ID
        /// "news":回复图文表中的消息,MsgValue为图文消息表ID集,用逗号分隔
        /// </summary>
        /// <param name="replyMsgType"></param>
        /// <param name="replyMsgValue"></param>
        /// <param name="customParams"></param>
        /// <returns></returns>
        private string ProcessReply(RequestMsgModel msgModel, string replyMsgType, string replyMsgValue)
        {
            string res = string.Empty;

            try
            {
                switch (replyMsgType.ToLower())
                {
                case "text":
                    //回复文本消息处理,MsgValue对应回复的文本
                    TextResponseMsgModel textMsg = new TextResponseMsgModel()
                    {
                        ToUserName   = msgModel.FromUserName,
                        FromUserName = msgModel.ToUserName,
                        CreateTime   = WeiXinHelper.ConvertDateTimeInt(DateTime.Now).ToString(),
                        Content      = replyMsgValue == null ? string.Empty : TransformText(replyMsgValue, msgModel)
                    };
                    res = textMsg.ToString();
                    break;

                case "voice":
                    //回复语音消息处理,MsgValue对应回复的文本
                    VoiceResponseMsgModel voiceMsg = new VoiceResponseMsgModel()
                    {
                        ToUserName   = msgModel.FromUserName,
                        FromUserName = msgModel.ToUserName,
                        CreateTime   = WeiXinHelper.ConvertDateTimeInt(DateTime.Now).ToString(),
                    };
                    Media media = MediaDAL.CreateInstance().GetMediaByID(replyMsgValue);
                    if (media != null && !string.IsNullOrEmpty(media.MediaID))
                    {
                        voiceMsg.MediaId = media.MediaID;
                    }
                    res = voiceMsg.ToString();
                    break;

                case "wxpay_test":
                    //用于微信支付测试
                    TextResponseMsgModel textMsgx = new TextResponseMsgModel()
                    {
                        ToUserName   = msgModel.FromUserName,
                        FromUserName = msgModel.ToUserName,
                        CreateTime   = WeiXinHelper.ConvertDateTimeInt(DateTime.Now).ToString(),
                        Content      = string.Format("<a href='{0}/Payment/wxpay/wxpayDemo.aspx?openid={1}'>微信支付测试</a>", GetSiteUrl(), msgModel.FromUserName)
                    };
                    res = textMsgx.ToString();
                    break;

                case "transfer_customer_service":
                    //将消息转发到多客服
                    TransferCustomerServiceResponseMsgModel transferMsg = new TransferCustomerServiceResponseMsgModel()
                    {
                        ToUserName   = msgModel.FromUserName,
                        FromUserName = msgModel.ToUserName,
                        CreateTime   = WeiXinHelper.ConvertDateTimeInt(DateTime.Now).ToString(),
                    };
                    res = transferMsg.ToString();
                    break;

                case "sub_auto_coupon":
                    //回复订阅自动优惠券处理,MsgValue对应回复的优惠券图文消息ID
                    //SubscribeCouponActHandle sch = new SubscribeCouponActHandle();
                    SiteActivityDAL dal      = new SiteActivityDAL();
                    SiteActivity    activity = dal.GetSiteAct(siteCode, "Coupon");
                    if (activity != null)
                    {
                        CouponDAL cdal = new CouponDAL();
                        if (!cdal.ExistCoupon(siteCode, activity.ID, msgModel.FromUserName))
                        {
                            Coupon coupon = new Coupon()
                            {
                                SiteCode       = siteCode,
                                SiteActivityID = activity.ID,
                                OpenID         = msgModel.FromUserName,
                                //CouponCode = msgModel.FromUserName,
                                CouponStatus = 0
                            };
                            cdal.InsertInfo(coupon);
                        }
                    }
                    CouponNewsDAL nmDAL = new CouponNewsDAL();
                    CouponNews    nm    = nmDAL.GetCouponNews(replyMsgValue);
                    if (nm != null)
                    {
                        NewsResponseMsgModel newsModel = new NewsResponseMsgModel()
                        {
                            ToUserName   = msgModel.FromUserName,
                            FromUserName = msgModel.ToUserName,
                            CreateTime   = WeiXinHelper.ConvertDateTimeInt(DateTime.Now).ToString()
                        };
                        List <Article> articles = new List <Article>();
                        articles.Add(new Article()
                        {
                            Title       = nm.Title,
                            Description = nm.Description,
                            PicUrl      = GetPicUrl(nm.PicUrl),
                            Url         = TransformUrl(nm.Url, msgModel)
                        });
                        newsModel.Articles = articles;
                        res = newsModel.ToString();
                    }
                    break;

                case "auto_coupon_category":
                    SiteActivityDAL dalCatList  = new SiteActivityDAL();
                    SiteActivity    activityCat = dalCatList.GetSiteAct(siteCode, "Coupon");
                    if (activityCat != null)
                    {
                        CouponDAL cdal = new CouponDAL();
                        if (!cdal.ExistCoupon(siteCode, activityCat.ID, msgModel.FromUserName))
                        {
                            Coupon coupon = new Coupon()
                            {
                                SiteCode       = siteCode,
                                SiteActivityID = activityCat.ID,
                                OpenID         = msgModel.FromUserName,
                                //CouponCode = msgModel.FromUserName,
                                CouponStatus = 0
                            };
                            cdal.InsertInfo(coupon);
                        }
                    }
                    ArticleDAL catDal = new ArticleDAL();
                    DataSet    cdsCat = catDal.GetCategoryList(siteCode, replyMsgValue);
                    if (cdsCat != null && cdsCat.Tables.Count > 0 && cdsCat.Tables[0] != null && cdsCat.Tables[0].Rows.Count > 0)
                    {
                        int i = 0;
                        NewsResponseMsgModel newsModel = new NewsResponseMsgModel()
                        {
                            ToUserName   = msgModel.FromUserName,
                            FromUserName = msgModel.ToUserName,
                            CreateTime   = WeiXinHelper.ConvertDateTimeInt(DateTime.Now).ToString()
                        };
                        List <Article> articles = new List <Article>();
                        foreach (DataRow dr in cdsCat.Tables[0].Rows)
                        {
                            if (++i > 4)
                            {
                                break;
                            }
                            articles.Add(new Article()
                            {
                                Title       = dr["Title"].ToString(),
                                Description = dr["Summary"].ToString(),
                                //Description = RemoveHtmlTag(dr["Content"].ToString(), 30),
                                PicUrl = GetPicUrl(dr["Pic"].ToString()),
                                Url    = GetArticleUrl(dr["ID"].ToString())
                            });
                        }
                        newsModel.Articles = articles;
                        res = newsModel.ToString();
                    }
                    break;

                case "auto_news_article":
                    //根据文章自动生成图文消息进行回复,MsgValue为文章ID
                    ArticleDAL aDal = new ArticleDAL();
                    DataSet    ds   = aDal.GetArticleDetail(replyMsgValue);
                    if (ds != null && ds.Tables.Count > 0 && ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                    {
                        int i = 0;
                        NewsResponseMsgModel newsModel = new NewsResponseMsgModel()
                        {
                            ToUserName   = msgModel.FromUserName,
                            FromUserName = msgModel.ToUserName,
                            CreateTime   = WeiXinHelper.ConvertDateTimeInt(DateTime.Now).ToString()
                        };
                        List <Article> articles = new List <Article>();
                        foreach (DataRow dr in ds.Tables[0].Rows)
                        {
                            if (++i > 4)
                            {
                                break;
                            }
                            articles.Add(new Article()
                            {
                                Title       = dr["Title"].ToString(),
                                Description = dr["Summary"].ToString(),
                                //Description = RemoveHtmlTag(dr["Content"].ToString(), 100),
                                PicUrl = GetPicUrl(dr["Pic"].ToString()),
                                Url    = GetArticleUrl(dr["ID"].ToString())
                            });
                        }
                        newsModel.Articles = articles;
                        res = newsModel.ToString();
                    }
                    break;

                case "auto_news_category":
                    //根据类别自动生成图文消息进行回复,MsgValue为类别ID
                    ArticleDAL cDal = new ArticleDAL();
                    DataSet    cds  = cDal.GetCategoryList(siteCode, replyMsgValue);
                    if (cds != null && cds.Tables.Count > 0 && cds.Tables[0] != null && cds.Tables[0].Rows.Count > 0)
                    {
                        int i = 0;
                        NewsResponseMsgModel newsModel = new NewsResponseMsgModel()
                        {
                            ToUserName   = msgModel.FromUserName,
                            FromUserName = msgModel.ToUserName,
                            CreateTime   = WeiXinHelper.ConvertDateTimeInt(DateTime.Now).ToString()
                        };
                        List <Article> articles = new List <Article>();
                        foreach (DataRow dr in cds.Tables[0].Rows)
                        {
                            if (++i > 4)
                            {
                                break;
                            }
                            articles.Add(new Article()
                            {
                                Title       = dr["Title"].ToString(),
                                Description = dr["Summary"].ToString(),
                                //Description = RemoveHtmlTag(dr["Content"].ToString(), 30),
                                PicUrl = GetPicUrl(dr["Pic"].ToString()),
                                Url    = GetArticleUrl(dr["ID"].ToString())
                            });
                        }
                        newsModel.Articles = articles;
                        res = newsModel.ToString();
                    }
                    break;

                case "coupon":
                    //回复图文表中的消息,MsgValue为图文消息表ID集,用逗号分隔
                    NewsMsgDAL nmDAL1 = new NewsMsgDAL();
                    NewsMsg    nms    = nmDAL1.GetNewsMsg(replyMsgValue);
                    if (nms != null)
                    {
                        NewsResponseMsgModel newsModel = new NewsResponseMsgModel()
                        {
                            ToUserName   = msgModel.FromUserName,
                            FromUserName = msgModel.ToUserName,
                            CreateTime   = WeiXinHelper.ConvertDateTimeInt(DateTime.Now).ToString()
                        };
                        List <Article> articles = new List <Article>();
                        articles.Add(new Article()
                        {
                            Title       = nms.Title,
                            Description = nms.Description,
                            PicUrl      = GetPicUrl(nms.PicUrl),
                            Url         = TransformUrl(nms.Url, msgModel)
                        });
                        newsModel.Articles = articles;
                        res = newsModel.ToString();
                    }
                    break;

                case "news":
                    //回复图文表中的消息,MsgValue为图文消息表ID集,用逗号分隔
                    NewsMsgDAL      nmDALs   = new NewsMsgDAL();
                    IList <NewsMsg> newsMsgs = nmDALs.GetNewsMsgs(replyMsgValue);
                    if (newsMsgs != null)
                    {
                        NewsResponseMsgModel newsModel = new NewsResponseMsgModel()
                        {
                            ToUserName   = msgModel.FromUserName,
                            FromUserName = msgModel.ToUserName,
                            CreateTime   = WeiXinHelper.ConvertDateTimeInt(DateTime.Now).ToString()
                        };
                        List <Article> articles = new List <Article>();
                        foreach (NewsMsg msg in newsMsgs)
                        {
                            articles.Add(new Article()
                            {
                                Title       = msg.Title,
                                Description = msg.Description,
                                PicUrl      = GetPicUrl(msg.PicUrl),
                                Url         = TransformUrl(msg.Url, msgModel)
                            });
                        }
                        newsModel.Articles = articles;
                        res = newsModel.ToString();
                    }
                    break;

                case "url":
                    //根据文章自动生成图文消息进行回复,MsgValue为文章ID
                    DAL.SYS.AccountDAL dalUrl = new DAL.SYS.AccountDAL();
                    DataSet            dsUrl  = dalUrl.GetAccountExtData(replyMsgValue);
                    if (dsUrl != null && dsUrl.Tables.Count > 0 && dsUrl.Tables[0] != null && dsUrl.Tables[0].Rows.Count > 0)
                    {
                        int i = 0;
                        NewsResponseMsgModel newsModel = new NewsResponseMsgModel()
                        {
                            ToUserName   = msgModel.FromUserName,
                            FromUserName = msgModel.ToUserName,
                            CreateTime   = WeiXinHelper.ConvertDateTimeInt(DateTime.Now).ToString()
                        };
                        List <Article> articles = new List <Article>();
                        foreach (DataRow dr in dsUrl.Tables[0].Rows)
                        {
                            if (++i > 4)
                            {
                                break;
                            }
                            articles.Add(new Article()
                            {
                                Title       = dr["Name"].ToString(),
                                Description = dr["Summary"].ToString(),
                                PicUrl      = GetPicUrl(dr["Photo"].ToString()),
                                Url         = GetSiteInfo(dr["ID"].ToString())
                            });
                        }
                        newsModel.Articles = articles;
                        res = newsModel.ToString();
                    }
                    break;

                case "hp_photo_text":
                    //为当前hp_photo对应的照片附加文字信息
                    PhotoDAL photoDal = new PhotoDAL();
                    if (photoDal.ExistPhoto(siteCode, msgModel.FromUserName, 0))
                    {
                        TextRequestMsgModel temp = msgModel as TextRequestMsgModel;
                        string text = temp.Content.Replace("#ms", "");
                        //附加图片文字
                        photoDal.UpdateAttachText(siteCode, msgModel.FromUserName, text);
                        TextResponseMsgModel textMsg2 = new TextResponseMsgModel()
                        {
                            ToUserName   = msgModel.FromUserName,
                            FromUserName = msgModel.ToUserName,
                            CreateTime   = WeiXinHelper.ConvertDateTimeInt(DateTime.Now).ToString(),
                            Content      = replyMsgValue == null ? string.Empty : TransformText(replyMsgValue, msgModel)
                        };
                        res = textMsg2.ToString();
                    }
                    else
                    {
                        TextResponseMsgModel textMsg2 = new TextResponseMsgModel()
                        {
                            ToUserName   = msgModel.FromUserName,
                            FromUserName = msgModel.ToUserName,
                            CreateTime   = WeiXinHelper.ConvertDateTimeInt(DateTime.Now).ToString(),
                            Content      = "对不起,您暂未参加图片打印活动!"
                        };
                        res = textMsg2.ToString();
                    }
                    break;

                case "hp_photo_ticket":
                    //对当前hp_photo对应的照片进行打印认证
                    PrintCodeDAL        printCodeDAL = new PrintCodeDAL();
                    TextRequestMsgModel temp1        = msgModel as TextRequestMsgModel;
                    string printCode = temp1.Content.Replace("#dy", "");
                    string clientID  = printCodeDAL.GetClientIDByPrintCode(printCode, siteCode);
                    ExceptionLogDAL.InsertExceptionLog(new ExceptionLog()
                    {
                        Message = clientID
                    });
                    if (!string.IsNullOrEmpty(clientID))
                    {
                        PhotoDAL photoDal1 = new PhotoDAL();
                        photoDal1.UpdatePrintInfo(printCode, clientID, siteCode, msgModel.FromUserName);
                        TextResponseMsgModel textMsg2 = new TextResponseMsgModel()
                        {
                            ToUserName   = msgModel.FromUserName,
                            FromUserName = msgModel.ToUserName,
                            CreateTime   = WeiXinHelper.ConvertDateTimeInt(DateTime.Now).ToString(),
                            Content      = replyMsgValue == null ? string.Empty : TransformText(replyMsgValue, msgModel)
                        };
                        res = textMsg2.ToString();
                        //TextResponseMsgModel textMsg2 = new TextResponseMsgModel()
                        //{
                        //    ToUserName = msgModel.FromUserName,
                        //    FromUserName = msgModel.ToUserName,
                        //    CreateTime = WeiXinHelper.ConvertDateTimeInt(DateTime.Now).ToString(),
                        //    Content = "照片打印中,请稍侯..."
                        //};
                        //res = textMsg2.ToString();
                    }
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                ExceptionLogDAL.InsertExceptionLog(ex);
            }
            return(res);
        }
예제 #12
0
        /// <summary>
        /// 用户注册
        /// </summary>
        void saveUserinfo()
        {
            if (strOpenID != null && strOpenID != "")
            {
                if (!AwardUserDal.ExistAwardUser(strOpenID, "", "", "", ""))
                {
                    LuckyAwardUsers usermodel = new LuckyAwardUsers();
                    usermodel.ID        = Guid.NewGuid().ToString("N").ToUpper();
                    usermodel.IsDel     = 0;
                    usermodel.OpenID    = strOpenID;
                    usermodel.SendAward = 0;
                    usermodel.ActID     = strActID;

                    if (AwardUserDal.AddAwardUsers(usermodel))
                    {
                        Random ran         = new Random();
                        int    RandKey     = ran.Next(0, 6);
                        string strGuid     = Guid.NewGuid().ToString("N");
                        string strSN       = GenerateCheckCode(7);
                        string strCouActID = "AC87CE288FC24F23B7B68CE8F3D93D04";
                        switch (RandKey)
                        {
                        case 1:
                            strCouActID = "AC87CE288FC24F23B7B68CE8F3D93D01";
                            break;

                        case 2:
                            strCouActID = "AC87CE288FC24F23B7B68CE8F3D93D02";
                            break;

                        case 3:
                            strCouActID = "AC87CE288FC24F23B7B68CE8F3D93D03";
                            break;

                        case 4:
                            strCouActID = "AC87CE288FC24F23B7B68CE8F3D93D04";
                            break;

                        case 5:
                            strCouActID = "AC87CE288FC24F23B7B68CE8F3D93D05";
                            break;

                        case 6:
                            strCouActID = "AC87CE288FC24F23B7B68CE8F3D93D06";
                            break;

                        default:
                            strCouActID = "AC87CE288FC24F23B7B68CE8F3D93D04";
                            break;
                        }

                        CouponDAL        cdal   = new CouponDAL();
                        Model.ACT.Coupon coupon = null;
                        coupon = new Model.ACT.Coupon()
                        {
                            ID             = strGuid,
                            SiteCode       = strSiteCode,
                            SiteActivityID = strCouActID,
                            OpenID         = strOpenID,
                            CouponCode     = strSN,
                            CouponStatus   = 0
                        };

                        cdal.InsertInfo(coupon);

                        Response.Write("{\"success\":\"true\",\"prizetype\":\"" + RandKey.ToString() + "\",\"sn\":\"a" + strSN + "\"}");
                    }
                    else
                    {
                        Response.Write("{\"error\":\"invalid\"}");
                    }
                }
                else
                {
                    //Response.Write("{\"prizetype\":\"null\",\"sn\":\"no\"}");
                    Response.Write("{\"error\":\"isdoing\"}");
                }
            }
            else
            {
                Response.Write("{\"prizetype\":\"null\",\"sn\":\"no\"}");
            }
        }
예제 #13
0
        protected override bool BeforeLoad()
        {
            string strGuid = string.Empty;


            if (null != Request.QueryString["sitecode"] && null != Request.QueryString["openid"] && null != Request.QueryString["couponid"])
            {
                CouponID = Common.Common.NoHtml(Request.QueryString["couponid"].ToString());
                SiteCode = Common.Common.NoHtml(Request.QueryString["sitecode"].ToString());

                if (Request.QueryString["sitecode"].ToString().Length > 6)
                {
                    return(false);
                }

                if (Request.QueryString["couponid"].ToString().Length != 32)
                {
                    return(false);
                }

                if (Request.QueryString["openid"].ToString().Length > 29 || Request.QueryString["openid"].ToString().Length < 25)
                {
                    return(false);
                }
                else
                {
                    OpenID = Request.QueryString["openid"].ToString();
                }

                //插入优惠券
                SiteActivityDAL dalActive = new SiteActivityDAL();
                DataSet         dsActive  = dalActive.GetActivityDetail(CouponID);
                if (null != dsActive && dsActive.Tables.Count > 0 && dsActive.Tables[0].Rows.Count > 0)
                {
                    strGuid = Guid.NewGuid().ToString("N");
                    CouponDAL cdal = new CouponDAL();
                    if (!cdal.ExistCoupon(SiteCode, CouponID, OpenID))
                    {
                        //判断是否可以参加
                        //取当前已经参加的人数
                        int iCount = 10000000;
                        if (null != dsActive.Tables[0].Rows[0]["DayLimit"].ToString())
                        {
                            string strCount = "SiteCode = '" + SiteCode + "' AND SiteActivityID = '" + CouponID + "' AND CONVERT(VARCHAR(10),AddTime,120) = CONVERT(VARCHAR(10),GETDATE(),120)";
                            iCount = cdal.GetCouponCount(strCount);
                        }
                        string strStartTime = dsActive.Tables[0].Rows[0]["StartTime"].ToString();
                        string strEndTime   = dsActive.Tables[0].Rows[0]["EndTime"].ToString();
                        string strOpenTime  = dsActive.Tables[0].Rows[0]["OpenTime"].ToString();
                        string strCloseTime = dsActive.Tables[0].Rows[0]["CloseTime"].ToString();
                        string strDayLimit  = dsActive.Tables[0].Rows[0]["DayLimit"].ToString();

                        if (DateTime.Now >= Convert.ToDateTime(strStartTime) &&
                            DateTime.Now < Convert.ToDateTime(strEndTime) &&
                            DateTime.Now.Hour >= int.Parse(strOpenTime) &&
                            DateTime.Now.Hour < int.Parse(strCloseTime)
                            )
                        {
                            if (iCount < int.Parse(strDayLimit))
                            {
                                Coupon coupon = new Coupon()
                                {
                                    ID             = strGuid,
                                    SiteCode       = SiteCode,
                                    SiteActivityID = CouponID,
                                    OpenID         = OpenID,
                                    CouponStatus   = 0
                                };
                                cdal.InsertInfo(coupon);
                                strReHtml = "RushBuyOK.html";
                            }
                            else
                            {
                                strReHtml  = "RushBuyOver.html";
                                strMessage = "抱歉!优惠券已经被抢完,请关注下期活动!";
                            }
                        }
                        else
                        {
                            strReHtml  = "RushBuyOver.html";
                            strMessage = "抱歉!近期活动未开始或者已经结束,请关注公方微信优惠消息!";
                        }
                    }
                    else
                    {
                        strReHtml  = "RushBuyOver.html";
                        strMessage = "抱歉!您已经参与了活动,请把机会留给其余的顾客。";
                    }
                }
                CouponID = strGuid;
            }
            else
            {
                Response.Write("<script>window.opener=null;window.close();</script>");
                return(false);
            }
            return(base.BeforeLoad());
        }
예제 #14
0
        protected override void AddTempData(JinianNet.JNTemplate.TemplateContext context)
        {
            base.AddTempData(context);
            CouponDAL dal = new CouponDAL();
            DataSet   ds  = dal.GetCouponInfo(CouponID);

            MyCouponInfo model = new MyCouponInfo();

            if (null != ds && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                model = DataConvert.DataRowToModel <MyCouponInfo>(ds.Tables[0].Rows[0]);
            }

            //读取模板内容

            //string text = System.IO.File.ReadAllText(Server.MapPath("Themes/Default/" + strReHtml));
            //JinianNet.JNTemplate.TemplateContext context = new JinianNet.JNTemplate.TemplateContext();
            if (strReHtml == "RushBuyOK.html" || strReHtml == "QJTVRushBuyOK.html")
            {
                this.SetQRCode(context, model.ID);

                context.TempData["pDetail"] = model;
                if (model.CouponStatus == "已经使用")
                {
                    context.TempData["RemainDay"] = "";
                }
                else
                {
                    if (int.Parse(model.RemainDay) > -1)
                    {
                        context.TempData["RemainDay"] = "有效期:还剩" + model.RemainDay + "天";
                    }
                    else
                    {
                        context.TempData["RemainDay"] = "有效期:此券已经过期!";
                    }
                }
            }
            else
            {
                #region 消费完成发生消息
                string strAppID             = string.Empty;
                string strSecret            = string.Empty;
                Model.WeiXin.WXConfig wc    = new Model.WeiXin.WXConfig();
                WXConfigDAL           wcdal = new WXConfigDAL();
                wc = wcdal.GetWXConfigBySiteCode(SiteCode);
                if (null != wc)
                {
                    strAppID  = wc.WXAppID;
                    strSecret = wc.WXAppSecret;
                }
                string strToken = WeiXinHelper.GetAccessToken(strAppID, strSecret);

                var    KeyToken  = new { access_token = "" };
                var    b         = JsonConvert.DeserializeAnonymousType(strToken, KeyToken);
                string strRToken = b.access_token;

                WeiXinHelper.SendCustomTextMessage(strRToken, OpenID, strMessage);
                #endregion
                //Response.Write("<script>document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {	WeixinJSBridge.call('closeWindow');});</script>");
                //Response.Redirect("MyCoupon.aspx?SiteCode=" + strSiteCode + "&OpenID=" + strOpenID);
                //return;
            }
            context.TempData["strmsg"] = strMessage;
            context.TempData["OpenID"] = OpenID;
        }
예제 #15
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string strSiteCode = string.Empty;
                string strOpenID   = string.Empty;

                //if (null == Request["state"] || Request["state"] == "")
                if (null == Request.QueryString["state"])
                {
                    return;
                }
                else
                {
                    strSiteCode            = Common.Common.NoHtml(Request.QueryString["state"].ToString());
                    Session["strSiteCode"] = strSiteCode;
                }

                string code = Request.QueryString["code"] as string;
                if (!string.IsNullOrEmpty(code))
                {
                    WXConfigDAL           dal      = new WXConfigDAL();
                    Model.WeiXin.WXConfig wxConfig = dal.GetWXConfigBySiteCode(strSiteCode);
                    if (wxConfig != null)
                    {
                        WeiXinCore.Models.WeiXinConfig weixinConfig = new WeiXinCore.Models.WeiXinConfig()
                        {
                            ID        = wxConfig.WXID,
                            Name      = wxConfig.WXName,
                            Token     = wxConfig.WXToken,
                            AppId     = wxConfig.WXAppID,
                            AppSecret = wxConfig.WXAppSecret
                        };
                        WeiXinCore.WeiXin weixin            = new WeiXinCore.WeiXin(weixinConfig);
                        Oauth2AccessToken oauth2AccessToken = weixin.GetOauth2AccessToken(code);
                        if (oauth2AccessToken != null)
                        {
                            strOpenID = oauth2AccessToken.OpenID;
                        }
                    }
                    else
                    {
                        strOpenID = code;
                    }
                }

                Session["OpenID"] = strOpenID;

                //取所有参加的活动列表
                List <MyCouponInfo> liCoupon = new List <MyCouponInfo>();
                CouponDAL           dalCoup  = new CouponDAL();
                DataSet             ds       = dalCoup.GetCouponInfoList(strSiteCode, strOpenID);

                if (null != ds && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow row in ds.Tables[0].Rows)
                    {
                        MyCouponInfo model = DataConvert.DataRowToModel <MyCouponInfo>(row);
                        liCoupon.Add(model);
                    }
                }

                string text = System.IO.File.ReadAllText(Server.MapPath("../ShopPage/ActiveList.html"));
                JinianNet.JNTemplate.TemplateContext context = new JinianNet.JNTemplate.TemplateContext();
                context.TempData["coupon_list"] = liCoupon;
                context.TempData["OpenID"]      = strOpenID;
                JinianNet.JNTemplate.Template t = new JinianNet.JNTemplate.Template(context, text);
                t.Render(Response.Output);
            }
        }
예제 #16
0
파일: CouponBLL.cs 프로젝트: vbea/BNSCoupon
 public CouponBLL()
 {
     dal = new CouponDAL();
 }