示例#1
0
 [MethodImpl(MethodImplOptions.Synchronized)] //方法的同步属性
 static public wxOrderTmpMgr instance()
 {
     if (null == uniCounter)
     {
         uniCounter = new wxOrderTmpMgr();
     }
     return(uniCounter);
 }
示例#2
0
        /// <summary>
        /// 处理回调的页面
        /// </summary>
        private void ProcessNotify()
        {
            int    wid        = 0;
            string payTmpType = "【微支付】";
            string funName    = payTmpType + " notify_url ProcessNotify ";

            WXLogs.AddLog(payTmpType, funName, "从微支付返回到notify_url.aspx页面", 1);

            byte[] byts = new byte[Request.InputStream.Length];
            Request.InputStream.Read(byts, 0, byts.Length);
            string req = System.Text.Encoding.Default.GetString(byts);

            req = Server.UrlDecode(req);
            WXLogs.AddLog(payTmpType, funName, "req:" + req, 1);

            //返回的状态码
            string return_code = ReadXmlValue(req, "xml/return_code");

            WXLogs.AddLog(payTmpType, "notify_url ProcessNotify", "返回的状态码return_code:" + return_code, 1);

            if (return_code.Trim().ToLower() == "fail")
            {
                string return_msg = ReadXmlValue(req, "xml/return_msg");
                WXLogs.AddLog(payTmpType, funName, "订单处理错误:" + return_msg, 0);
                WriteContent("fail", "订单处理错误:" + return_msg);
                return;
            }


            string attach = ReadXmlValue(req, "xml/attach");

            string[] attachArr = attach.Split('|');
            wid = MyCommFun.Str2Int(attachArr[0]);
            int otid = MyCommFun.Str2Int(attachArr[1]);

            BLL.wx_payment_wxpay   payBll      = new BLL.wx_payment_wxpay();
            Model.wx_payment_wxpay paymentInfo = payBll.GetModelByWid(wid);
            WXLogs.AddLog(wid, payTmpType, funName, "取到wid=" + wid, 1);



            string appId = ReadXmlValue(req, "xml/appid");             //公众账号id
            string mchId = ReadXmlValue(req, "xml/mch_id");            //商户号

            string result_code = ReadXmlValue(req, "xml/result_code"); //业务结果

            if (result_code.Trim().ToLower() == "fail")
            {
                //支付失败
                string err_code     = ReadXmlValue(req, "xml/err_code");
                string err_code_des = ReadXmlValue(req, "xml/err_code_des");
                WXLogs.AddLog(wid, payTmpType, funName, "业务结果处理错误err_code:" + err_code + "[err_code_des]:" + err_code_des, 0);
                WriteContent("fail", "业务结果处理错误err_code:" + err_code + "[err_code_des]:" + err_code_des);
                return;
            }
            //支付成功
            string openid = ReadXmlValue(req, "xml/openid");
            //金额,以分为单位
            string total_fee = ReadXmlValue(req, "xml/total_fee");

            string out_trade_no = ReadXmlValue(req, "xml/out_trade_no");

            string transaction_id = ReadXmlValue(req, "xml/transaction_id");

            WXLogs.AddLog(wid, payTmpType, "notify_url ProcessNotify", "支付成功了:openid=" + openid + " out_trade_no=" + out_trade_no + " transaction_id=" + transaction_id + " total_fee(分)=" + total_fee + " result_code=" + result_code + " orderid=" + otid + " wid=" + wid, 1);
            //------------------------------
            //处理业务开始
            //处理数据库逻辑
            //注意交易单不要重复处理
            //注意判断返回金额
            //------------------------------
            wxOrderTmpMgr Totbll = wxOrderTmpMgr.instance();
            string        ret    = Totbll.ProcessPaySuccess_wx("notify_url", out_trade_no, transaction_id, result_code, MyCommFun.Str2Int(total_fee), otid, wid);

            ret = ret == "" ? "处理数据同步发送成功" : ret;

            WXLogs.AddLog(wid, payTmpType, funName, ret, 1);

            //------------------------------
            //处理业务完毕
            //------------------------------
            //回复服务器处理成功
            WriteContent("success");
        }