// GET: /WeChat/FourthPay/ProductPage
        public ActionResult Charge(string openid = "test", int total_fee = 1)
        {
            //1.创建支付订单
            var chargePayOrder = _accountPayService.CreatePayOrder(Qx.Account.Configs.Setting.PLATE_WECHAT_ACCOUNT, openid, total_fee, PayOrderTypeEnum.VipCard, PaymentTypeEnum.Jkb
                                                                   );
            var poid = chargePayOrder.PayOrder.PO_ID;

            //2.同步支付订单
            _accountPayService.SyncPayOrder(chargePayOrder);
            //3.发起请求
            var p = new PayRequest()
            {
                instId      = "999999",
                mercOrderId = "NO12345678900001",
                mercId      = "OLP999999000001",
                txnType     = "W",
                txnDate     = DateTime.Now.FormatDate(true),
                txnTime     = DateTime.Now.FormatTime(false, true),
                ccy         = "CNY",
                txnAmt      = total_fee,
                notifyUrl   = RETURN_NOTIFY,
                productName = "测试productName",
                productDesc = "测试productDesc"
            };
            var response = Post <PayResponse>($"/posm/qrpayreq.tran?olpdat={p.Serialize()}");

            if (!response.Successful)
            {//请求失败时删除本地订单
                _accountPayService.DeletePayOrder(poid);
            }
            return(Content(response.Successful ? "下单成功,订单号为:" + poid : "下单失败:" + response.rspMsg + response.rspData));
        }
        //   /WeChat/WeChatPay/JsApiPayPage?uid=123&total_fee=0.01return_url=oksMlwPF5Y1KQvoi8AklF-lUwnYQ&
        public ActionResult JsApiPayPage(double total_fee, string return_url)
        {
            string openid = DataContext.UserId;

            if (!openid.HasValue() || !return_url.HasValue())
            {
                return(Content("参数错误"));
            }
            var money        = (int)(total_fee * 100);
            var wxJsApiParam = "";

            //检测是否给当前页面传递了相关参数
            if (string.IsNullOrEmpty(openid))
            {
                return(Content("<span style='color:#FF0000;font-size:20px'>" + "页面传参出错,请返回重试" + "</span>"));;
            }

            //若传递了相关参数,则调统一下单接口,获得后续相关接口的入口参数
            var jsApiPay = new JsApiPay <Qx.Account.Configs.Setting.WxPayConfig.Sports>(HttpContext);

            jsApiPay.openid    = openid;
            jsApiPay.total_fee = money;
            var poid = "";

            //JSAPI支付预处理
            try
            {
                //1.创建支付订单
                var chargePayOrder = _accountPayService.CreatePayOrder(Qx.Account.Configs.Setting.PLATE_WECHAT_ACCOUNT,
                                                                       openid,
                                                                       total_fee,
                                                                       PayOrderTypeEnum.WeChatPay,
                                                                       PaymentTypeEnum.Rmb);
                poid = chargePayOrder.PayOrder.PO_ID;
                var trade_no = chargePayOrder.PayOrder.PO_ID;
                //2.同步支付订单
                _accountPayService.SyncPayOrder(chargePayOrder);

                //3.通知微信服务器
                var unifiedOrderResult = jsApiPay.GetUnifiedOrderResult(trade_no, "充值" + (total_fee) + "元");
                wxJsApiParam = jsApiPay.GetJsApiParameters();//获取H5调起JS API参数
                if (!wxJsApiParam.HasValue())
                {
                    throw new Exception("下单失败");
                }

                //在页面上显示订单信息
                return(View("JsApiPayPage", JsApiPayPage_M.Init(wxJsApiParam,
                                                                "<span style='color:#00CD00;font-size:20px'>充值" + total_fee + "元</span><br/><span style='color:#00CD00;font-size:20px'>" + "</span>",
                                                                //"<span style='color:#00CD00;font-size:20px'>订单详情:</span><br/><span style='color:#00CD00;font-size:20px'>" + unifiedOrderResult.ToPrintStr() + "</span>",
                                                                total_fee + "", poid, DataContext.UserId, return_url
                                                                )));
            }
            catch (Exception ex)
            {
                return(View("JsApiPayPage", JsApiPayPage_M.Init(wxJsApiParam,
                                                                "<span style='color:#FF0000;font-size:20px'>" + "下单失败,请返回重试" + "<hr/>" + ex.Data + "<hr/>" + ex.InnerException + "<hr/>" + ex.Message + "<hr/>" + ex.StackTrace + "</span>", "", poid, DataContext.UserId, return_url)));
            }
        }
        public ActionResult Charge(Web.Areas.Alipay.Models.Orderetail model)
        {
            model.WIDtotal_fee = double.Parse(F("WIDtotal_fee"));
            if (model.WIDtotal_fee < 0.01)
            {
                return(Alert("充值金额必须>=0.01", -1));
            }

            model.WIDbody    = "充值" + model.WIDtotal_fee * 100 + "健康币";
            model.WIDsubject = model.WIDbody;
            //=============================存储订单


            //1.创建支付订单
            var chargePayOrder = _accountPayService.CreatePayOrder(PLATE_ALIPAY_ACCOUNT,
                                                                   DEMO_CHARGE_ACCOUNT,
                                                                   model.WIDtotal_fee,
                                                                   PayOrderTypeEnum.AliPay,
                                                                   PaymentTypeEnum.Rmb);

            model.WIDout_trade_no = chargePayOrder.PayOrder.PO_ID;
            //2.同步支付订单
            _accountPayService.SyncPayOrder(chargePayOrder);



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

            ////商户订单号,商户网站订单系统中唯一订单号,必填
            //string out_trade_no = "pid1234565489";

            ////订单名称,必填
            //string subject = "测试充值";

            ////付款金额,必填
            //string total_fee = "0.01";

            ////商品描述,可空
            //string body = "我是商品描述";



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

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

            sParaTemp.Add("service", Config.service);
            sParaTemp.Add("partner", Config.partner);
            sParaTemp.Add("seller_id", Config.seller_id);
            sParaTemp.Add("_input_charset", Config.input_charset.ToLower());
            sParaTemp.Add("payment_type", Config.payment_type);
            sParaTemp.Add("notify_url", Config.notify_url);
            sParaTemp.Add("return_url", Config.return_url);
            sParaTemp.Add("anti_phishing_key", Config.anti_phishing_key);
            sParaTemp.Add("exter_invoke_ip", Config.exter_invoke_ip);
            sParaTemp.Add("out_trade_no", model.WIDout_trade_no);
            sParaTemp.Add("subject", model.WIDsubject);
            sParaTemp.Add("total_fee", model.WIDtotal_fee.ToString());
            sParaTemp.Add("body", model.WIDbody);
            //其他业务参数根据在线开发文档,添加参数.文档地址:https://doc.open.alipay.com/doc2/detail.htm?spm=a219a.7629140.0.0.O9yorI&treeId=62&articleId=103740&docType=1
            //如sParaTemp.Add("参数名","参数值");

            //建立请求
            string sHtmlText = Submit.BuildRequest(sParaTemp, "get", "确认");



            return(Content(sHtmlText));
        }
        // /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("测试成功!"));
        }