public bool CheckRegistInfo(string uid)
 {
     try
     {
         //检测注册信息是否完全
         return(_permissionProvider.UserInfo(uid) != null &&
                _permissionProvider.Services().GetOrgIdByUserId(uid).Any() &&
                _accountPayService.FindAccount(uid) != null &&
                _sportsService.HasUser(uid));
     }
     catch
     {
         return(false);
     }
 }
예제 #2
0
 // GET: Open/balance
 public ActionResult Balance()
 {
     return(Json(State.Success, _accountPayService.FindAccount(DataContext.UserId).Account));
 }
예제 #3
0
        // /Demo/TestPay
        public ActionResult TestPay()
        {
            const string DEMO_ACCOUNT_ONE = "plate-alipay";
            const string DEMO_ACCOUNT_TWO = "test-panda";
            const string DEMO_ORDER       = "10385-14093-8587258378306281019-10385-14093-8587258377194947454-8587258371564275398";
            const string DEMO_ALIPAY_ID   = "123456415645121346313548454";

            ////1.创建账户
            //var account = _accountPayService.CreateAccount(DataContext, AccountTypeEnum.Personal);
            ////2.改变账户类型
            //account.ChangeType(AccountTypeEnum.Orgnization);
            ////3.为账户充值
            //account.Charge(1000);
            ////4.账户消费
            //account.Expense(200);
            ////5.同步账户
            //_accountPayService.SyncAccount(account);
            //6.查找账户
            var payer   = _accountPayService.FindAccount(DEMO_ACCOUNT_ONE);
            var recever = _accountPayService.FindAccount(DEMO_ACCOUNT_TWO);
            ////7.删除账户
            //_accountPayService.DeleteAccount(DEMO_ACCOUNT_TWO);
            //8.账户支付记录
            var payerRecords = payer.Account.account_record;
            //1.创建支付订单
            var payOrder = _accountPayService.CreatePayOrder(payer, recever, 100, PayOrderTypeEnum.Nomal, PaymentTypeEnum.Jkb);

            //2.订单支付
            payOrder.Successful();
            //3.同步支付订单
            _accountPayService.SyncPayOrder(payOrder);
            //4.查找支付订单
            var findPayOrder = _accountPayService.FindPayOrder(DEMO_ORDER);

            ////5.删除支付订单
            //_accountPayService.DeletePayOrder(DEMO_ORDER);


            const string DEMO_CHARGE_ACCOUNT  = "test-panda";
            const string PLATE_ALIPAY_ACCOUNT = "plate-alipay";
            //1.创建支付订单
            var chargePayOrder = _accountPayService.CreatePayOrder(PLATE_ALIPAY_ACCOUNT, DEMO_CHARGE_ACCOUNT, 1000, PayOrderTypeEnum.AliPay, PaymentTypeEnum.Rmb);

            _accountPayService.SyncPayOrder(chargePayOrder);
            //2.订单支付激活
            chargePayOrder.Pending(DEMO_ALIPAY_ID);
            _accountPayService.SyncPayOrder(chargePayOrder);
            //3.订单验证并付款
            if (chargePayOrder.IsValid(DEMO_ALIPAY_ID))
            {
                chargePayOrder.Successful();
            }
            else
            {
                //忽略
            }
            _accountPayService.SyncPayOrder(chargePayOrder);
            //4.订单验证并结束
            if (chargePayOrder.IsValid(DEMO_ALIPAY_ID))
            {
                chargePayOrder.Finished();
            }
            else
            {
                //忽略
            }
            _accountPayService.SyncPayOrder(chargePayOrder);
            //5.同步支付订单
            // _accountPayService.SyncPayOrder(chargePayOrder);

            return(Alert("测试成功!"));
        }
예제 #4
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 }));
        }