コード例 #1
0
ファイル: WeixinVoiceUtil.cs プロジェクト: radtek/etowncode
        // <summary>
        /// 获取jsapi_ticket
        /// jsapi_ticket是公众号用于调用微信JS接口的临时票据。
        /// 正常情况下,jsapi_ticket的有效期为7200秒,通过access_token来获取。
        /// 由于获取jsapi_ticket的api调用次数非常有限,频繁刷新jsapi_ticket会导致api调用受限,影响自身业务,开发者必须在自己的服务全局缓存jsapi_ticket 。
        /// </summary>
        /// <param name="access_token">BasicAPI获取的access_token,也可以通过TokenHelper获取</param>
        /// <returns></returns>
        public string GetTickect(string access_token, int comid)
        {
            try
            {
                if (HttpRuntime.Cache["jsapiticket" + comid] == null)
                {
                    var    url      = string.Format("https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token={0}&type=jsapi", access_token);
                    string jsonText = new GetUrlData().HttpGet(url);

                    XmlDocument doc = (XmlDocument)JsonConvert.DeserializeXmlNode("{\"root\":" + jsonText + "}");

                    XmlElement rootElement = doc.DocumentElement;
                    string     jsTicket    = rootElement.SelectSingleNode("ticket").InnerText;

                    //有效期7200秒,开发者必须在自己的服务全局缓存jsapi_ticket
                    HttpRuntime.Cache.Insert("jsapiticket" + comid, jsTicket, null, DateTime.Now.AddHours(2), System.Web.Caching.Cache.NoSlidingExpiration); //HttpRuntime.Cache与HttpContext.Current.Cache是同一对象,建议使用HttpRuntime.Cache

                    return(jsTicket);
                }
                else
                {
                    return(System.Web.HttpRuntime.Cache.Get("jsapiticket" + comid).ToString());
                }
            }
            catch
            {
                return("");
            }
        }
コード例 #2
0
ファイル: WeixinVoiceUtil.cs プロジェクト: radtek/etowncode
        /// <summary>
        /// 获取凭证(首先判断数据库是否存在凭证以及是否过期,如过期,重新获取)
        /// </summary>
        /// <returns></returns>
        public WXAccessToken GetAccessToken(int comid, string AppId, string AppSecret)
        {
            try
            {
                DateTime      fitcreatetime = DateTime.Now.AddHours(-2);
                WXAccessToken token         = new WXAccessTokenData().GetLaststWXAccessToken(fitcreatetime, comid);
                if (token == null)
                {
                    string geturl   = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" + AppId + "&secret=" + AppSecret;
                    string jsonText = new GetUrlData().HttpGet(geturl);

                    XmlDocument doc = (XmlDocument)JsonConvert.DeserializeXmlNode("{\"root\":" + jsonText + "}");

                    XmlElement rootElement  = doc.DocumentElement;
                    string     access_token = rootElement.SelectSingleNode("access_token").InnerText;

                    //把获取到的凭证录入数据库中
                    token = new WXAccessToken()
                    {
                        Id           = 0,
                        ACCESS_TOKEN = access_token,
                        CreateDate   = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")),
                        Comid        = comid
                    };
                    int edittoken = new WXAccessTokenData().EditAccessToken(token);
                }
                return(token);
            }
            catch
            {
                return(null);
            }
        }
コード例 #3
0
        /// <summary>
        /// 上传图文消息素材(微信群发),返回media_id
        /// </summary>
        /// <param name="articles"></param>
        /// <returns></returns>
        public string Uploadnews(string ACCESS_TOKEN, List <Wxarticle> articles, out string created_at)
        {
            if (articles == null)
            {
                created_at = "";
                return("");
            }
            if (articles.Count == 0)
            {
                created_at = "";
                return("");
            }
            string requesturl = "https://api.weixin.qq.com/cgi-bin/media/uploadnews?access_token=" + ACCESS_TOKEN;

            Wxarticles obj = new Wxarticles();

            obj.articles = articles;

            string json_param = JsonConvert.SerializeObject(obj);

            #region
            //System.Web.Script.Serialization.JavaScriptSerializer jss = new System.Web.Script.Serialization.JavaScriptSerializer();

            //StringBuilder json_param = new StringBuilder();
            //jss.Serialize(obj, json_param);

            //string json_param = "{\"articles\": [";
            //foreach (Wxarticle m in articles)
            //{
            //    json_param += "{" +
            //            "\"thumb_media_id\":\"" + m.thumb_media_id + "\"," +
            //            "\"author\":\"" + m.author + "\"," +
            //             "\"title\":\"" + m.title + "\"," +
            //             "\"content_source_url\":\"" + m.content_source_url + "\"," +
            //             "\"content\":\"" + m.content + "\"," +
            //             "\"digest\":\"" + m.digest + "\"," +
            //            "\"show_cover_pic\":\"" + m.show_cover_pic + "\"" +
            //            "},";
            //}
            //json_param = json_param.Substring(0, json_param.Length - 1);
            //json_param += "]}";
            #endregion
            try
            {
                string ret = new GetUrlData().HttpPost(requesturl, json_param.ToString());
                JavaScriptSerializer ser = new JavaScriptSerializer();
                UploadMM             foo = ser.Deserialize <UploadMM>(ret);
                created_at = foo.created_at;

                return(foo.media_id);
            }
            catch
            {
                created_at = "";
                return("");
            }
        }
コード例 #4
0
ファイル: htest.aspx.cs プロジェクト: radtek/etowncode
        protected void Button2_Click(object sender, EventArgs e)
        {
            ////TxtHelper.WriteFile("D:\\site\\b2betown\\ETS2.WebApp\\weixinlogs\\aalog.txt", "uuu");
            ////TxtHelper.CheckLog("D:\\site\\b2betown\\ETS2.WebApp\\weixinlogs\\aalog.txt", "uuu");
            string lengthurl = TextBox1.Text.Trim();
            string shorturl  = new GetUrlData().ToShortUrl(lengthurl);

            Label1.Text = shorturl;
        }
コード例 #5
0
ファイル: ObtainGZList.aspx.cs プロジェクト: radtek/etowncode
        private void AskWeixin(string token, string nextopenid, int nowotainno)
        {
            //获取关注者列表

            string geturl = "https://api.weixin.qq.com/cgi-bin/user/get?access_token=" + token;

            if (nextopenid != "")
            {
                geturl = "https://api.weixin.qq.com/cgi-bin/user/get?access_token=" + token + "&next_openid=" + nextopenid;
            }
            string      jsonText = new GetUrlData().HttpGet(geturl);
            XmlDocument doc      = (XmlDocument)JsonConvert.DeserializeXmlNode("{\"root\":" + jsonText + "}");

            XmlElement rootElement = doc.DocumentElement;

            if (rootElement.SelectSingleNode("errcode") == null)
            {
                int     id          = 0;
                string  total       = rootElement.SelectSingleNode("total").InnerText;
                string  count       = rootElement.SelectSingleNode("count").InnerText;
                string  next_openid = rootElement.SelectSingleNode("next_openid").InnerText;
                XmlNode data        = rootElement.SelectSingleNode("data");
                string  openid      = "";
                foreach (XmlNode node in data.ChildNodes)
                {
                    openid += node.InnerText + ",";
                }
                openid = openid.Substring(0, openid.Length - 1);

                DateTime obtaintime = DateTime.Now;
                string   errcode    = "";
                string   errmsg     = "";

                int insertlog = new ObtainGzListLogData().InsObtainLog(id, total, count, openid, next_openid, obtaintime, errcode, errmsg, comid, dealuserid, nowotainno);
            }
            else
            {
                int      id          = 0;
                string   total       = "0";
                string   count       = "0";
                string   next_openid = "0";
                string   openid      = "";
                DateTime obtaintime  = DateTime.Now;
                XmlNode  data        = rootElement.SelectSingleNode("data");
                string   errcode     = rootElement.SelectSingleNode("errcode").InnerText;
                string   errmsg      = rootElement.SelectSingleNode("errmsg").InnerText;

                int insertlog = new ObtainGzListLogData().InsObtainLog(id, total, count, openid, next_openid, obtaintime, errcode, errmsg, comid, dealuserid, nowotainno);
            }
        }
