Example #1
0
        public string GetShowCount()
        {
            string Timestamp = Request["Timestamp"].ToString().Trim();

            if (Timestamp == null || Timestamp.Equals(""))
            {
                Timestamp = "0";
            }
            string content    = string.Empty;
            VipBLL vipService = new VipBLL(Default.GetLoggingSession());
            var    respData   = new RespData();

            try
            {
                respData.Code        = "200";
                respData.Description = "操作成功";
                respData.count       = vipService.GetShowCount(Convert.ToInt64(Timestamp), out respData.NewTimestamp);
            }
            catch (Exception ex) {
                respData.Code        = "201";
                respData.Description = "操作失败";
                respData.Exception   = ex.ToString();
            }
            content = respData.ToJSON();
            return(content);
        }
        /// <summary>
        /// 支付宝分润公共方法
        /// </summary>
        /// <param name="out_bill_no">该次分润的分润号,必填,保证其唯一性</param>
        /// <param name="out_trade_no">商户订单号,商户网站已经付款完成的商户网站订单号,out_trade_no、trade_no须至少填写一项</param>
        /// <param name="trade_no">支付宝交易号,已经付款完成的支付宝交易号,与商户网站订单号out_trade_no相对应</param>
        /// <param name="royalty_parameters">提成信息集,必填,格式设置参见接口技术文档</param>
        /// <returns>返回分润结果JSON字符串</returns>
        public string SubmitDistribute(string out_bill_no, string out_trade_no, string trade_no, string royalty_parameters)
        {
            BaseService.WriteLog("分润公共方法SubmitDistribute()");

            BaseService.WriteLog("把请求参数打包成数组");
            //把请求参数打包成数组
            SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>();

            sParaTemp.Add("partner", Config.Partner);
            sParaTemp.Add("_input_charset", Config.Input_charset.ToLower());
            sParaTemp.Add("service", "distribute_royalty");
            sParaTemp.Add("out_bill_no", out_bill_no);
            sParaTemp.Add("out_trade_no", out_trade_no);
            sParaTemp.Add("trade_no", trade_no);
            sParaTemp.Add("royalty_type", "10");
            sParaTemp.Add("royalty_parameters", royalty_parameters);

            BaseService.WriteLog("建立请求,以模拟远程HTTP的POST请求方式构造并获取支付宝的处理结果");
            //建立请求
            string sHtmlText = Submit.BuildRequest(sParaTemp);

            RespData    respData = new RespData();
            XmlDocument xmlDoc   = new XmlDocument();

            try
            {
                xmlDoc.LoadXml(sHtmlText);

                string is_success = xmlDoc.SelectSingleNode("/alipay/is_success").InnerText;
                if (!is_success.Equals("T"))
                {
                    string error = xmlDoc.SelectSingleNode("/alipay/error").InnerText;
                    respData.Code        = "F";
                    respData.Description = "操作失败";
                    respData.Exception   = error;
                }
            }
            catch (Exception exp)
            {
                respData.Code        = "F";
                respData.Description = "操作失败";
                respData.Exception   = exp.ToString();
            }

            return(respData.ToJSON());
        }
