Ejemplo n.º 1
0
        /// <summary>
        /// 发送客服图片消息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public static void SendNews(string AdminHotelid, string ToUserName, string FromUserName)
        {
            string postUrl = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token={0}";

            postUrl = string.Format(postUrl, TemplateMessage.GetAccessToken(AdminHotelid));
            string menuInfo = SendNewsContent(AdminHotelid, ToUserName, FromUserName);

            if (menuInfo != "")
            {
                string sqljosn = TemplateMessage.PostWebRequest(postUrl, menuInfo);
                //JavaScriptSerializer serializer = new JavaScriptSerializer();
                //Dictionary<string, object> json = (Dictionary<string, object>)serializer.DeserializeObject(sqljosn);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 扫码成功 发送员工通知
        /// </summary>
        /// <param name="hotelId"></param>
        /// <param name="userid"></param>
        /// <param name="userOpenid"></param>
        /// <param name="openid"></param>
        /// <param name="isVip"></param>
        private static void RemindStaff(string hotelId, string userid, string userOpenid, string openid, bool isVip)
        {
            bool isOthers = false;

            //查询客人第一次扫描的员工id
            StringBuilder sb = new StringBuilder();

            sb.Append(@"
            SELECT TOP 1 TGMember
            FROM    MemberSource
            WHERE   HotelId = @HotelId
                    AND openid = @openid
                    AND LEN(TGMember) > 4
            ORDER BY AddTime ASC
            ");
            SqlParam[] param = new SqlParam[] {
                new SqlParam("@HotelId", hotelId),
                new SqlParam("@openid", openid)
            };
            DataTable dt = DataFactory.SqlDataBase().GetDataTableBySQL(sb, param);

            if (dt != null && dt.Rows.Count > 0)
            {
                if (userid != dt.Rows[0]["TGMember"].ToString())
                {
                    isOthers = true;
                }
            }

            JavaScriptSerializer        serializer = new JavaScriptSerializer();
            Dictionary <string, object> csInfo     = new Dictionary <string, object>();

            csInfo.Add("touser", userOpenid);                                          //微信id
            csInfo.Add("template_id", ApplicationHelper.GetAdminTemplateId("关注成功通知")); //推送模板id
            string url    = "";
            string title  = "恭喜您又有一位客人扫描您的推广二维码!";
            string remark = "";

            if (isVip)        //客人是国光会员
            {
                if (isOthers) //之前已经扫过他人推广码
                {
                    remark = "客人已与他人绑定关系,客人本次微网消费您将获得奖金";
                }
                else//未扫过他人推广码
                {
                    remark = "客人已和您绑定永久关系";
                }
            }
            else//还未注册未会员
            {
                if (isOthers)//之前已经扫过他人推广码
                {
                    remark = "客人已与他人绑定关系,客人本次微网消费您将获得奖金";
                }
                else//未扫过他人推广码
                {
                    //remark = "客人还未注册,请提醒客人注册会员,才能与您绑定永久关系";
                    remark = "客人还未注册,请提醒客人注册会员,才能查看订单详情及获得积分";
                }
            }

            csInfo.Add("url", url);//点击跳转地址

            #region ****** 参数信息 ******

            Dictionary <string, object> data = new Dictionary <string, object>();
            data.Add("first", new Dictionary <string, object>
            {
                { "value", title },
                { "color", "#000" }
            });
            //
            data.Add("keyword1", new Dictionary <string, object>
            {
                { "value", "******" },
                { "color", "#000" }
            });
            //
            data.Add("keyword2", new Dictionary <string, object>
            {
                { "value", DateTime.Now.ToString("yyyy-MM-dd HH:mm") },
                { "color", "#000" }
            });

            data.Add("remark", new Dictionary <string, object>
            {
                { "value", remark },
                { "color", "#000" }
            });
            #endregion
            csInfo.Add("data", data);
            string menuInfo = serializer.Serialize(csInfo);
            string postUrl  = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token={0}";
            postUrl = string.Format(postUrl, TemplateMessage.GetAccessToken("1"));
            TemplateMessage.PostWebRequest(postUrl, menuInfo);
        }