private void ShowInfo(int id) { Model.wx_userweixin weixin = GetWeiXinCode(); litUrl.Text = MyCommFun.getWebSite() + "/weixin/ucard/index.aspx?wid=" + weixin.id + "&id=" + id; hidid.Value = id.ToString(); Model.wx_ucard_store store = storeBll.GetModel(id); Model.wx_requestRule rule = rBll.GetModelList("modelFunctionName='会员卡' and modelFunctionId=" + id)[0]; txtKW.Text = rule.reqKeywords; if (store.hfPic != null && store.hfPic.Trim() != "/weixin/ucard/images/ucard_cover.jpg") { txtImgUrl.Text = store.hfPic; imgbeginPic.ImageUrl = store.hfPic; } txtstoreName.Text = store.storeName; if (store.logo != "") { txtLogo.Text = store.logo; } txtcardBrief.Value = store.cardBrief; ddlstoreCatagory.SelectedValue = store.storeCatagory; txttel.Text = store.tel; txtaddr.Text = store.addr; txtconsumePwd.Text = store.consumePwd; txtLatXPoint.Text = store.xPoint == null ? "" : store.xPoint.ToString(); txtLngYPoint.Text = store.yPoint == null ? "" : store.yPoint.ToString(); ClientScript.RegisterStartupScript(GetType(), "message", "<script language='javascript'> $(\"#baiduframe\").attr(\"src\", \"../lbs/MapSelectPoint.aspx?yjindu=" + store.yPoint.Value.ToString() + "&xweidu=" + store.xPoint.Value.ToString() + "\");</script>"); }
/// <summary> /// 会员卡 /// </summary> /// <param name="id"></param> /// <param name="apiid"></param> /// <param name="openid"></param> /// <returns></returns> private IList <Model.ResponseContentEntity> ucardReponse(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_ucard_store ucardBll = new BLL.wx_ucard_store(); Model.wx_ucard_store ucard = ucardBll.GetModel(id); responseEntity.rcType = Model.ReponseContentType.txtpic; responseEntity.rContent = ucard.storeName; responseEntity.rContent2 = ucard.cardBrief; responseEntity.detailUrl = MyCommFun.getWebSite() + "/weixin/ucard/index.aspx?wid=" + apiid + "&id=" + id; responseEntity.picUrl = ucard.hfPic; responselist.Add(responseEntity); return(responselist); }
private void bindData() { BLL.wx_ucard_cardinfo cardBll = new BLL.wx_ucard_cardinfo(); Model.wx_ucard_cardinfo cardinfo = cardBll.GetModelBySid(sid); if (cardinfo != null) { imgTopPic.ImageUrl = cardinfo.instructionsPic; } BLL.wx_ucard_score scoreBll = new BLL.wx_ucard_score(); IList <Model.wx_ucard_score> slist = scoreBll.GetModelList("sid=" + sid); if (slist != null && slist.Count > 0) { lituserdContent.Text = slist[0].userdContent; litscoreRegular.Text = slist[0].scoreRegular; } BLL.wx_ucard_store storeBll = new BLL.wx_ucard_store(); Model.wx_ucard_store store = storeBll.GetModel(sid); if (store != null) { litcardBrief.Text = store.cardBrief; } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/json"; string _action = MyCommFun.QueryString("myact"); string openid = MyCommFun.RequestOpenid(); //得到微信用户的openid Dictionary <string, string> jsonDict = new Dictionary <string, string>(); int sid = MyCommFun.RequestInt("sid"); int uid = 0; BLL.wx_ucard_store storeBll = new BLL.wx_ucard_store(); BLL.wx_ucard_users_consumeinfo conBll = new BLL.wx_ucard_users_consumeinfo(); BLL.wx_ucard_score scoreBll = new BLL.wx_ucard_score(); BLL.wx_ucard_users userBll = new BLL.wx_ucard_users(); Model.wx_ucard_users_consumeinfo consume = new Model.wx_ucard_users_consumeinfo(); Model.wx_ucard_score score = new Model.wx_ucard_score(); Model.wx_ucard_store store = storeBll.GetModel(sid); if (store == null) { jsonDict.Add("ret", "err"); jsonDict.Add("msg", "店铺不存在"); context.Response.Write(MyCommFun.getJsonStr(jsonDict)); return; } if (_action == "userreg") { #region //用户第一次领取卡 jsonDict = new Dictionary <string, string>(); if (sid == 0) { jsonDict.Add("ret", "error"); context.Response.Write(MyCommFun.getJsonStr(jsonDict)); return; } string tel = MyCommFun.QueryString("tel"); string realName = MyCommFun.QueryString("truename"); XCWeiXin.Model.wx_ucard_users user = userBll.GetStoreUserInfo(openid, sid); if (user == null) { //第一次添加 user = new Model.wx_ucard_users(); user.mobile = tel; user.realName = realName; user.regTime = DateTime.Now; user.sid = sid; user.openid = openid; user.ttScore = 0; user.consumeScore = 0; user.qdScore = 0; user.consumeMoney = 0; user.regIp = MXRequest.GetIP(); int ret = userBll.Add(user); if (ret > 0) { jsonDict.Add("ret", "succ"); context.Response.Write(MyCommFun.getJsonStr(jsonDict)); } else { jsonDict.Add("ret", "err"); context.Response.Write(MyCommFun.getJsonStr(jsonDict)); } } else { user.mobile = tel; user.realName = realName; user.regTime = DateTime.Now; user.sid = sid; user.openid = openid; user.regIp = MXRequest.GetIP(); bool ret = userBll.Update(user); if (ret) { jsonDict.Add("ret", "succ"); context.Response.Write(MyCommFun.getJsonStr(jsonDict)); } else { jsonDict.Add("ret", "err"); context.Response.Write(MyCommFun.getJsonStr(jsonDict)); } } context.Response.End(); #endregion } else if (_action == "qiandao") { #region 签到 jsonDict = new Dictionary <string, string>(); sid = MyCommFun.RequestInt("sid"); uid = MyCommFun.RequestInt("uid"); if (sid == 0 || uid == 0) { jsonDict.Add("ret", "error"); context.Response.Write(MyCommFun.getJsonStr(jsonDict)); return; } bool hasqd = conBll.hasDayQD(sid, uid, DateTime.Now); int retScore = 0; if (!hasqd) { //新增 //取签到积分策略 score = scoreBll.GetStoreModel(sid); if (score != null) { //判断是否6天连续签到,并且6天内没有给额外的奖励 DateTime day6before = DateTime.Now.AddDays(-6); int record = conBll.GetRecordCount("sId=" + sid + " and uid=" + uid + " and moduleType='签到' and addTime>='" + day6before.ToShortDateString() + "' and addTime<'" + DateTime.Now.ToShortDateString() + "' and moduleActionId=6 "); if (record >= 5) { consume = new Model.wx_ucard_users_consumeinfo(); consume.sId = sid; consume.uid = uid; consume.moduleType = "签到"; consume.moduleActionName = "连续6天签到奖励"; consume.moduleActionId = 6; consume.score = MyCommFun.Obj2Int(score.qiandao6Score) + score.qiandaoScore.Value; conBll.AddJiFen(consume, 0); retScore = MyCommFun.Obj2Int(score.qiandao6Score) + score.qiandaoScore.Value; } else { consume = new Model.wx_ucard_users_consumeinfo(); consume.sId = sid; consume.uid = uid; consume.moduleType = "签到"; consume.score = score.qiandaoScore.Value; conBll.AddJiFen(consume, 0); retScore = score.qiandaoScore.Value; } } } jsonDict.Add("ret", "succ"); jsonDict.Add("msg", "+" + retScore + "分,明天继续"); context.Response.Write(MyCommFun.getJsonStr(jsonDict)); #endregion } else if (_action == "tequan") { #region //消费: 特权 ,注意,只有在新增这个的时候记录user表总积分,修改的时候 对user表的总积分和金额先减后加 jsonDict = new Dictionary <string, string>(); sid = MyCommFun.RequestInt("sid"); //店铺id uid = MyCommFun.RequestInt("uid"); //用户id string sn = MyCommFun.QueryString("sncode"); string pwd = MyCommFun.QueryString("parssword"); float money = MyCommFun.RequestFloat("money", 0); int pid = MyCommFun.RequestInt("pid"); //特权主键id string type = MyCommFun.QueryString("type"); //tequan:特权 if (sid == 0 || uid == 0 || pid == 0) { jsonDict.Add("ret", "error"); jsonDict.Add("msg", "error"); context.Response.Write(MyCommFun.getJsonStr(jsonDict)); return; } if (pwd != store.consumePwd) { jsonDict.Add("ret", "error"); jsonDict.Add("msg", "密码错误"); context.Response.Write(MyCommFun.getJsonStr(jsonDict)); return; } int ssid = userBll.ExistsStoreAndUser(uid); if (ssid == 0 || sid != ssid) { //验证,用户存在,店铺存在,并且用户属于这个店铺 return; } BLL.wx_ucard_privileges privBll = new BLL.wx_ucard_privileges(); Model.wx_ucard_privileges privileges = privBll.GetModel(pid); if (privileges == null) { jsonDict.Add("ret", "error"); jsonDict.Add("msg", "特权不存在"); context.Response.Write(MyCommFun.getJsonStr(jsonDict)); return; } //积分策略 score = scoreBll.GetStoreModel(sid); int avgScore = score.consumeMoneyScore.Value / score.consumeMoney.Value; //1先添加消费明细,和修改用户的总积分和总消费金额 //IList<Model.wx_ucard_users_consumeinfo> conlist = conBll.GetModelList("moduleType='特权' and moduleActionId=" + privileges.id + " and sid=" + sid + " and uid=" + uid); //if (conlist == null || conlist.Count <= 0 || conlist[0] == null) //{ //新增 consume = new Model.wx_ucard_users_consumeinfo(); consume.moduleActionId = 10; consume.moduleType = "特权"; consume.moduleActionId = privileges.id; consume.moduleActionName = privileges.pName; consume.sId = sid; consume.uid = uid; consume.consumeMoney = (decimal)money; consume.addTime = DateTime.Now; consume.sn = sn; consume.pwd = pwd; consume.cMoneyType = 2; consume.score = (int)(avgScore * money); consume.cScoreType = 1; conBll.Add(consume, true); //} //else //{ // //修改 // consume = conlist[0]; // decimal oldMoney = MyCommFun.Obj2Decimal(consume.consumeMoney, 0); // int oldScore = MyCommFun.Obj2Int(consume.score); // consume.moduleActionName = privileges.pName; // consume.consumeMoney = (decimal)money; // consume.sn = sn; // consume.pwd = pwd; // consume.cMoneyType = 2; // consume.score = (int)(avgScore * money); // conBll.UpdateInfoAndUserTT(consume, oldMoney, oldScore); //} jsonDict.Add("ret", "succ"); jsonDict.Add("msg", "获得" + consume.score.Value + "积分 "); context.Response.Write(MyCommFun.getJsonStr(jsonDict)); #endregion } else if (_action == "lq_yhq") { #region 领取优惠券 jsonDict = new Dictionary <string, string>(); sid = MyCommFun.RequestInt("sid"); //店铺id uid = MyCommFun.RequestInt("uid"); //用户id string sn = MyCommFun.QueryString("sncode"); string pwd = MyCommFun.QueryString("parssword"); float money = MyCommFun.RequestFloat("money", 0); int ticketId = MyCommFun.RequestInt("cid");//优惠券主键id if (sid == 0 || uid == 0 || ticketId == 0) { jsonDict.Add("ret", "error"); jsonDict.Add("msg", "error"); context.Response.Write(MyCommFun.getJsonStr(jsonDict)); return; } if (pwd != store.consumePwd) { jsonDict.Add("ret", "error"); jsonDict.Add("msg", "密码错误"); context.Response.Write(MyCommFun.getJsonStr(jsonDict)); return; } int ssid = userBll.ExistsStoreAndUser(uid); if (ssid == 0 || sid != ssid) { //验证,用户存在,店铺存在,并且用户属于这个店铺 return; } BLL.wx_ucard_ticket ticketBll = new BLL.wx_ucard_ticket(); Model.wx_ucard_ticket ticket = ticketBll.GetModel(ticketId); if (ticket == null) { jsonDict.Add("ret", "error"); jsonDict.Add("msg", "优惠券不存在"); context.Response.Write(MyCommFun.getJsonStr(jsonDict)); return; } int syTimes = ticketBll.getsyTimesByTicket(uid, ticketId); if (syTimes <= 0) { jsonDict.Add("ret", "error"); jsonDict.Add("msg", "已没有使用次数"); context.Response.Write(MyCommFun.getJsonStr(jsonDict)); return; } //积分策略 score = scoreBll.GetStoreModel(sid); int avgScore = score.consumeMoneyScore.Value / score.consumeMoney.Value; //1先添加消费明细,和修改用户的总积分和总消费金额 //新增 consume = new Model.wx_ucard_users_consumeinfo(); consume.moduleActionId = 10; consume.moduleType = "优惠券"; consume.moduleActionId = ticket.id; consume.moduleActionName = ticket.tName; consume.sId = sid; consume.uid = uid; consume.consumeMoney = (decimal)money; consume.addTime = DateTime.Now; consume.sn = sn; consume.pwd = pwd; consume.cMoneyType = 2; consume.score = (int)(avgScore * money); consume.cScoreType = 1; conBll.Add(consume, true); syTimes -= 1; jsonDict.Add("ret", "succ"); jsonDict.Add("msg", "获得" + consume.score.Value + "积分 "); jsonDict.Add("sy", syTimes.ToString()); context.Response.Write(MyCommFun.getJsonStr(jsonDict)); #endregion } else if (_action == "gift") { #region 兑换礼品券 jsonDict = new Dictionary <string, string>(); sid = MyCommFun.RequestInt("sid"); //店铺id uid = MyCommFun.RequestInt("uid"); //用户id string sn = MyCommFun.QueryString("sncode"); string pwd = MyCommFun.QueryString("parssword"); float money = MyCommFun.RequestFloat("money", 0); int giftId = MyCommFun.RequestInt("gid");//礼品主键id if (sid == 0 || uid == 0 || giftId == 0) { jsonDict.Add("ret", "error"); jsonDict.Add("msg", "error"); context.Response.Write(MyCommFun.getJsonStr(jsonDict)); return; } if (pwd != store.consumePwd) { jsonDict.Add("ret", "error"); jsonDict.Add("msg", "密码错误"); context.Response.Write(MyCommFun.getJsonStr(jsonDict)); return; } int ssid = userBll.ExistsStoreAndUser(uid); if (ssid == 0 || sid != ssid) { //验证,用户存在,店铺存在,并且用户属于这个店铺 return; } BLL.wx_ucard_gift giftBll = new BLL.wx_ucard_gift(); Model.wx_ucard_gift gift = giftBll.GetModel(giftId); if (gift == null) { jsonDict.Add("ret", "error"); jsonDict.Add("msg", "优惠券不存在"); context.Response.Write(MyCommFun.getJsonStr(jsonDict)); return; } int userTTScore = userBll.GetUserJiFen(uid); if (userTTScore < gift.score.Value) { jsonDict.Add("ret", "error"); jsonDict.Add("msg", "积分不够"); context.Response.Write(MyCommFun.getJsonStr(jsonDict)); return; } //1先添加消费明细,和修改用户的总积分和总消费金额 //新增 consume = new Model.wx_ucard_users_consumeinfo(); consume.moduleActionId = 10; consume.moduleType = "礼品券"; consume.moduleActionId = gift.id; consume.moduleActionName = gift.gName; consume.sId = sid; consume.uid = uid; consume.addTime = DateTime.Now; consume.sn = sn; consume.pwd = pwd; consume.score = -gift.score.Value; consume.cScoreType = 1; conBll.Add(consume, false); jsonDict.Add("ret", "succ"); jsonDict.Add("msg", "成功兑换礼品扣除 " + gift.score.Value + " 积分 "); context.Response.Write(MyCommFun.getJsonStr(jsonDict)); #endregion } }
//保存 protected void btnSubmit_Click(object sender, EventArgs e) { Model.wx_userweixin weixin = GetWeiXinCode(); Model.wx_requestRuleContent rc = new Model.wx_requestRuleContent(); int id = MyCommFun.Str2Int(hidid.Value); #region //先判断 string strErr = ""; if (this.txtKW.Text.Trim().Length == 0) { strErr += "关键词不能为空!"; } if (this.txtstoreName.Text.Trim().Length == 0) { strErr += "商家名称不能为空!"; } if (strErr != "") { JscriptMsg(strErr, "back", "Error"); return; } #endregion #region 赋值 Model.wx_ucard_store store = new Model.wx_ucard_store(); Model.wx_requestRule rule = new Model.wx_requestRule(); string hfPic = imgbeginPic.ImageUrl; if (txtImgUrl.Text.Trim() != "") { hfPic = txtImgUrl.Text.Trim(); } if (id > 0) { store = storeBll.GetModel(id); } store.storeName = txtstoreName.Text.Trim(); store.logo = txtLogo.Text.Trim(); store.cardBrief = txtcardBrief.Value.Trim(); store.storeCatagory = ddlstoreCatagory.SelectedItem.Value; store.tel = txttel.Text.Trim(); store.addr = txtaddr.Text.Trim(); store.consumePwd = txtconsumePwd.Text.Trim(); store.hfPic = hfPic; store.xPoint = decimal.Parse( txtLatXPoint.Text.Trim()); store.yPoint = decimal.Parse( txtLngYPoint.Text.Trim()); #endregion if (id <= 0) { //新增 store.wid = weixin.id; store.createDate = DateTime.Now; //1新增主表 id = storeBll.Add(store); //2 新增回复规则表 AddRule(weixin.id, id); AddAdminLog(MXEnums.ActionEnum.Add.ToString(), "添加会员卡商家,主键为" + id); //记录日志 JscriptMsg("添加会员卡商家成功!", "business_list.aspx", "Success"); } else { //修改 //1修改主表 storeBll.Update(store); //3 修改回复规则表 IList<Model.wx_requestRule> rlist = rBll.GetModelList("modelFunctionName = '会员卡' and modelFunctionId=" + id); if (rlist != null && rlist.Count > 0) { rule = rlist[0]; rule.reqKeywords = txtKW.Text.Trim(); rBll.Update(rule); } else { AddRule(weixin.id, id); } AddAdminLog(MXEnums.ActionEnum.Edit.ToString(), "修改会员卡商家,主键为" + id); //记录日志 JscriptMsg("修改会员卡商家成功!", "business_list.aspx", "Success"); } }
//保存 protected void btnSubmit_Click(object sender, EventArgs e) { Model.wx_userweixin weixin = GetWeiXinCode(); Model.wx_requestRuleContent rc = new Model.wx_requestRuleContent(); int id = MyCommFun.Str2Int(hidid.Value); #region //先判断 string strErr = ""; if (this.txtKW.Text.Trim().Length == 0) { strErr += "关键词不能为空!"; } if (this.txtstoreName.Text.Trim().Length == 0) { strErr += "商家名称不能为空!"; } if (strErr != "") { JscriptMsg(strErr, "back", "Error"); return; } #endregion #region 赋值 Model.wx_ucard_store store = new Model.wx_ucard_store(); Model.wx_requestRule rule = new Model.wx_requestRule(); string hfPic = imgbeginPic.ImageUrl; if (txtImgUrl.Text.Trim() != "") { hfPic = txtImgUrl.Text.Trim(); } if (id > 0) { store = storeBll.GetModel(id); } store.storeName = txtstoreName.Text.Trim(); store.logo = txtLogo.Text.Trim(); store.cardBrief = txtcardBrief.Value.Trim(); store.storeCatagory = ddlstoreCatagory.SelectedItem.Value; store.tel = txttel.Text.Trim(); store.addr = txtaddr.Text.Trim(); store.consumePwd = txtconsumePwd.Text.Trim(); store.hfPic = hfPic; store.xPoint = decimal.Parse(txtLatXPoint.Text.Trim()); store.yPoint = decimal.Parse(txtLngYPoint.Text.Trim()); #endregion if (id <= 0) { //新增 store.wid = weixin.id; store.createDate = DateTime.Now; //1新增主表 id = storeBll.Add(store); //2 新增回复规则表 AddRule(weixin.id, id); AddAdminLog(MXEnums.ActionEnum.Add.ToString(), "添加会员卡商家,主键为" + id); //记录日志 JscriptMsg("添加会员卡商家成功!", "business_list.aspx", "Success"); } else { //修改 //1修改主表 storeBll.Update(store); //3 修改回复规则表 IList <Model.wx_requestRule> rlist = rBll.GetModelList("modelFunctionName = '会员卡' and modelFunctionId=" + id); if (rlist != null && rlist.Count > 0) { rule = rlist[0]; rule.reqKeywords = txtKW.Text.Trim(); rBll.Update(rule); } else { AddRule(weixin.id, id); } AddAdminLog(MXEnums.ActionEnum.Edit.ToString(), "修改会员卡商家,主键为" + id); //记录日志 JscriptMsg("修改会员卡商家成功!", "business_list.aspx", "Success"); } }
private void bindData() { string jibie = "会员卡号"; BLL.wx_ucard_cardinfo cardBll = new BLL.wx_ucard_cardinfo(); Model.wx_ucard_cardinfo cardinfo = cardBll.GetModelBySid(id); BLL.wx_ucard_users userBll = new BLL.wx_ucard_users(); Model.wx_ucard_users user = userBll.GetStoreUserInfo(openid, id); bool hasLq = true; if (user == null || user.id <= 0) { //说明该用户还未领取这个会员卡 hasLq = false; StringBuilder lqStr = new StringBuilder(""); lqStr.Append(" <div class=\"msk\"><p class=\"explain2\">"); lqStr.Append("<a id=\"showcard\" class=\"receive\" href=\"javascript:void(0)\">领取您的新会员卡</a><span>微时代会员卡,方便携带收藏,永不挂失</span>"); lqStr.Append("</p></div>"); litLQK.Text = lqStr.ToString(); } else { jibie = BLL.wx_ucard_fun.userDegree(id, MyCommFun.Obj2Int(user.ttScore), jibie, out degreeNum); //已经领取了会员卡 bindJiFen(user); //展示积分 bindNewInfo(user); QDInof(user); } if (cardinfo != null) { Page.Title = cardinfo.cardName; //卡版面设计 StringBuilder sbStr = new StringBuilder(""); string bgPic = ""; if (cardinfo.bgUrl == null || cardinfo.bgUrl.Trim().Length <= 0) { bgPic = cardinfo.bgTypeUrl; } else { bgPic = cardinfo.bgUrl; } sbStr.Append(" <img class=\"cardbg\" src=\"" + bgPic + "\">"); sbStr.Append(" <img id=\"cardlogo\" class=\"logo\" src=\"" + cardinfo.logo + "\">"); sbStr.Append(" <h1 style=\"color: " + cardinfo.cardNameColor + "\">" + cardinfo.cardName + "</h1>"); if (hasLq) { sbStr.Append(" <strong class=\"pdo verify\" style=\"color: " + cardinfo.cardNoColor + "\"><span id=\"cdnb\"><em>" + jibie + "</em>" + user.cardNo + "</span></strong>"); } else { sbStr.Append(" <strong class=\"pdo verify\" style=\"color: #A985FF\"><span id=\"cdnb\"><em>普通会员</em>00000000</span></strong>"); } litCardInfo.Text = sbStr.ToString(); } //店铺信息 BLL.wx_ucard_store storeBll = new BLL.wx_ucard_store(); Model.wx_ucard_store store = storeBll.GetModel(id); if (store != null) { litTel.Text = MyCommFun.ObjToStr(store.tel); litAddr.Text = MyCommFun.ObjToStr(store.addr); aAddr.HRef = "http://api.map.baidu.com/marker?location=" + store.yPoint + "," + store.xPoint + "&title=" + store.addr + "&content=" + store.cardBrief + "&output=html"; aTel.HRef = "tel:" + store.tel;; } }