Example #3
0
        /// <summary>
        /// 主动给用户推送订单消息
        /// </summary>
        /// <returns></returns>
        public string SetOrderPush()
        {
            var respData = new RespData();

            if (string.IsNullOrEmpty(Request["WeiXinId"]) ||
                string.IsNullOrEmpty(Request["OpenId"]) ||
                string.IsNullOrEmpty(Request["OrdeNo"]))
            {
                respData.Code        = "103";
                respData.Description = "数据库操作错误";
                respData.Exception   = "请求的数据不能为空";
                return(respData.ToJSON());
            }

            string content = string.Empty;

            try
            {
                string vipID              = string.Empty;
                string vipName            = string.Empty;
                var    loggingSessionInfo = Default.GetLjLoggingSession();
                //根据客户标识获取连接字符串  qianzhi  2013-07-30
                if (!string.IsNullOrEmpty(Request["customerId"]))
                {
                    loggingSessionInfo = Default.GetBSLoggingSession(Request["customerId"].Trim(), "");
                }

                #region 获取VIP信息

                VipBLL vipService = new VipBLL(loggingSessionInfo);
                var    vipList    = vipService.QueryByEntity(new VipEntity()
                {
                    WeiXinUserId = Request["OpenId"],
                    WeiXin       = Request["WeiXinId"]
                }, null);

                if (vipList == null || vipList.Length == 0)
                {
                    respData.Code        = "103";
                    respData.Description = "未查找到匹配的VIP信息";
                    return(respData.ToJSON());
                }
                else
                {
                    vipID   = vipList.FirstOrDefault().VIPID;
                    vipName = vipList.FirstOrDefault().VipName;
                }

                #endregion

                // 推送消息
                string msgUrl  = ConfigurationManager.AppSettings["push_weixin_msg_url"].Trim();
                string msgText = string.Format("亲爱的会员{1},您单号为{0}的购买请求我们已经收到,请您到指定渠道下交纳钱款。谢谢再次惠顾!", Request["OrdeNo"], vipName);
                string msgData = "<xml><OpenID><![CDATA[" + Request["OpenId"] + "]]></OpenID><Content><![CDATA[" + msgText + "]]></Content></xml>";

                var msgResult = Common.Utils.GetRemoteData(msgUrl, "POST", msgData);
                #region 发送日志
                MarketSendLogBLL    logServer = new MarketSendLogBLL(loggingSessionInfo);
                MarketSendLogEntity logInfo   = new MarketSendLogEntity();
                logInfo.LogId           = BaseService.NewGuidPub();
                logInfo.IsSuccess       = 1;
                logInfo.MarketEventId   = Request["OrdeNo"];
                logInfo.SendTypeId      = "2";
                logInfo.TemplateContent = msgData;
                logInfo.VipId           = vipID;
                logInfo.WeiXinUserId    = Request["OpenId"];
                logInfo.CreateTime      = System.DateTime.Now;
                logServer.Create(logInfo);
                #endregion
                Loggers.Debug(new DebugLogInfo()
                {
                    Message = string.Format("PushMsgResult:{0}", msgResult)
                });
            }
            catch (Exception ex)
            {
                respData.Code        = "201";
                respData.Description = "操作失败";
                respData.Exception   = ex.ToString();
            }
            content = respData.ToJSON();
            return(content);
        }
        private void SubmitDistribute()
        {
            BaseService.WriteLog("多级分润接口-----------------------AlipayWapTrade2/DistributeRoyalty.aspx");

            ////////////////////////////////////////////请求参数////////////////////////////////////////////

            string out_bill_no        = string.Empty;
            string out_trade_no       = string.Empty;
            string trade_no           = string.Empty;
            string royalty_parameters = string.Empty;

            //该次分润的分润号
            //必填,保证其唯一性
            if (!string.IsNullOrEmpty(Request["out_bill_no"]))
            {
                out_bill_no = Request["out_bill_no"].Trim();
                BaseService.WriteLog("out_bill_no:  " + Request["out_bill_no"]);
            }
            else
            {
                BaseService.WriteLog("请求参数out_bill_no is null!!!!!");
            }

            //商户订单号
            //商户网站已经付款完成的商户网站订单号,out_trade_no、trade_no须至少填写一项
            if (!string.IsNullOrEmpty(Request["out_trade_no"]))
            {
                out_trade_no = Request["out_trade_no"].Trim();
                BaseService.WriteLog("out_trade_no:  " + Request["out_trade_no"]);
            }
            else
            {
                BaseService.WriteLog("请求参数out_trade_no is null!!!!!");
            }

            //支付宝交易号
            //已经付款完成的支付宝交易号,与商户网站订单号out_trade_no相对应
            if (!string.IsNullOrEmpty(Request["trade_no"]))
            {
                trade_no = Request["trade_no"].Trim();
                BaseService.WriteLog("trade_no:  " + Request["trade_no"]);
            }
            else
            {
                BaseService.WriteLog("请求参数trade_no is null!!!!!");
            }

            //提成信息集
            //必填,格式设置参见接口技术文档
            if (!string.IsNullOrEmpty(Request["royalty_parameters"]))
            {
                royalty_parameters = Request["royalty_parameters"].Trim();
                BaseService.WriteLog("royalty_parameters:  " + Request["royalty_parameters"]);
            }
            else
            {
                BaseService.WriteLog("请求参数royalty_parameters is null!!!!!");
            }

            ////////////////////////////////////////////////////////////////////////////////////////////////

            BaseService.WriteLog("把请求参数打包成数组");
            //把请求参数打包成数组
            SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>();

            sParaTemp.Add("partner", Config.Partner);
            sParaTemp.Add("_input_charset", Config.Input_charset.ToLower());
            sParaTemp.Add("service", "distribute_royalty");
            sParaTemp.Add("out_bill_no", out_bill_no);
            sParaTemp.Add("out_trade_no", out_trade_no);
            sParaTemp.Add("trade_no", trade_no);
            sParaTemp.Add("royalty_type", "10");
            sParaTemp.Add("royalty_parameters", royalty_parameters);

            BaseService.WriteLog("建立请求,以模拟远程HTTP的POST请求方式构造并获取支付宝的处理结果");
            //建立请求
            string sHtmlText = Submit.BuildRequest(sParaTemp);

            RespData    respData = new RespData();
            XmlDocument xmlDoc   = new XmlDocument();

            try
            {
                xmlDoc.LoadXml(sHtmlText);

                string is_success = xmlDoc.SelectSingleNode("/alipay/is_success").InnerText;
                if (!is_success.Equals("T"))
                {
                    string error = xmlDoc.SelectSingleNode("/alipay/error").InnerText;
                    respData.Code        = "F";
                    respData.Description = "操作失败";
                    respData.Exception   = error;
                }
            }
            catch (Exception exp)
            {
                respData.Code        = "F";
                respData.Description = "操作失败";
                respData.Exception   = exp.ToString();
            }

            Response.Write(respData.ToJSON());
        }