コード例 #6
0
ファイル: HzinsInter.cs プロジェクト: radtek/etowncode
        //退保
        public string Hzins_orderCancel(int orderid)
        {
            string transNo = orderid.ToString(); //(以后需要修改为渠道商订单号)易流水号,每次请求不能相同

            //根据订单号得到投保单号
            string insureNo = new Api_hzins_OrderApplyResp_OrderExtData().GetinsureNumbyorderid(orderid);//投保单号

            if (insureNo == "")
            {
                return("");
            }

            //签名,预签名数据:密钥+渠道商身份标识+交易流水号+方案代码
            string sign = EncryptionHelper.ToMD5(signkey + partnerId + transNo + insureNo, "UTF-8");

            sign = sign.ToLower();

            string s = "{" +
                       "\"transNo\":\"" + transNo + "\"," +
                       "\"partnerId\":" + partnerId + "," +
                       "\"insureNo\":\"" + insureNo + "\"," +
                       "\"sign\":\"" + sign + "\"," +
                       "\"extendInfo\":{" +
                       "\"userId\":null," +
                       "\"email\":null," +
                       "\"userName\":null," +
                       "\"phone\":null" +
                       "}" +
                       "}";

            string str = new GetUrlData().HttpPostJson("http://channel.hzins.com/api/orderCancel", s.Trim());

            //录入和慧择网交互日志
            ApiLog mapilog = new ApiLog
            {
                Id            = 0,
                request_type  = "orderCancel",
                Serviceid     = 2,
                Str           = s.Trim(),
                Subdate       = DateTime.Now,
                ReturnStr     = str,
                ReturnSubdate = DateTime.Now,
                Errmsg        = "",
            };
            int ins = new ApiLogData().EditLog(mapilog);

            //TxtHelper.WriteFile("D:\\site\\b2betown\\ETS2.WebApp\\BaoxianLog.txt", "发送信息:" + s.Trim() + "<br>" + "返回信息:" + str);
            return(str);
        }
コード例 #7
0
ファイル: h5test112.aspx.cs プロジェクト: radtek/etowncode
        //确定
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (t_caozuo.Text.Trim() == "")
            {
                Label1.Text = "请填写操作类型";
                return;
            }
            if (t_xml.Text.Trim() == "")
            {
                Label1.Text = "请填写发送内容";
                return;
            }

            string str = new GetUrlData().HttpPostJson("http://channel.hzins.com/api/" + t_caozuo.Text.Trim(), t_xml.Text.Trim());

            Label1.Text = str;
        }
コード例 #8
0
ファイル: ObtainGZList.aspx.cs プロジェクト: radtek/etowncode
        private int AskWeixinTotal(string token)
        {
            //获取关注者列表

            string geturl = "https://api.weixin.qq.com/cgi-bin/user/get?access_token=" + token;

            string      jsonText = new GetUrlData().HttpGet(geturl);
            XmlDocument doc      = (XmlDocument)JsonConvert.DeserializeXmlNode("{\"root\":" + jsonText + "}");

            XmlElement rootElement = doc.DocumentElement;

            if (rootElement.SelectSingleNode("errcode") == null)
            {
                string total = rootElement.SelectSingleNode("total").InnerText;
                return(int.Parse(total));
            }
            else
            {
                return(0);
            }
        }
コード例 #9
0
        /// <summary>
        /// 微信图文群发
        /// </summary>
        /// <param name="tousernames"></param>
        /// <param name="media_id"></param>
        /// <returns></returns>
        public string Wxqunfanews(string ACCESS_TOKEN, string[] tousernames, string media_id)
        {
            if (ACCESS_TOKEN == "")
            {
                return("ACCESS_TOKEN为空");
            }
            if (tousernames.Length <= 0)
            {
                return("请选择群发用户");
            }
            if (media_id == "")
            {
                return("请选择图文消息");
            }
            string requesturl = "https://api.weixin.qq.com/cgi-bin/message/mass/send?access_token=" + ACCESS_TOKEN;

            string json_param = "{\"touser\":[";

            foreach (string m in tousernames)
            {
                if (m != "")
                {
                    json_param += "\"" + m + "\",";
                }
            }
            json_param  = json_param.Substring(0, json_param.Length - 1);
            json_param += " ]," +
                          "\"mpnews\":{" +
                          "\"media_id\":\"" + media_id + "\"" +
                          "}," +
                          "\"msgtype\":\"mpnews\"" +
                          "}";

            string ret = new GetUrlData().HttpPost(requesturl, json_param);
            JavaScriptSerializer ser = new JavaScriptSerializer();
            WxQunfaMM            foo = ser.Deserialize <WxQunfaMM>(ret);

            return(foo.errcode);
        }
