/// <summary> /// 领取红包 /// </summary> /// <returns></returns> public JsonResult GetCoupon() { string tel = HCRequest.GetString("tel"); int hid = HCRequest.getInt("hid"); int memberid = HCRequest.getInt("memberid"); string weixinid = HCRequest.GetString("weixinid"); bool status = false; string msg = PromoterDAL.SendCustomCoupon(weixinid, tel, memberid, hid, out status); return(Json(new { status = status ? 1 : 0, msg = msg })); }
public ActionResult Generalize(string id) { string key = HotelCloud.Common.HCRequest.GetString("key"); string[] keys = key.Split('@'); if (keys.Length == 2) { string weixinID = keys[0]; string userWeiXinID = keys[1]; ViewData["hid"] = id; ViewData["weixinID"] = weixinID; ViewData["userWeiXinID"] = userWeiXinID; hotel3g.Repository.MemberCard CurUser = hotel3g.Repository.MemberHelper.GetFXMemberCard(userWeiXinID, weixinID); if (string.IsNullOrEmpty(CurUser.photo)) { AccessToken TokenItem = MemberHelper.GetAccessToken(weixinID); if (TokenItem.error == 1) { try { WeiXinUserInfo UserInfo = MemberHelper.GetUserWeixinInfo(TokenItem.message, userWeiXinID); CurUser.nickname = UserInfo.nickname; if (!string.IsNullOrEmpty(UserInfo.headimgurl)) { CurUser.photo = UserInfo.headimgurl; string sql_ = "UPDATE dbo.Member SET photo=@photo WHERE weixinID=@weixinID AND userWeiXinNO=@userWeiXinNO"; Dictionary <string, DBParam> Dic = new Dictionary <string, DBParam>(); Dic.Add("photo", new DBParam { ParamValue = CurUser.photo }); Dic.Add("weixinID", new DBParam { ParamValue = weixinID }); Dic.Add("userWeiXinNO", new DBParam { ParamValue = userWeiXinID }); int Count = SQLHelper.Run_SQL(sql_, SQLHelper.GetCon(), Dic); } } catch { } } } if (!string.IsNullOrEmpty(CurUser.photo)) { CurUser.photo = PromoterDAL.GetPromoterCoverImage(CurUser.photo, "PHOTO_" + userWeiXinID, id); } else { CurUser.photo = "/images/member/wechat.png"; } ViewData["CurUser"] = CurUser; //获取酒店信息 hotel3g.Repository.HotelInfoItem HotelInfo = hotel3g.Repository.MemberHelper.GetHotelInfo(weixinID, id); ViewData["HotelLogo"] = PromoterDAL.GetPromoterCoverImage(HotelInfo.hotelLog, "hotelLog", id); ViewData["HotelInfo"] = HotelInfo; //获取公众号信息 //string sql = "SELECT TOP 1 WeiXin2Img,appid,weixintype,WeiXinImg FROM dbo.WeiXinNO WITH(NOLOCK) WHERE WeiXinID=@WeiXinID"; //DataTable dt = SQLHelper.Get_DataTable(sql, SQLHelper.GetCon(), new Dictionary<string, DBParam>() { //{"WeiXinID",new DBParam{ParamValue=weixinID}} //}); ViewData["weixintype"] = "0"; hotel3g.PromoterEntitys.WeiXinPublicInfoResponse WeiXinPublicInfo = PromoterDAL.GetWeiXinPublicInfo(weixinID); if (WeiXinPublicInfo != null && !string.IsNullOrEmpty(WeiXinPublicInfo.appid)) { string weixintype = WeiXinPublicInfo.weixintype.ToString(); ViewData["weixintype"] = weixintype; if (int.Parse(CurUser.memberid) > 0) { if (weixintype.Equals("4")) { string logourl = QR_Code_Url(int.Parse(CurUser.memberid), weixinID); string Logo = PromoterDAL.GetPromoterCoverImage(logourl, "LOGO", id); ViewData["Logo"] = Logo; } else { string logourl = "http://qr.liantu.com/api.php?text=" + HttpUtility.UrlEncode(string.Format("http://hotel.weikeniu.com/Promoter/Coupon/{0}?hid={1}", CurUser.memberid, id)); string Logo = PromoterDAL.GetPromoterCoverImage(logourl, "LOGO", id); //生成跳转链接 ViewData["Logo"] = Logo; } if (string.IsNullOrEmpty(HotelInfo.MainPic)) { //生成跳转链接 string backgroundurl = WeiXinPublicInfo.WeiXinImg;// dt.Rows[0]["WeiXinImg"].ToString(); string background = PromoterDAL.GetPromoterCoverImage(backgroundurl, "BACKGROUND", id); ViewData["background"] = background; } else { //生成跳转链接 string backgroundurl = HotelInfo.MainPic.Split(';')[0]; string background = PromoterDAL.GetPromoterCoverImage(backgroundurl, "BACKGROUND", id); ViewData["background"] = background; } } ViewData["appid"] = WeiXinPublicInfo.appid;// dt.Rows[0]["appid"].ToString(); } //获取红包信息 string sql = "SELECT moneys,Remark,s_JiFen FROM dbo.CouPon WITH(NOLOCK) WHERE weixinID=@WeiXinID AND s_huodongid>0"; System.Data.DataTable hongbao = SQLHelper.Get_DataTable(sql, SQLHelper.GetCon(), new Dictionary <string, DBParam>() { { "WeiXinID", new DBParam { ParamValue = weixinID } } }); var Signature = WeiXinJsSdkDAL.JsApiSignature(weixinID, Request.Url.AbsoluteUri); ViewData["timespan"] = Signature.timestamp; ViewData["signature"] = Signature; if (hongbao != null && hongbao.Rows.Count > 0) { ViewData["Remark"] = hongbao.Rows[0]["Remark"].ToString(); ViewData["money"] = hongbao.Rows[0]["moneys"].ToString(); ViewData["info"] = hongbao.Rows[0]["Remark"].ToString(); ViewData["jifen"] = hongbao.Rows[0]["s_JiFen"].ToString(); } } return(View()); }
/// <summary> /// 购买会员卡成功后处理订单 /// </summary> /// <param name="orderNo"></param> public static void DoneOrderSuccess(string orderNo) { try { System.Data.DataTable dt = HotelCloud.SqlServer.SQLHelper.Get_DataTable("select * from MemberCardBuyRecord wiht(nolock) where orderno=@orderno and orderstatus=0 ", HotelCloud.SqlServer.SQLHelper.GetCon(), new Dictionary <string, HotelCloud.SqlServer.DBParam> { { "orderNo", new HotelCloud.SqlServer.DBParam { ParamValue = orderNo } } }); if (dt.Rows.Count == 0) { return; } int row = HotelCloud.SqlServer.SQLHelper.Run_SQL("update MemberCardBuyRecord set orderStatus=1,payTime=getdate() where orderno=@orderno", HotelCloud.SqlServer.SQLHelper.GetCon(), new Dictionary <string, HotelCloud.SqlServer.DBParam> { { "orderNo", new HotelCloud.SqlServer.DBParam { ParamValue = orderNo } } }); if (row > 0) { int levelRows = HotelCloud.SqlServer.SQLHelper.Run_SQL("update Member set viptype=@viptype where weixinId=@weixinId and userweixinno=@userweixinno ", HotelCloud.SqlServer.SQLHelper.GetCon(), new Dictionary <string, HotelCloud.SqlServer.DBParam> { { "viptype", new HotelCloud.SqlServer.DBParam { ParamValue = dt.Rows[0]["CardLevel"].ToString() } }, { "weixinId", new HotelCloud.SqlServer.DBParam { ParamValue = dt.Rows[0]["weixinId"].ToString() } }, { "userweixinno", new HotelCloud.SqlServer.DBParam { ParamValue = dt.Rows[0]["userweixinId"].ToString() } } }); DataTable db_member = WeiXin.Models.Home.RechargeCard.GetRechargeMemberInfo(dt.Rows[0]["weixinId"].ToString(), dt.Rows[0]["userweixinId"].ToString()); if (db_member.Rows[0]["cardNO"].ToString() == string.Empty) { //没有会员卡生成会员卡号 string cardNo = hotel3g.Repository.MemberHelper.GetNotUsedCard(dt.Rows[0]["hotelId"].ToString(), dt.Rows[0]["weixinId"].ToString()); if (!string.IsNullOrEmpty(cardNo)) { int updateRows = HotelCloud.SqlServer.SQLHelper.Run_SQL("update MemberCard set isuse=1 , binddate=getdate() where weixinId=@weixinId and cardno=@cardno ", HotelCloud.SqlServer.SQLHelper.GetCon(), new Dictionary <string, HotelCloud.SqlServer.DBParam> { { "cardno", new HotelCloud.SqlServer.DBParam { ParamValue = cardNo } }, { "weixinId", new HotelCloud.SqlServer.DBParam { ParamValue = dt.Rows[0]["weixinId"].ToString() } } }); if (updateRows > 0) { updateRows = HotelCloud.SqlServer.SQLHelper.Run_SQL("update Member set cardno=@cardno, name=@name,mobile=@mobile where weixinId=@weixinId and userweixinno=@userweixinno ", HotelCloud.SqlServer.SQLHelper.GetCon(), new Dictionary <string, HotelCloud.SqlServer.DBParam> { { "cardno", new HotelCloud.SqlServer.DBParam { ParamValue = cardNo } }, { "weixinId", new HotelCloud.SqlServer.DBParam { ParamValue = dt.Rows[0]["weixinId"].ToString() } }, { "userweixinno", new HotelCloud.SqlServer.DBParam { ParamValue = dt.Rows[0]["userweixinId"].ToString() } }, { "name", new HotelCloud.SqlServer.DBParam { ParamValue = dt.Rows[0]["name"].ToString() } }, { "mobile", new HotelCloud.SqlServer.DBParam { ParamValue = dt.Rows[0]["mobile"].ToString() } } }); if (updateRows > 0) { //会员注册赠送订房红包 MemberHelper.RegisterCouponGift(dt.Rows[0]["weixinId"].ToString(), dt.Rows[0]["userweixinId"].ToString()); //绑定推广员赠送订房红包 MemberHelper.UpdateCommission(dt.Rows[0]["hotelid"].ToString(), dt.Rows[0]["weixinId"].ToString(), dt.Rows[0]["userweixinId"].ToString()); //推广员送红包 int PromoterID = MemberHelper.GetPromoterID(dt.Rows[0]["userweixinId"].ToString(), dt.Rows[0]["weixinId"].ToString()); if (PromoterID > 0) { bool pstatus = false; string pstr = PromoterDAL.SendCustomCoupon(dt.Rows[0]["weixinId"].ToString(), dt.Rows[0]["mobile"].ToString(), Convert.ToInt32(db_member.Rows[0]["Id"].ToString()), Convert.ToInt32(dt.Rows[0]["hotelid"].ToString()), out pstatus); } } } } } //送红包 积分 DataTable dt_hb = HotelCloud.SqlServer.SQLHelper.Get_DataTable("select hongbaomoney,givejifen from MemberCardCustom with(nolock) where Id=@Id", HotelCloud.SqlServer.SQLHelper.GetCon(), new Dictionary <string, HotelCloud.SqlServer.DBParam> { { "Id", new HotelCloud.SqlServer.DBParam { ParamValue = dt.Rows[0]["CardId"].ToString() } } }); if (dt_hb.Rows.Count > 0) { string hongbaomoney = dt_hb.Rows[0]["hongbaomoney"].ToString(); if (!string.IsNullOrEmpty(hongbaomoney) && Convert.ToInt32(Convert.ToDecimal(hongbaomoney)) > 0) { int hbmoney = Convert.ToInt32(Convert.ToDecimal(hongbaomoney)); int rows = AddCardCoupon(dt.Rows[0]["weixinId"].ToString(), dt.Rows[0]["userweixinId"].ToString(), hbmoney, Convert.ToInt32(dt.Rows[0]["cardId"].ToString())); } int givejifen = Convert.ToInt32(dt_hb.Rows[0]["givejifen"].ToString()); if (givejifen > 0) { //重新获取会员最新信息 DataTable dbmember_new = WeiXin.Models.Home.RechargeCard.GetRechargeMemberInfo(dt.Rows[0]["weixinId"].ToString(), dt.Rows[0]["userweixinId"].ToString()); int userId = 0; string cardno = string.Empty; if (dbmember_new.Rows.Count > 0) { int.TryParse(dbmember_new.Rows[0]["Id"].ToString(), out userId); cardno = dbmember_new.Rows[0]["cardno"].ToString(); } int row_jifen = AddCardJifen(dt.Rows[0]["weixinId"].ToString(), dt.Rows[0]["userweixinId"].ToString(), userId, cardno, givejifen, Convert.ToInt32(dt.Rows[0]["cardId"].ToString())); if (row_jifen > 0) { row_jifen = MemberCardBuyRecord.UpdateUserJifen(dt.Rows[0]["weixinId"].ToString(), dt.Rows[0]["userweixinId"].ToString(), givejifen); } } } } } catch (Exception ex) { WeiXin.Common.Logger.Instance.Error(ex.ToString()); } }