public ActionResult Send_Charge_Ok_Msg()
        {
            var touser = "******";
            var url    = "http://wx.52xyj.cn/WeChat/BookTiketWeb/MyWallet";

            return(Content(_wechatServices.Send_Charge_Ok_Msg(touser, url, DateTime.Now.ToStr(), "100", "50").ToString()));
        }
示例#2
0
        // GET: /WeChat/WeChatPay/ResultNotifyPage/
        public ActionResult ResultNotifyPage()
        {
            var redirectAction = "";

            var res            = new WxPayData();
            var appid          = RequstParam["appid"];
            var attach         = RequstParam["attach"];
            var bank_type      = RequstParam["bank_type"];
            var cash_fee       = RequstParam["cash_fee"];
            var fee_type       = RequstParam["fee_type"];
            var is_subscribe   = RequstParam["is_subscribe"];
            var mch_id         = RequstParam["mch_id"];
            var nonce_str      = RequstParam["nonce_str"];
            var openid         = RequstParam["openid"];
            var out_trade_no   = RequstParam["out_trade_no"];
            var result_code    = RequstParam["result_code"];
            var return_code    = RequstParam["return_code"];
            var sign           = RequstParam["sign"];
            var time_end       = RequstParam["time_end"];
            var total_fee      = RequstParam["total_fee"];
            var transaction_id = RequstParam["transaction_id"];

            //检查支付结果中transaction_id是否存在
            if (transaction_id.HasValue() && out_trade_no.HasValue())
            {
                //1.开始处理
                var chargePayOrder = _accountPayService.FindPayOrder(out_trade_no);
                chargePayOrder.Pending(transaction_id);

                if (chargePayOrder != null)
                {
                    if (result_code.ToUpper().Contains("SUCCESS") &&
                        return_code.ToUpper().Contains("SUCCESS") &&
                        chargePayOrder.IsValid(transaction_id))
                    {
                        //防止重复处理
                        if (!chargePayOrder.IsFinished)
                        {
                            chargePayOrder.Successful();
                            chargePayOrder.Finished();
                            //2.同步支付订单
                            _accountPayService.SyncPayOrder(chargePayOrder);

                            //3.发送成功通知
                            var url = "http://wx.52xyj.cn/WeChat/BookTiketWeb/MyWallet";
                            var acc = _accountPayService.FindAccount(openid);
                            _wechatServices.Send_Charge_Ok_Msg(openid, url,
                                                               acc.Account.LastUpdateTime.ToStr(),
                                                               (int.Parse(total_fee) / 100.0) + "元",
                                                               (acc.Account.Balance / 100.0) + "元");
                        }
                        res.SetValue("return_code", "SUCCESS");
                        res.SetValue("return_msg", "OK");
                        Log.Info(this.GetType().ToString(), "order query success : " + res.ToXml());
                        redirectAction = "ChargeOK";
                    }
                    else
                    {
                        chargePayOrder.Failed();
                        res.SetValue("return_code", "FAIL");
                        res.SetValue("return_msg", "订单查询失败");
                        Log.Error(this.GetType().ToString(), "Order query failure : " + res.ToXml());
                        redirectAction = "ChargeFailed";
                    }
                }
            }
            else
            {
                //若transaction_id不存在,则立即返回结果给微信支付后台
                res.SetValue("return_code", "FAIL");
                res.SetValue("return_msg", "支付结果中微信订单号不存在");
                Log.Error(this.GetType().ToString(), "The Pay result is error : " + res.ToXml());
                redirectAction = "ChargeFailed";
            }
            Response.Write(res.ToXml());
            Response.End();
            ResultNotify resultNotify = new ResultNotify(HttpContext);

            resultNotify.ProcessNotify();
            return(RedirectToAction(redirectAction, "BookTiketWeb", new { transaction_id = transaction_id }));
        }