コード例 #10
0
        public static void AsyncSend(string updateurl, string pno, int confirmnum, string confirmtime, int agentcomid, int comidd1, int validateticketlogid, int aorderid)
        {
            Agent_asyncsendlog log = new Agent_asyncsendlog
            {
                Id                = 0,
                Pno               = pno,
                Num               = confirmnum,
                Sendtime          = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")),
                Confirmtime       = DateTime.Parse(confirmtime),
                Issendsuc         = 0,//0失败;1成功
                Agentupdatestatus = (int)AgentUpdateStatus.Fail,
                Agentcomid        = agentcomid,
                Comid             = comidd1,
                Remark            = "",
                Issecondsend      = 0,
                Platform_req_seq  = (1000000000 + agentcomid).ToString() + DateTime.Now.ToString("yyyyMMddhhssmm") + CommonFunc.CreateNum(6),//请求流水号
                Request_content   = "",
                Response_content  = "",
                b2b_etcket_logid  = validateticketlogid
            };
            int inslog = new Agent_asyncsendlogData().EditLog(log);

            log.Id = inslog;
            try
            {
                //获得分销商信息
                Agent_company agentinfo = new AgentCompanyData().GetAgentCompany(agentcomid);
                if (agentinfo != null)
                {
                    string agent_updateurl = agentinfo.Agent_updateurl;

                    #region 糯米分销
                    if (agentinfo.Agent_type == (int)AgentCompanyType.NuoMi)//糯米分销
                    {
                        string re = new GetUrlData().HttpPost(updateurl, "");

                        XmlDocument doc  = (XmlDocument)JsonConvert.DeserializeXmlNode("{\"root\":" + re + "}");
                        XmlElement  root = doc.DocumentElement;
                        string      info = root.SelectSingleNode("info").InnerText;

                        //只要返回了数据,则是发送成功
                        log.Id               = inslog;
                        log.Issendsuc        = 1;
                        log.Request_content  = updateurl;
                        log.Response_content = re;

                        if (info == "success")
                        {
                            string errCode = root.SelectSingleNode("res/errCode").InnerText;//分销商更新结果
                            if (errCode == "0")
                            {
                                log.Agentupdatestatus = (int)AgentUpdateStatus.Suc;
                                new Agent_asyncsendlogData().EditLog(log);
                            }
                            else
                            {
                                log.Agentupdatestatus = (int)AgentUpdateStatus.Fail;
                                new Agent_asyncsendlogData().EditLog(log);
                            }
                        }
                        else
                        {
                            log.Remark            = info;
                            log.Agentupdatestatus = (int)AgentUpdateStatus.Fail;
                            new Agent_asyncsendlogData().EditLog(log);
                        }
                    }
                    #endregion
                    #region 一般分销
                    else //一般分销
                    {
                        /*根据订单号得到分销商订单请求记录(当前需要得到原订单请求流水号)*/
                        List <Agent_requestlog> listagent_rlog = new Agent_requestlogData().GetAgent_requestlogByOrdernum(aorderid.ToString(), "add_order", "1");
                        if (listagent_rlog == null)
                        {
                            log.Remark            = "根据订单号得到分销商订单请求记录失败";//单引号替换为'',双引号不用处理;
                            log.Agentupdatestatus = (int)AgentUpdateStatus.Fail;
                            new Agent_asyncsendlogData().EditLog(log);
                            return;
                        }
                        if (listagent_rlog.Count == 0)
                        {
                            log.Remark            = "根据订单号得到分销商订单请求记录失败.";//单引号替换为'',双引号不用处理;
                            log.Agentupdatestatus = (int)AgentUpdateStatus.Fail;
                            new Agent_asyncsendlogData().EditLog(log);
                            return;
                        }


                        /*验证通知发送内容*/
                        string sbuilder = string.Format("<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                                                        "<business_trans>" +
                                                        "<request_type>sync_order</request_type>" +  //<!--验证同步-->
                                                        "<req_seq>{0}</req_seq>" +                   //<!--原订单请求流水号-->
                                                        "<platform_req_seq>{1}</platform_req_seq>" + //<!--平台请求流水号-->
                                                        "<order>" +                                  //<!--订单信息-->
                                                        "<code>{5}</code>" +                         //<!-- 验证电子码 y-->
                                                        "<order_num>{2}</order_num>" +               //<!-- 订单号 y-->
                                                        "<num>{3}</num>" +                           //<!-- 使用张数 -->
                                                        "<use_time>{4}</use_time>" +                 //<!--  使用时间  -->
                                                        "</order>" +
                                                        "</business_trans>", listagent_rlog[0].Req_seq, log.Platform_req_seq, aorderid, confirmnum, CommonFunc.ConvertDateTimeInt(DateTime.Parse(confirmtime)), pno);

                        #region 分销通知发送方式post
                        if (agentinfo.inter_sendmethod.ToLower() == "post")
                        {
                            string re = "";
                            if (agentcomid == 6490)
                            {
                                re = new GetUrlData().HttpPost(updateurl, sbuilder);

                                updateurl += "?xml=" + sbuilder;//只为记录
                            }
                            else
                            {
                                updateurl += "?xml=" + sbuilder;
                                re         = new GetUrlData().HttpPost(updateurl, "");
                            }


                            //只要返回了数据,则是发送成功
                            log.Id               = inslog;
                            log.Issendsuc        = 1;
                            log.Request_content  = updateurl;
                            log.Response_content = re;

                            log.Remark = re.Replace("'", "''");//单引号替换为'',双引号不用处理;
                            if (re.Length >= 7)
                            {
                                re = re.Substring(0, 7);
                            }
                            if (re == "success")
                            {
                                log.Agentupdatestatus = (int)AgentUpdateStatus.Suc;
                                new Agent_asyncsendlogData().EditLog(log);
                            }
                            else
                            {
                                log.Agentupdatestatus = (int)AgentUpdateStatus.Fail;
                                new Agent_asyncsendlogData().EditLog(log);
                            }
                        }
                        #endregion
                        #region 分销通知发送方式get
                        else
                        {
                            if (updateurl.IndexOf('?') > -1)
                            {
                                updateurl += "&xml=" + sbuilder;
                            }
                            else
                            {
                                updateurl += "?xml=" + sbuilder;
                            }

                            string re = new GetUrlData().HttpGet(updateurl);
                            //只要返回了数据,则是发送成功
                            log.Id               = inslog;
                            log.Issendsuc        = 1;
                            log.Request_content  = updateurl;
                            log.Response_content = re;

                            log.Remark = re.Replace("'", "''");//单引号替换为'',双引号不用处理;
                            if (re.Length >= 7)
                            {
                                re = re.Substring(0, 7);
                            }
                            if (re == "success")
                            {
                                log.Agentupdatestatus = (int)AgentUpdateStatus.Suc;
                                new Agent_asyncsendlogData().EditLog(log);
                            }
                            else
                            {
                                log.Agentupdatestatus = (int)AgentUpdateStatus.Fail;
                                new Agent_asyncsendlogData().EditLog(log);
                            }
                        }
                        #endregion
                    }
                    #endregion
                }
                else
                {
                    log.Remark            = "分销商获取失败";
                    log.Agentupdatestatus = (int)AgentUpdateStatus.Fail;
                    new Agent_asyncsendlogData().EditLog(log);
                }
            }
            catch (Exception e)
            {
                log.Id     = inslog;
                log.Remark = e.Message.Replace("'", "''");//单引号替换为'',双引号不用处理
                new Agent_asyncsendlogData().EditLog(log);
            }
        }
