protected void Page_Load(object sender, EventArgs e) { OnlyWeiXinLook(); if (!IsPostBack) { int aid = MyCommFun.RequestInt("aid", 0); if (aid == 0) { return; } BLL.wx_sTicket actbll = new BLL.wx_sTicket(); Model.wx_sTicket sstAction = actbll.GetModel(aid); if (sstAction != null) { imgEnd.ImageUrl = sstAction.endPic == null ? "images/end.jpg" : sstAction.endPic.ToString(); } } }
protected void Page_Load(object sender, EventArgs e) { OnlyWeiXinLook(); if (!IsPostBack) { int aid = MyCommFun.RequestInt("aid", 0); if (aid == 0 ) { return; } BLL.wx_sTicket actbll = new BLL.wx_sTicket(); Model.wx_sTicket sstAction = actbll.GetModel(aid); if (sstAction != null) { imgEnd.ImageUrl = sstAction.endPic == null ? "images/end.jpg" : sstAction.endPic.ToString(); } } }
/// <summary> /// 优惠券简单版回复内容 /// </summary> /// <param name="id">模块主键Id</param> /// <param name="apiid">微帐号主键id</param> /// <param name="openid">openid</param> /// <param name="responseType">回复类型:1纯文字,2图文</param> /// <param name="responseVaule">回复的内容</param> private IList <Model.ResponseContentEntity> yhqjdReponse(int id, int apiid, string openid) { IList <Model.ResponseContentEntity> responselist = new List <Model.ResponseContentEntity>(); Model.ResponseContentEntity responseEntity = new Model.ResponseContentEntity(); responseEntity.id = id; responseEntity.wid = apiid; BLL.wx_sTicket sttActBll = new BLL.wx_sTicket(); Model.wx_sTicket actModel = sttActBll.GetModel(id); if (actModel.beginDate > DateTime.Now) { //活动尚未开始 responseEntity.rcType = Model.ReponseContentType.text; responseEntity.rContent = "活动【" + actModel.actionName + "】将于" + actModel.beginDate + "开始。"; } else if (actModel.endDate <= DateTime.Now) { //活动结束 responseEntity.rcType = Model.ReponseContentType.txtpic; responseEntity.rContent = actModel.endNotice; responseEntity.rContent2 = actModel.endContent; responseEntity.detailUrl = MyCommFun.getWebSite() + "/weixin/sticket/end.aspx?wid=" + apiid + "&aid=" + id; responseEntity.picUrl = actModel.endPic; } else { //活动正在进行中 responseEntity.rcType = Model.ReponseContentType.txtpic; responseEntity.rContent = actModel.actionName; responseEntity.rContent2 = actModel.brief; responseEntity.detailUrl = MyCommFun.getWebSite() + "/weixin/sticket/index.aspx?wid=" + apiid + "&aid=" + id; responseEntity.picUrl = actModel.beginPic; } responselist.Add(responseEntity); return(responselist); }
/// <summary> /// 绑定页面上的基本信息 /// </summary> /// <param name="id">活动主键id</param> /// <param name="openid"></param> private void bindData(int id, string openid) { #region 活动详情 sstAction = actbll.GetModel(id); if (sstAction == null) { hidStatus.Value = "-2"; hidErrInfo.Value = "该活动不存在!"; return; } this.Title = sstAction.actionName; stitle = sstAction.actionName; sbrief = sstAction.brief; List <Model.wx_sttAwardItem> itemlist = itemBll.GetModelList("actId=" + id); StringBuilder sb = new StringBuilder(""); Model.wx_sttAwardItem item = new Model.wx_sttAwardItem(); int ttJpNum = 0;//最大的奖品数量 for (int i = 0; i < itemlist.Count; i++) { item = itemlist[i]; sb.Append("<p>优惠券名称:" + item.jpName + " 数量:" + item.jpRealNum + "</p>"); ttJpNum += item.jpRealNum.Value; } zjpic.ImageUrl = sstAction.bannerPic == null ? "images/banner.jpg" : sstAction.bannerPic; litJiangXing.Text = sb.ToString(); litusedRemark.Text = sstAction.usedRemark; litaContent.Text = sstAction.aContent; #endregion #region 判断 if (sstAction.endDate <= DateTime.Now) { //说明活动已经结束 //非活动期间 hidStatus.Value = "-1"; hidErrInfo.Value = "活动已结束!"; return; } else if (sstAction.beginDate > DateTime.Now) { //活动未开始 //非活动期间 hidStatus.Value = "-2"; hidErrInfo.Value = "活动尚未开始!"; return; } #endregion #region 计算中奖信息 Model.wx_sttAwardUser awardUser = ubll.getZJinfoByOpenid(id, openid); if (awardUser != null && awardUser.id > 0) { if (awardUser.uTel != null && awardUser.uTel.Trim() != "") { //说明已经提交成功了 hidStatus.Value = "3"; hidErrInfo.Value = "恭喜你中奖了!"; litJp.Text = awardUser.jpName; hidAwardId.Value = awardUser.id.ToString(); litSNM.Text = awardUser.sn; } else { //未提交 //中奖了 hidStatus.Value = "2"; hidErrInfo.Value = "恭喜你中奖了!"; litJiangPing.Text = awardUser.jpName; hidAwardId.Value = awardUser.id.ToString(); litSn.Text = awardUser.sn; } return; } IList <Model.wx_sttAwardUser> auserlist = ubll.getHasZJList(id); //已经中奖的人列表 int ZhongJiangNum = 0; //中奖人数 if (auserlist != null) { ZhongJiangNum = auserlist.Count; //已经中奖的人数 } int syZjNum = ttJpNum - ZhongJiangNum; //剩余的奖品数量 if (syZjNum <= 0) { //说明已经没有奖品了 hidStatus.Value = "-2"; hidErrInfo.Value = "优惠券已经被领取完了,请下次再来吧!"; return; } Random rd = new Random((int)DateTime.Now.Ticks); int radNum = rd.Next(0, syZjNum);//从0到剩余的奖品里随机出一个值 if (radNum < syZjNum) { //中奖了,再从剩余奖品里抽取一个奖品 Model.wx_sttAwardItem dajiang = getZJItem(itemlist, auserlist); if (dajiang != null) { //这是中的中奖了 string snumber = Get_snumber(id); int uId = ubll.Add(id, "", "", openid, dajiang.jpName, snumber); hidStatus.Value = "2"; hidErrInfo.Value = "恭喜你中奖了!"; litJiangPing.Text = dajiang.jpName; hidAwardId.Value = uId.ToString(); litSn.Text = snumber; return; } else { //奖品已经全部中完了 hidStatus.Value = "-2"; hidErrInfo.Value = "优惠券已经被领取完了,请下次再来吧!"; return; } } else { //这个条件说明:未中奖 //抛出未中奖的数据 hidStatus.Value = "-2"; hidErrInfo.Value = "优惠券已经被领取完了,请下次再来吧!"; return; } #endregion }
/// <summary> /// 优惠券简单版回复内容 /// </summary> /// <param name="id">模块主键Id</param> /// <param name="apiid">微帐号主键id</param> /// <param name="openid">openid</param> /// <param name="responseType">回复类型:1纯文字,2图文</param> /// <param name="responseVaule">回复的内容</param> private IList<Model.ResponseContentEntity> yhqjdReponse(int id, int apiid, string openid) { IList<Model.ResponseContentEntity> responselist = new List<Model.ResponseContentEntity>(); Model.ResponseContentEntity responseEntity = new Model.ResponseContentEntity(); responseEntity.id = id; responseEntity.wid = apiid; BLL.wx_sTicket sttActBll = new BLL.wx_sTicket(); Model.wx_sTicket actModel = sttActBll.GetModel(id); if (actModel.beginDate > DateTime.Now) { //活动尚未开始 responseEntity.rcType = Model.ReponseContentType.text; responseEntity.rContent = "活动【" + actModel.actionName + "】将于" + actModel.beginDate + "开始。"; } else if (actModel.endDate <= DateTime.Now) { //活动结束 responseEntity.rcType = Model.ReponseContentType.txtpic; responseEntity.rContent = actModel.endNotice; responseEntity.rContent2 = actModel.endContent; responseEntity.detailUrl = MyCommFun.getWebSite() + "/weixin/sticket/end.aspx?wid=" + apiid + "&aid=" + id; responseEntity.picUrl = actModel.endPic; } else { //活动正在进行中 responseEntity.rcType = Model.ReponseContentType.txtpic; responseEntity.rContent = actModel.actionName; responseEntity.rContent2 = actModel.brief; responseEntity.detailUrl = MyCommFun.getWebSite() + "/weixin/sticket/index.aspx?wid=" + apiid + "&aid=" + id; responseEntity.picUrl = actModel.beginPic; } responselist.Add(responseEntity); return responselist; }