コード例 #11
0
        public string AsyncSend(Agent_asyncsendlog log1)
        {
            lock (lockobj)
            {
                Agent_asyncsendlog log = new Agent_asyncsendlog
                {
                    Id                = 0,
                    Pno               = log1.Pno,
                    Num               = log1.Num,
                    Sendtime          = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")),
                    Confirmtime       = log1.Confirmtime,
                    Issendsuc         = 0,//0失败;1成功
                    Agentupdatestatus = (int)AgentUpdateStatus.Fail,
                    Agentcomid        = log1.Agentcomid,
                    Comid             = log1.Comid,
                    Remark            = "",
                    Issecondsend      = 1,
                    Platform_req_seq  = log1.Platform_req_seq,//平台流水号,同一次验证的平台流水号相同,分销商根据平台流水号判断是否是同一次验证
                    Request_content   = "",
                    Response_content  = "",
                    b2b_etcket_logid  = log1.b2b_etcket_logid
                };
                int inslog = new Agent_asyncsendlogData().EditLog(log);
                log.Id = inslog;
                try
                {
                    var eticketinfo = new B2bEticketData().GetEticketDetail(log1.Pno);
                    if (eticketinfo.Agent_id > 0)//分销商电子票,需要发送验证同步请求
                    {
                        //获得分销商信息
                        Agent_company agentinfo = new AgentCompanyData().GetAgentCompany(log1.Agentcomid);
                        if (agentinfo != null)
                        {
                            string agent_updateurl = agentinfo.Agent_updateurl;
                            #region 糯米分销
                            if (agentinfo.Agent_type == (int)AgentCompanyType.NuoMi)//糯米分销
                            {
                                //查询站外码状态
                                string username    = agentinfo.Agent_auth_username; //百度糯米用户名
                                string token       = agentinfo.Agent_auth_token;    //百度糯米token
                                string code        = eticketinfo.Pno;               //券码
                                string bindcomname = agentinfo.Agent_bindcomname;   //供应商名称

                                string updateurl = agent_updateurl + "?auth={\"userName\":\"" + username + "\",\"token\":\"" + token + "\"}&code=" + code + "&userName="******"&dealId=&phone=";;


                                string re = new GetUrlData().HttpPost(updateurl, "");

                                XmlDocument doc  = (XmlDocument)JsonConvert.DeserializeXmlNode("{\"root\":" + re + "}");
                                XmlElement  root = doc.DocumentElement;
                                string      info = root.SelectSingleNode("info").InnerText;

                                //只要返回了数据,则是发送成功
                                log.Id               = inslog;
                                log.Issendsuc        = 1;
                                log.Request_content  = updateurl;
                                log.Response_content = re;

                                if (info == "success")
                                {
                                    string errCode = root.SelectSingleNode("res/errCode").InnerText;//分销商更新结果
                                    if (errCode == "0")
                                    {
                                        log.Agentupdatestatus = (int)AgentUpdateStatus.Suc;
                                        new Agent_asyncsendlogData().EditLog(log);

                                        return("糯米成功");
                                    }
                                    else
                                    {
                                        log.Agentupdatestatus = (int)AgentUpdateStatus.Fail;
                                        new Agent_asyncsendlogData().EditLog(log);

                                        return("糯米失败:" + log.Agentupdatestatus);
                                    }
                                }
                                else
                                {
                                    log.Remark            = info;
                                    log.Agentupdatestatus = (int)AgentUpdateStatus.Fail;
                                    new Agent_asyncsendlogData().EditLog(log);

                                    return("糯米失败:" + log.Remark);
                                }
                            }
                            #endregion
                            #region 一般分销推送验证同步请求
                            else
                            {
                                //一般分销推送验证同步请求

                                if (agent_updateurl.Trim() == "" || agentinfo.Inter_deskey == "")
                                {
                                    log.Remark            = "分销商验证同步通知或秘钥没提供";//单引号替换为'',双引号不用处理;
                                    log.Agentupdatestatus = (int)AgentUpdateStatus.Fail;
                                    new Agent_asyncsendlogData().EditLog(log);
                                    return(log.Remark);
                                }

                                if (eticketinfo.Oid == 0)
                                {
                                    log.Remark            = "电子票对应的订单号为0";//单引号替换为'',双引号不用处理;
                                    log.Agentupdatestatus = (int)AgentUpdateStatus.Fail;
                                    new Agent_asyncsendlogData().EditLog(log);
                                    return(log.Remark);
                                }

                                //a订单:原分销向指定商户提交的订单;b订单:指定商户下的绑定分销向拥有产品的商户提交的订单
                                //电子票表中记录的Oid是b订单
                                //判断b订单 是否 属于某个a订单
                                B2b_order loldorder = new B2bOrderData().GetOldorderBybindingId(eticketinfo.Oid);
                                if (loldorder != null)
                                {
                                    eticketinfo.Oid = loldorder.Id;
                                }
                                /*根据订单号得到分销商订单请求记录(当前需要得到原订单请求流水号)*/
                                List <Agent_requestlog> listagent_rlog = new Agent_requestlogData().GetAgent_requestlogByOrdernum(eticketinfo.Oid.ToString(), "add_order", "1");
                                if (listagent_rlog == null)
                                {
                                    log.Remark            = "根据订单号得到分销商订单请求记录失败";//单引号替换为'',双引号不用处理;
                                    log.Agentupdatestatus = (int)AgentUpdateStatus.Fail;
                                    new Agent_asyncsendlogData().EditLog(log);
                                    return(log.Remark);
                                }

                                if (listagent_rlog.Count == 0)
                                {
                                    log.Remark            = "根据订单号得到分销商订单请求记录失败.";//单引号替换为'',双引号不用处理;
                                    log.Agentupdatestatus = (int)AgentUpdateStatus.Fail;
                                    new Agent_asyncsendlogData().EditLog(log);
                                    return(log.Remark);
                                }


                                /*验证通知发送内容*/
                                string sbuilder = string.Format("<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                                                                "<business_trans>" +
                                                                "<request_type>sync_order</request_type>" +  //<!--验证同步-->
                                                                "<req_seq>{0}</req_seq>" +                   //<!--原订单请求流水号-->
                                                                "<platform_req_seq>{1}</platform_req_seq>" + //<!--平台请求流水号-->
                                                                "<order>" +                                  //<!--订单信息-->
                                                                "<order_num>{2}</order_num>" +               //<!-- 订单号 y-->
                                                                "<num>{3}</num>" +                           //<!-- 使用张数 -->
                                                                "<use_time>{4}</use_time>" +                 //<!--  使用时间  -->
                                                                "</order>" +
                                                                "</business_trans>", listagent_rlog[0].Req_seq, log.Platform_req_seq, eticketinfo.Oid, log.Num, ConvertDateTimeInt(log.Confirmtime));

                                string updateurl = agent_updateurl + "?xml=" + sbuilder;


                                string re = new GetUrlData().HttpPost(updateurl, "");

                                //只要返回了数据,则是发送成功
                                log.Id               = inslog;
                                log.Issendsuc        = 1;
                                log.Request_content  = updateurl;
                                log.Response_content = re;

                                log.Remark = re.Replace("'", "''");//单引号替换为'',双引号不用处理;
                                if (re.Length >= 7)
                                {
                                    re = re.Substring(0, 7);
                                }
                                if (re == "success")
                                {
                                    log.Agentupdatestatus = (int)AgentUpdateStatus.Suc;
                                    new Agent_asyncsendlogData().EditLog(log);

                                    return("成功");
                                }
                                else
                                {
                                    log.Agentupdatestatus = (int)AgentUpdateStatus.Fail;
                                    new Agent_asyncsendlogData().EditLog(log);

                                    return(re);
                                }
                            }
                            #endregion
                        }
                        else
                        {
                            return("分销商信息获取失败");
                        }
                    }
                    else
                    {
                        return("直销订单无需发送验证通知");
                    }
                }
                catch (Exception e)
                {
                    log.Id     = inslog;
                    log.Remark = e.Message.Replace("'", "''");//单引号替换为'',双引号不用处理
                    new Agent_asyncsendlogData().EditLog(log);

                    return(log.Remark);
                }
            }
        }
コード例 #12
0
        public static void AsyncSend(string updateurl, string pno, int confirmnum, string confirmtime, int agentcomid, int comidd1, int validateticketlogid, int aorderid)
        {
            Agent_asyncsendlog log = new Agent_asyncsendlog
            {
                Id                = 0,
                Pno               = pno,
                Num               = confirmnum,
                Sendtime          = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")),
                Confirmtime       = DateTime.Parse(confirmtime),
                Issendsuc         = 0,//0失败;1成功
                Agentupdatestatus = (int)AgentUpdateStatus.Fail,
                Agentcomid        = agentcomid,
                Comid             = comidd1,
                Remark            = "",
                Issecondsend      = 0,
                Platform_req_seq  = (1000000000 + agentcomid).ToString() + DateTime.Now.ToString("yyyyMMddhhssmm") + CommonFunc.CreateNum(6),//请求流水号
                Request_content   = "",
                Response_content  = "",
                b2b_etcket_logid  = validateticketlogid
            };
            int inslog = new Agent_asyncsendlogData().EditLog(log);

            log.Id = inslog;
            try
            {
                //获得分销商信息
                Agent_company agentinfo = new AgentCompanyData().GetAgentCompany(agentcomid);
                if (agentinfo != null)
                {
                    string agent_updateurl = agentinfo.Agent_updateurl;

                    #region 糯米分销
                    if (agentinfo.Agent_type == (int)AgentCompanyType.NuoMi)//糯米分销
                    {
                        string re = new GetUrlData().HttpPost(updateurl, "");

                        XmlDocument doc  = (XmlDocument)JsonConvert.DeserializeXmlNode("{\"root\":" + re + "}");
                        XmlElement  root = doc.DocumentElement;
                        string      info = root.SelectSingleNode("info").InnerText;

                        //只要返回了数据,则是发送成功
                        log.Id               = inslog;
                        log.Issendsuc        = 1;
                        log.Request_content  = updateurl;
                        log.Response_content = re;

                        if (info == "success")
                        {
                            string errCode = root.SelectSingleNode("res/errCode").InnerText;//分销商更新结果
                            if (errCode == "0")
                            {
                                log.Agentupdatestatus = (int)AgentUpdateStatus.Suc;
                                new Agent_asyncsendlogData().EditLog(log);
                            }
                            else
                            {
                                log.Agentupdatestatus = (int)AgentUpdateStatus.Fail;
                                new Agent_asyncsendlogData().EditLog(log);
                            }
                        }
                        else
                        {
                            log.Remark            = info;
                            log.Agentupdatestatus = (int)AgentUpdateStatus.Fail;
                            new Agent_asyncsendlogData().EditLog(log);
                        }
                    }
                    #endregion
                    #region 驴妈妈
                    else if (agentinfo.Agent_type == (int)AgentCompanyType.Lvmama)
                    {
                        /*根据订单号得到分销商订单请求记录(当前需要得到原订单请求流水号)*/


                        Lvmama_reqlog LvmamaOrderCrateSucLog = new lvmama_reqlogData().GetLvmama_OrderpayreqlogBySelforderid(aorderid, "0");


                        if (LvmamaOrderCrateSucLog == null)
                        {
                            log.Remark            = "根据订单号得到分销商订单请求记录失败";//单引号替换为'',双引号不用处理;
                            log.Agentupdatestatus = (int)AgentUpdateStatus.Fail;
                            new Agent_asyncsendlogData().EditLog(log);
                            return;
                        }

                        B2b_order morder = new B2bOrderData().GetOrderById(aorderid);
                        if (morder == null)
                        {
                            log.Remark            = "根据订单号查询订单失败.";//单引号替换为'',双引号不用处理;
                            log.Agentupdatestatus = (int)AgentUpdateStatus.Fail;
                            new Agent_asyncsendlogData().EditLog(log);
                            return;
                        }

                        string state = "1";
                        if (morder.U_num > confirmnum)
                        {
                            state = "2";
                        }
                        else if (confirmnum == morder.U_num)
                        {
                            state = "3";
                        }
                        else
                        {
                            state = "1";
                        }



                        var lvmamadata = new LVMAMA_Data(agentinfo.Lvmama_uid, agentinfo.Lvmama_password, agentinfo.Lvmama_Apikey);
                        //初始的时候没有sign值,等组合后下面生成加密文件
                        var hexiaojson = lvmamadata.usedticketscallback_json(LvmamaOrderCrateSucLog.mtorderid, agentinfo.Lvmama_uid, agentinfo.Lvmama_password, state, "", DateTime.Now.ToString("yyyyMMddHHmmss"), confirmnum.ToString());

                        #region 签名验证
                        string Md5Sign   = lvmamadata.usedticketscallbackmd5(hexiaojson);
                        string afterSign = lvmamadata.lumamasign(Md5Sign, agentinfo.Lvmama_Apikey);
                        #endregion
                        hexiaojson.sign = afterSign;

                        var asynnoticecall = lvmamadata.useConsumeNotify(hexiaojson, agentinfo.Id);
                        return;
                    }
                    #endregion
                    #region 一般分销
                    else //一般分销
                    {
                        #region 如果是美团分销,则向美团发送验证通知
                        Agent_company mtagentcompany = new AgentCompanyData().GetAgentCompany(agentinfo.Id);
                        if (mtagentcompany != null)
                        {
                            if (mtagentcompany.mt_partnerId != "")
                            {
                                B2b_order      ordermodel  = new B2bOrderData().GetOrderById(aorderid);
                                Meituan_reqlog meituanlogg = new Meituan_reqlogData().GetMt_OrderpayreqlogBySelforderid(ordermodel.Id, "200");
                                if (meituanlogg == null)
                                {
                                    LogHelper.RecordSelfLog("Erro", "meituan", "美团验证通知发送失败:查询美团支付成功订单失败");
                                }
                                else
                                {
                                    #region  订单电子票使用情况
                                    string all_pno     = ""; //全部电子码
                                    string keyong_pno  = ""; //可用电子码
                                    int    buy_num     = 0;
                                    int    keyong_num  = 0;
                                    int    consume_num = 0;
                                    int    tuipiao_num = ordermodel.Cancelnum;
                                    #endregion


                                    string meituancontent = "{" +
                                                            "\"partnerId\": " + mtagentcompany.mt_partnerId + "," +
                                                            "\"body\": " +
                                                            "{" +
                                                            "\"orderId\": " + meituanlogg.mtorderid + "," +
                                                            "\"partnerOrderId\": \"" + aorderid + "\"," +
                                                            "\"quantity\": " + ordermodel.U_num + "," +
                                                            "\"usedQuantity\": " + confirmnum + "," +
                                                            "\"refundedQuantity\": " + tuipiao_num + "," +
                                                            "\"voucherList\": " +
                                                            "[{" +
                                                            "\"voucher\":\"" + pno + "\"," +
                                                            "\"voucherPics\":\"\"," +
                                                            "\"voucherInvalidTime\":\"" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\"," +
                                                            "\"quantity\":" + confirmnum + "," +
                                                            "\"status\":1" + //4.10 凭证码状态:0	未使用;1	已使用;2	已退款;3	已废弃 对应的门票还未消费,但是此凭证码作废了
                                                            "}]" +
                                                            "}" +
                                                            "}";


                                    OrderConsumeNotice mrequest = (OrderConsumeNotice)JsonConvert.DeserializeObject(meituancontent, typeof(OrderConsumeNotice));

                                    ETS2.PM.Service.Meituan.Data.ReturnResult r = new MeiTuanInter(mtagentcompany.mt_partnerId, mtagentcompany.mt_secret, mtagentcompany.mt_client).ConsumeNotify(mrequest, mtagentcompany.Id);
                                }
                            }
                        }
                        #endregion


                        /*根据订单号得到分销商订单请求记录(当前需要得到原订单请求流水号)*/
                        List <Agent_requestlog> listagent_rlog = new Agent_requestlogData().GetAgent_requestlogByOrdernum(aorderid.ToString(), "add_order", "1");
                        if (listagent_rlog == null)
                        {
                            log.Remark            = "根据订单号得到分销商订单请求记录失败";//单引号替换为'',双引号不用处理;
                            log.Agentupdatestatus = (int)AgentUpdateStatus.Fail;
                            new Agent_asyncsendlogData().EditLog(log);
                            return;
                        }
                        if (listagent_rlog.Count == 0)
                        {
                            log.Remark            = "根据订单号得到分销商订单请求记录失败.";//单引号替换为'',双引号不用处理;
                            log.Agentupdatestatus = (int)AgentUpdateStatus.Fail;
                            new Agent_asyncsendlogData().EditLog(log);
                            return;
                        }


                        /*验证通知发送内容*/
                        string sbuilder = string.Format("<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                                                        "<business_trans>" +
                                                        "<request_type>sync_order</request_type>" +  //<!--验证同步-->
                                                        "<req_seq>{0}</req_seq>" +                   //<!--原订单请求流水号-->
                                                        "<platform_req_seq>{1}</platform_req_seq>" + //<!--平台请求流水号-->
                                                        "<order>" +                                  //<!--订单信息-->
                                                        "<code>{5}</code>" +                         //<!-- 验证电子码 y-->
                                                        "<order_num>{2}</order_num>" +               //<!-- 订单号 y-->
                                                        "<num>{3}</num>" +                           //<!-- 使用张数 -->
                                                        "<use_time>{4}</use_time>" +                 //<!--  使用时间  -->
                                                        "</order>" +
                                                        "</business_trans>", listagent_rlog[0].Req_seq, log.Platform_req_seq, aorderid, confirmnum, CommonFunc.ConvertDateTimeInt(DateTime.Parse(confirmtime)), pno);

                        #region 分销通知发送方式post
                        if (agentinfo.inter_sendmethod.ToLower() == "post")
                        {
                            string re = "";
                            if (agentcomid == 6490)
                            {
                                re = new GetUrlData().HttpPost(updateurl, sbuilder);

                                updateurl += "?xml=" + sbuilder;//只为记录
                            }
                            else
                            {
                                updateurl += "?xml=" + sbuilder;
                                re         = new GetUrlData().HttpPost(updateurl, "");
                            }


                            //只要返回了数据,则是发送成功
                            log.Id               = inslog;
                            log.Issendsuc        = 1;
                            log.Request_content  = updateurl;
                            log.Response_content = re;

                            log.Remark = re.Replace("'", "''");//单引号替换为'',双引号不用处理;
                            if (re.Length >= 7)
                            {
                                re = re.Substring(0, 7);
                            }
                            if (re == "success")
                            {
                                log.Agentupdatestatus = (int)AgentUpdateStatus.Suc;
                                new Agent_asyncsendlogData().EditLog(log);
                            }
                            else
                            {
                                log.Agentupdatestatus = (int)AgentUpdateStatus.Fail;
                                new Agent_asyncsendlogData().EditLog(log);
                            }
                        }
                        #endregion
                        #region 分销通知发送方式get
                        else
                        {
                            if (updateurl.IndexOf('?') > -1)
                            {
                                updateurl += "&xml=" + sbuilder;
                            }
                            else
                            {
                                updateurl += "?xml=" + sbuilder;
                            }

                            string re = new GetUrlData().HttpGet(updateurl);
                            //只要返回了数据,则是发送成功
                            log.Id               = inslog;
                            log.Issendsuc        = 1;
                            log.Request_content  = updateurl;
                            log.Response_content = re;

                            log.Remark = re.Replace("'", "''");//单引号替换为'',双引号不用处理;
                            if (re.Length >= 7)
                            {
                                re = re.Substring(0, 7);
                            }
                            if (re == "success")
                            {
                                log.Agentupdatestatus = (int)AgentUpdateStatus.Suc;
                                new Agent_asyncsendlogData().EditLog(log);
                            }
                            else
                            {
                                log.Agentupdatestatus = (int)AgentUpdateStatus.Fail;
                                new Agent_asyncsendlogData().EditLog(log);
                            }
                        }
                        #endregion
                    }
                    #endregion
                }
                else
                {
                    log.Remark            = "分销商获取失败";
                    log.Agentupdatestatus = (int)AgentUpdateStatus.Fail;
                    new Agent_asyncsendlogData().EditLog(log);
                }
            }
            catch (Exception e)
            {
                log.Id     = inslog;
                log.Remark = e.Message.Replace("'", "''");//单引号替换为'',双引号不用处理
                new Agent_asyncsendlogData().EditLog(log);
            }
        }
コード例 #13
0
        public static string SendWxMsg(int comid, string tousername, int type, string img, string txt, string mediaid, string fromusername)
        {
            //B2b_company_manageuser manageuser = UserHelper.CurrentUser();//客服信息(账户表B2b_company_manageuser)

            B2b_crm crm = new B2bCrmData().GetB2bCrmByWeiXin(tousername);

            if (crm == null)
            {
                return(JsonConvert.SerializeObject(new { type = 1, msg = "发送客服消息失败" }));
            }
            //else
            //{
            //    if (crm.Whetherwxfocus == false)
            //    {
            //        return JsonConvert.SerializeObject(new { type = 1, msg = "微信用户已经取消了关注" });
            //    }
            //}


            WeiXinBasic basicc = new WeiXinBasicData().GetWxBasicByComId(comid);

            if (basicc != null)
            {
                //获取凭证(首先判断数据库是否存在凭证以及是否过期,如过期,重新获取)
                WXAccessToken token = WeiXinManage.GetAccessToken(comid, basicc.AppId, basicc.AppSecret);
                //发送文本信息
                string err = "";//返回错误原因

                string createmenuurl   = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=" + token.ACCESS_TOKEN;
                string createmenutext1 = ""; //微信菜单内容
                if (type == 1)               //文本
                {
                    createmenutext1 = "{\"touser\":\"" + tousername + "\", \"msgtype\":\"text\",\"text\":{\"content\":\"" + txt + "\"}}";
                }
                if (type == 2)//语音
                {
                    if (mediaid != "")
                    {
                        createmenutext1 = "{\"touser\":\"" + tousername + "\", \"msgtype\":\"voice\",\"voice\":{\"media_id\":\"" + mediaid + "\"}}";
                    }
                    else
                    {
                        return(JsonConvert.SerializeObject(new { type = 1, msg = "语音mediaid不可为空" }));
                    }
                }
                if (type == 3)//图片
                {
                    if (mediaid != "")
                    {
                        createmenutext1 = "{\"touser\":\"" + tousername + "\", \"msgtype\":\"image\",\"image\":{\"media_id\":\"" + mediaid + "\"}}";
                    }
                    else
                    {
                        return(JsonConvert.SerializeObject(new { type = 1, msg = "图片mediaid不可为空" }));
                    }
                }

                if (err.Length > 0)
                {
                    return(JsonConvert.SerializeObject(new { type = 1, msg = err }));
                }
                else
                {
                    string createmenuutret = new GetUrlData().HttpPost(createmenuurl, createmenutext1);

                    XmlDocument createselfmenudoc = (XmlDocument)JsonConvert.DeserializeXmlNode("{\"root\":" + createmenuutret + "}");

                    XmlElement createselfmenurootElement = createselfmenudoc.DocumentElement;
                    string     createerrcode             = createselfmenurootElement.SelectSingleNode("errcode").InnerText;
                    if (createerrcode != "0")
                    {
                        //短信提示 ,查询会员账户,并检测是否今天发送过短信,如果发送过就不发送了,每天发送一次
                        var crmdata = new B2bCrmData();
                        var crminfo = crmdata.b2b_crmH5(tousername, comid);
                        if (crminfo != null)
                        {
                            if (crminfo.Phone != "")
                            {
                                var smstixing = new WxRequestXmlData().GetWxErr_sms_SendMsgList(comid, crminfo.Phone);
                                if (smstixing == 0)
                                {
                                    var smstixinginsert = new WxRequestXmlData().InsertWxErr_sms_SendMsgList(comid, crminfo.Phone);
                                    if (smstixinginsert != 0)
                                    {
                                        var    cominfo   = B2bCompanyData.GetCompany(comid);
                                        string comname   = "";
                                        string weixincom = "";
                                        if (cominfo != null)
                                        {
                                            comname   = cominfo.Com_name;
                                            weixincom = cominfo.B2bcompanyinfo.Weixinname;
                                        }

                                        ////发送短信
                                        //var smsmsg = "";
                                        //var smssendback = SendSmsHelper.SendSms(crminfo.Phone, "有一条给您发送微信消息接收失败 请关注" + comname + "微信账户: " + weixincom + " ,输入“我的消息”获取消息内容!", comid, out smsmsg);
                                    }
                                }
                            }
                        }

                        //发送客服信息,信息内容录入数据库
                        if (type == 1)//文本
                        {
                            RequestXML retRequestXML = new RequestXML();
                            retRequestXML.PostStr    = createmenutext1;
                            retRequestXML.ToUserName = tousername;
                            //retRequestXML.FromUserName = new WeiXinBasicData().GetWxBasicByComId(comid).Weixinno.ConvertTo<string>("");
                            retRequestXML.FromUserName = fromusername;
                            retRequestXML.CreateTime   = ConvertDateTimeInt(DateTime.Now).ToString();
                            retRequestXML.MsgType      = "text";
                            retRequestXML.Content      = txt;
                            retRequestXML.contentType  = false;
                            retRequestXML.Comid        = comid;
                            retRequestXML.Sendstate    = 0;//发送状态为 未发送


                            int inswxexchangemsg = new WxRequestXmlData().EditWxRequestXmlLog(retRequestXML);
                        }
                        //发送客服信息,信息内容录入数据库
                        if (type == 2)//语音
                        {
                            RequestXML retRequestXML = new RequestXML();
                            retRequestXML.PostStr    = createmenutext1;
                            retRequestXML.ToUserName = tousername;
                            //retRequestXML.FromUserName = new WeiXinBasicData().GetWxBasicByComId(comid).Weixinno.ConvertTo<string>("");
                            retRequestXML.FromUserName = fromusername;
                            retRequestXML.CreateTime   = ConvertDateTimeInt(DateTime.Now).ToString();
                            retRequestXML.MsgType      = "voice";
                            retRequestXML.Recognition  = txt;
                            retRequestXML.contentType  = false;
                            retRequestXML.Comid        = comid;
                            retRequestXML.MediaId      = mediaid;
                            retRequestXML.Sendstate    = 0;//发送状态为 未发送


                            int inswxexchangemsg = new WxRequestXmlData().EditWxRequestXmlLog(retRequestXML);
                        }

                        if (type == 3)//图片
                        {
                            RequestXML retRequestXML = new RequestXML();
                            retRequestXML.PostStr    = createmenutext1;
                            retRequestXML.ToUserName = tousername;
                            //retRequestXML.FromUserName = new WeiXinBasicData().GetWxBasicByComId(comid).Weixinno.ConvertTo<string>("");
                            retRequestXML.FromUserName = fromusername;
                            retRequestXML.CreateTime   = ConvertDateTimeInt(DateTime.Now).ToString();
                            retRequestXML.MsgType      = "image";
                            retRequestXML.PicUrl       = img;
                            retRequestXML.contentType  = false;
                            retRequestXML.Comid        = comid;
                            retRequestXML.Sendstate    = 0;//发送状态为 未发送

                            int inswxexchangemsg = new WxRequestXmlData().EditWxRequestXmlLog(retRequestXML);
                        }


                        return(JsonConvert.SerializeObject(new { type = 1, msg = "回复客服信息失败" + createerrcode }));
                    }
                    else
                    {
                        //发送客服信息,信息内容录入数据库
                        if (type == 1)//文本
                        {
                            RequestXML retRequestXML = new RequestXML();
                            retRequestXML.PostStr    = createmenutext1;
                            retRequestXML.ToUserName = tousername;
                            //retRequestXML.FromUserName = new WeiXinBasicData().GetWxBasicByComId(comid).Weixinno.ConvertTo<string>("");
                            retRequestXML.FromUserName = fromusername;
                            retRequestXML.CreateTime   = ConvertDateTimeInt(DateTime.Now).ToString();
                            retRequestXML.MsgType      = "text";
                            retRequestXML.Content      = txt;
                            retRequestXML.contentType  = false;
                            retRequestXML.Comid        = comid;
                            retRequestXML.Sendstate    = 1;//发送状态为 未发送
                            //retRequestXML.Manageuserid = manageuser.Id;
                            //retRequestXML.Manageusername = manageuser.Accounts;


                            int inswxexchangemsg = new WxRequestXmlData().EditWxRequestXmlLog(retRequestXML);
                        }
                        //发送客服信息,信息内容录入数据库
                        if (type == 2)//语音
                        {
                            RequestXML retRequestXML = new RequestXML();
                            retRequestXML.PostStr    = createmenutext1;
                            retRequestXML.ToUserName = tousername;
                            //retRequestXML.FromUserName = new WeiXinBasicData().GetWxBasicByComId(comid).Weixinno.ConvertTo<string>("");
                            retRequestXML.FromUserName = fromusername;
                            retRequestXML.CreateTime   = ConvertDateTimeInt(DateTime.Now).ToString();
                            retRequestXML.MsgType      = "voice";
                            retRequestXML.Recognition  = txt;
                            retRequestXML.contentType  = false;
                            retRequestXML.Comid        = comid;
                            retRequestXML.MediaId      = mediaid;
                            retRequestXML.Sendstate    = 1;//发送状态为 未发送
                            //retRequestXML.Manageuserid = manageuser.Id;
                            //retRequestXML.Manageusername = manageuser.Accounts;


                            int inswxexchangemsg = new WxRequestXmlData().EditWxRequestXmlLog(retRequestXML);
                        }

                        if (type == 3)//图片
                        {
                            RequestXML retRequestXML = new RequestXML();
                            retRequestXML.PostStr    = createmenutext1;
                            retRequestXML.ToUserName = tousername;
                            //retRequestXML.FromUserName = new WeiXinBasicData().GetWxBasicByComId(comid).Weixinno.ConvertTo<string>("");
                            retRequestXML.FromUserName = fromusername;
                            retRequestXML.CreateTime   = ConvertDateTimeInt(DateTime.Now).ToString();
                            retRequestXML.MsgType      = "image";
                            retRequestXML.PicUrl       = img;
                            retRequestXML.contentType  = false;
                            retRequestXML.Comid        = comid;
                            retRequestXML.Sendstate    = 1;//发送状态为 未发送
                            //retRequestXML.Manageuserid = manageuser.Id;
                            //retRequestXML.Manageusername = manageuser.Accounts;


                            int inswxexchangemsg = new WxRequestXmlData().EditWxRequestXmlLog(retRequestXML);
                        }
                        return(JsonConvert.SerializeObject(new { type = 100, msg = "回复客服信息成功" }));
                    }
                }
            }
            else
            {
                return(JsonConvert.SerializeObject(new { type = 1, msg = "" }));
            }
        }
コード例 #14
0
ファイル: HzinsInter.cs プロジェクト: radtek/etowncode
        //投保单批量查询
        public string Hzins_orderSearch(string orderidstr)
        {
            string transNo = orderidstr;//(以后需要修改为渠道商订单号)易流水号,每次请求不能相同

            //根据订单号列表得到投保单号列表
            List <Api_hzins_OrderApplyResp_OrderExt> list = new Api_hzins_OrderApplyResp_OrderExtData().GetinsureNumsbyorderids(orderidstr);

            if (list == null)
            {
                return("");
            }
            else
            {
                if (list.Count == 0)
                {
                    return("");
                }
            }
            //需要对insureNos处理一下,形如:["15080546794635","15080544341441"]
            string insureNos = "";

            foreach (Api_hzins_OrderApplyResp_OrderExt ext in list)
            {
                insureNos += "\"" + ext.insureNum + "\",";
            }
            if (insureNos != "")
            {
                insureNos = insureNos.Substring(0, insureNos.Length - 1);
            }

            //签名,预签名数据:密钥+渠道商身份标识+交易流水号
            string sign = EncryptionHelper.ToMD5(signkey + partnerId + transNo, "UTF-8");

            sign = sign.ToLower();

            string s = "{" +
                       "\"transNo\":\"" + transNo + "\"," +
                       "\"partnerId\":" + partnerId + "," +
                       "\"sign\":\"" + sign + "\"," +
                       "\"insureNums\":[" + insureNos + "]," +
                       "\"applicant\":null," +
                       "\"insurant\":null," +
                       "\"idCard\":null," +
                       "\"userId\":null," +
                       "\"startTime\":null," +
                       "\"endTime\":null," +
                       "\"pageNum\":1," +
                       "\"pageSize\":" + list.Count +
                       "}";

            string str = new GetUrlData().HttpPostJson("http://channel.hzins.com/api/orderSearch", s.Trim());

            //录入和慧择网交互日志
            ApiLog mapilog = new ApiLog
            {
                Id            = 0,
                request_type  = "orderSearch",
                Serviceid     = 2,
                Str           = s.Trim(),
                Subdate       = DateTime.Now,
                ReturnStr     = str,
                ReturnSubdate = DateTime.Now,
                Errmsg        = "",
            };
            int ins = new ApiLogData().EditLog(mapilog);

            //TxtHelper.WriteFile("D:\\site\\b2betown\\ETS2.WebApp\\BaoxianLog.txt", "发送信息:" + s.Trim() + "<br>" + "返回信息:" + str);
            return(str);
        }
コード例 #15
0
ファイル: HzinsInter.cs プロジェクト: radtek/etowncode
        private string signkey   = "146491#%##^11"; //签名秘钥,由慧择指定
        //承保
        public string Hzins_OrderApply(B2b_com_pro modelcompro, B2b_order modelb2border)
        {
            string transNo  = modelb2border.Id.ToString(); //(以后需要修改为渠道商订单号)交易流水号,每次请求不能相同
            string caseCode = modelcompro.Service_proid;   //(以后需要更改为正式产品)方案代码,每一款保险公司产品的方案代码都不相同,由慧择分配

            //签名,预签名数据:密钥+渠道商身份标识+交易流水号+方案代码
            string sign = EncryptionHelper.ToMD5(signkey + partnerId + transNo + caseCode, "UTF-8");

            sign = sign.ToLower();

            //根据订单号 得到慧择网 承保信息
            Api_hzins_OrderApplyReq_Application mapplication = new Api_hzins_OrderApplyReq_ApplicationData().GetOrderApplyReq_Application(modelb2border.Id);

            if (mapplication == null)
            {
                TxtHelper.WriteFile("D:\\site\\b2betown\\ETS2.WebApp\\BaoxianLog.txt", "fail1");
                return("fail");
            }
            Api_hzins_OrderApplyReq_applicantInfo mapplicationinfo = new Api_hzins_OrderApplyReq_applicantInfoData().GetOrderApplyReq_applicantInfo(modelb2border.Id);

            if (mapplicationinfo == null)
            {
                TxtHelper.WriteFile("D:\\site\\b2betown\\ETS2.WebApp\\BaoxianLog.txt", "fail2");
                return("fail");
            }
            List <Api_hzins_OrderApplyReq_insurantInfo> listinsurantInfo = new Api_hzins_OrderApplyReq_insurantInfoData().GetOrderApplyReq_insurantInfo(modelb2border.Id);

            if (listinsurantInfo == null)
            {
                TxtHelper.WriteFile("D:\\site\\b2betown\\ETS2.WebApp\\BaoxianLog.txt", "fail3");
                return("fail");
            }
            else
            {
                if (listinsurantInfo.Count == 0)
                {
                    TxtHelper.WriteFile("D:\\site\\b2betown\\ETS2.WebApp\\BaoxianLog.txt", "fail4");
                    return("fail");
                }
            }

            string s = "{" +
                       "\"partnerId\":" + partnerId + "," +
                       "\"transNo\":\"" + transNo + "\"," +
                       "\"caseCode\":\"" + caseCode + "\"," +
                       "\"sign\":\"" + sign + "\"," +
                       "\"applicationData\":{" +
                       "\"applicationDate\":\"" + mapplication.applicationDate + "\"," +
                       "\"startDate\":\"" + mapplication.startDate + "\"," +
                       "\"endDate\":\"" + mapplication.endDate + "\"" +
                       "}," +
                       "\"applicantInfo\":{" +
                       "\"cName\":\"" + mapplicationinfo.cName + "\"," +
                       "\"eName\":\"" + mapplicationinfo.eName + "\"," +
                       "\"cardType\":\"" + mapplicationinfo.cardType + "\"," +
                       "\"cardCode\":\"" + mapplicationinfo.cardCode + "\"," +
                       "\"sex\":" + mapplicationinfo.sex + "," +
                       "\"birthday\":\"" + mapplicationinfo.birthday + "\"," +
                       "\"mobile\":\"" + mapplicationinfo.mobile + "\"," +
                       "\"email\":\"" + mapplicationinfo.email + "\"," +
                       "\"jobInfo\":null" +
                       "}," +
                       "\"insurantInfos\":[";

            string insurantInfosstr = "";

            foreach (Api_hzins_OrderApplyReq_insurantInfo minsinfo in listinsurantInfo)
            {
                if (minsinfo != null)
                {
                    insurantInfosstr += "{" +
                                        "\"insurantId\":" + minsinfo.insurantId + "," +
                                        "\"cName\":\"" + minsinfo.cName + "\"," +
                                        "\"eName\":\"" + minsinfo.eName + "\"," +
                                        "\"sex\":" + minsinfo.sex + "," +
                                        "\"cardType\":" + minsinfo.cardType + "," +
                                        "\"cardCode\":\"" + minsinfo.cardCode + "\"," +
                                        "\"birthday\":\"" + minsinfo.birthday + "\"," +
                                        "\"relationId\":" + minsinfo.relationId + "," +
                                        "\"count\":" + minsinfo.count + "," +
                                        "\"singlePrice\":" + minsinfo.singlePrice + "," +
                                        "\"fltNo\":null," +
                                        "\"fltDate\":null," +
                                        "\"city\":\"null\"," +
                                        "\"tripPurposeId\":" + minsinfo.tripPurposeId + "," +
                                        "\"destination\":null," +
                                        "\"visaCity\":null," +
                                        "\"jobInfo\":null," +
                                        "\"mobile\":null" +
                                        "},";
                }
            }
            insurantInfosstr = insurantInfosstr.Substring(0, insurantInfosstr.Length - 1);

            s += insurantInfosstr + "]," +
                 "\"extendInfo\":{" +
                 "\"userId\":null," +
                 "\"email\":null," +
                 "\"userName\":null," +
                 "\"phone\":null" +
                 "}" +
                 "}";

            string str = new GetUrlData().HttpPostJson("http://channel.hzins.com/api/orderApply", s.Trim());

            //录入和慧择网交互日志
            ApiLog mapilog = new ApiLog
            {
                Id            = 0,
                request_type  = "orderApply",
                Serviceid     = 2,
                Str           = s.Trim(),
                Subdate       = DateTime.Now,
                ReturnStr     = str,
                ReturnSubdate = DateTime.Now,
                Errmsg        = "",
            };
            int ins = new ApiLogData().EditLog(mapilog);

            //TxtHelper.WriteFile("D:\\site\\b2betown\\ETS2.WebApp\\BaoxianLog.txt", "发送信息:" + s.Trim() + "<br>" + "返回信息:" + str);
            return(str);
        }