예제 #1
0
        private bool OrderPay(string user_id, string financial_id, string order_num, decimal changes_amount, string order_payid, string operator_way)
        {
            bool isSuccess = false;

            try
            {
                UserInfoManager uim = new UserInfoManager();
                if (operator_way == UserFinancialOperatorWay.WeixinPay.GetHashCode().ToString())
                {
                    WxOrderQuery     orderQuery  = new WxOrderQuery();
                    OrderQueryResult queryResult = orderQuery.Query(order_payid);
                    if (queryResult.trade_state == TradeStateEnum.SUCCESS)
                    {
                        Hashtable hashuf = new Hashtable();
                        hashuf["ID"]       = financial_id;
                        hashuf["OrderNum"] = order_num;
                        hashuf["UserID"]   = user_id;
                        hashuf["State"]    = UserFinancialState.Effect.GetHashCode();
                        hashuf["TradeNo"]  = queryResult.transaction_id;
                        hashuf["TotalFee"] = queryResult.total_fee;
                        hashuf["PayWay"]   = UserFinancialOperatorWay.WeixinPay;
                        decimal changesAmount = changes_amount;
                        if (Math.Abs(changesAmount) == queryResult.total_fee)
                        {
                            isSuccess = uim.OrderPayCallback(hashuf);
                        }
                    }
                }
                else if (operator_way == UserFinancialOperatorWay.Alipay.GetHashCode().ToString())
                {
                    AlipayOrderQuery orderQuery  = new AlipayOrderQuery();
                    OrderQueryResult queryResult = orderQuery.Query(order_payid);
                    if (queryResult.trade_state == TradeStateEnum.SUCCESS)
                    {
                        Hashtable hashuf = new Hashtable();
                        hashuf["ID"]       = financial_id;
                        hashuf["OrderNum"] = order_num;
                        hashuf["UserID"]   = user_id;
                        hashuf["State"]    = UserFinancialState.Effect.GetHashCode();
                        hashuf["TradeNo"]  = queryResult.transaction_id;
                        hashuf["TotalFee"] = queryResult.total_fee;
                        hashuf["PayWay"]   = UserFinancialOperatorWay.Alipay;
                        decimal changesAmount = changes_amount;
                        if (Math.Abs(changesAmount) == queryResult.total_fee)
                        {
                            isSuccess = uim.OrderPayCallback(hashuf);
                        }
                    }
                }
                return(isSuccess);
            }
            catch
            {
                return(false);
            }
        }
예제 #2
0
        public string Execute(Hashtable params_ht)
        {
            Hashtable res = params_ht;

            if (res["UID"] == null || res["UID"].ToString().Trim().Length <= 0 ||
                res["OrderPayID"] == null || res["OrderPayID"].ToString().Trim().Length <= 0)
            {
                return(SiteHelper.GetJsonFromHashTable(null, "faild", "参数不完整"));
            }
            else
            {
                uid         = res["UID"].ToString().Trim();
                order_payid = res["OrderPayID"].ToString().Trim();

                AlipayOrderQuery orderQuery = new AlipayOrderQuery();
                //OrderQueryResult queryResult = orderQuery.Query(order_payid);
                OrderQueryResult queryResult = orderQuery.QueryByTradeNO(order_payid);
                string           result      = JsonConvert.SerializeObject(queryResult);
                return(result);
            }
        }
예제 #3
0
        public string Execute(Hashtable params_ht)
        {
            Hashtable res = params_ht;

            if (res["UID"] == null || res["UID"].ToString().Trim().Length <= 0 ||
                res["PayWay"] == null || res["PayWay"].ToString().Trim().Length <= 0 ||
                res["Money"] == null || res["Money"].ToString().Trim().Length <= 0)
            {
                return(SiteHelper.GetJsonFromHashTable(null, "faild", "参数不完整"));
            }
            else
            {
                uid = res["UID"].ToString().Trim();
                int.TryParse(res["PayWay"].ToString().Trim(), out payway);
                cacheKey += uid;
                decimal.TryParse(res["Money"].ToString().Trim(), out money);

                //在充值时进行身份验证
                UserFinancialManager ufm  = new UserFinancialManager();
                UserInfoManager      uim  = new UserInfoManager();
                Hashtable            user = uim.GetUserInfoByUserID(uid);
                if (user == null || user.Keys.Count <= 0)
                {
                    return(SiteHelper.GetJsonFromHashTable(null, "faild", "您不是有效会员"));
                }
                else
                {
                    //验证用户是否经过身份认证
                    if ("4".CompareTo(user["REALNAMECERTIFICATION"].ToString()) != 0)
                    {
                        return(SiteHelper.GetJsonFromHashTable(null, "faild", "您当前未完成实名认证,请完成实名认证后重试"));
                    }
                    //验证用户状态是否有效
                    if ("0".CompareTo(user["USERSTATE"].ToString()) == 0)
                    {
                        return(SiteHelper.GetJsonFromHashTable(null, "faild", "您当前已被禁用无法充值"));
                    }
                }
                //----------------------------------------------------------------------------------

                #region 检测前一笔未确认支付交易是否成功,成功则调用支付成功业务逻辑

                Hashtable financial_ht = ufm.GetLatestUserFinancialInfo(uid, UserFinancialState.NewSubmit, UserFinancialChangesType.Recharge);
                if (financial_ht != null && financial_ht.Keys.Count > 0)
                {
                    string order_payid  = SiteHelper.GetHashTableValueByKey(financial_ht, "OrderPayID");
                    string operator_way = SiteHelper.GetHashTableValueByKey(financial_ht, "OperatorWay");
                    if (operator_way == UserFinancialOperatorWay.WeixinPay.GetHashCode().ToString())
                    {
                        WxOrderQuery     orderQuery  = new WxOrderQuery();
                        OrderQueryResult queryResult = orderQuery.Query(order_payid);
                        if (queryResult.trade_state == TradeStateEnum.SUCCESS)
                        {
                            Hashtable hashuf = new Hashtable();
                            hashuf["ID"]       = SiteHelper.GetHashTableValueByKey(financial_ht, "ID");
                            hashuf["UserID"]   = SiteHelper.GetHashTableValueByKey(financial_ht, "UserID");
                            hashuf["State"]    = UserFinancialState.Effect.GetHashCode();
                            hashuf["TradeNo"]  = queryResult.transaction_id;
                            hashuf["TotalFee"] = queryResult.total_fee;
                            hashuf["PayWay"]   = UserFinancialOperatorWay.WeixinPay;
                            decimal changesAmount = 0.00m;
                            decimal.TryParse(SiteHelper.GetHashTableValueByKey(financial_ht, "ChangesAmount"), out changesAmount);
                            bool isSuccess = false;
                            if (Math.Abs(changesAmount) == queryResult.total_fee)
                            {
                                isSuccess = uim.RechargeCallBack(hashuf);
                            }
                        }
                    }
                    else if (operator_way == UserFinancialOperatorWay.Alipay.GetHashCode().ToString())
                    {
                        AlipayOrderQuery orderQuery  = new AlipayOrderQuery();
                        OrderQueryResult queryResult = orderQuery.Query(order_payid);
                        if (queryResult.trade_state == TradeStateEnum.SUCCESS)
                        {
                            Hashtable hashuf = new Hashtable();
                            hashuf["ID"]       = SiteHelper.GetHashTableValueByKey(financial_ht, "ID");
                            hashuf["UserID"]   = SiteHelper.GetHashTableValueByKey(financial_ht, "UserID");
                            hashuf["State"]    = UserFinancialState.Effect.GetHashCode();
                            hashuf["TradeNo"]  = queryResult.transaction_id;
                            hashuf["TotalFee"] = queryResult.total_fee;
                            hashuf["PayWay"]   = UserFinancialOperatorWay.Alipay;
                            decimal changesAmount = 0.00m;
                            decimal.TryParse(SiteHelper.GetHashTableValueByKey(financial_ht, "ChangesAmount"), out changesAmount);
                            bool isSuccess = false;
                            if (Math.Abs(changesAmount) == queryResult.total_fee)
                            {
                                isSuccess = uim.RechargeCallBack(hashuf);
                            }
                        }
                    }
                }

                #endregion

                webRoot         = SiteHelper.GetWebRoot();
                weixinNotifyUrl = string.Format("{0}{1}", webRoot, "/api/app/pay/wxpay/recharge_notify_url.aspx");
                alipayNotifyUrl = string.Format("{0}{1}", webRoot, "/api/app/pay/alipay/recharge_notify_url.aspx");

                string result = "";
                ICache cache  = null;
                switch (payway)
                {
                case 1:
                    cache = CacheFactory.GetCache();
                    if (!string.IsNullOrEmpty(cache.Get <string>(cacheKey)))
                    {
                        cache.Dispose();
                        Logger.Error("充值支付宝支付5秒内," + uid);
                        return(SiteHelper.GetJsonFromHashTable(null, "faild", "5秒内请勿重复点击"));
                    }
                    cache.Dispose();
                    result = AliPay(uid, money);
                    break;

                case 2:
                    cache = CacheFactory.GetCache();
                    if (!string.IsNullOrEmpty(cache.Get <string>(cacheKey)))
                    {
                        cache.Dispose();
                        Logger.Error("充值微信支付5秒内," + uid);
                        return(SiteHelper.GetJsonFromHashTable(null, "faild", "5秒内请勿重复点击"));
                    }
                    cache.Dispose();
                    result = WxPay(uid, money);
                    break;

                default:
                    break;
                }
                return(result);
            }
        }
예제 #4
0
        public string Execute(Hashtable params_ht)
        {
            Hashtable res = params_ht;

            if (res["UID"] == null || res["UID"].ToString().Trim().Length <= 0 ||
                res["PayWay"] == null || res["PayWay"].ToString().Trim().Length <= 0)
            {
                return(SiteHelper.GetJsonFromHashTable(null, "faild", "参数不完整"));
            }
            else
            {
                uid = res["UID"].ToString().Trim();
                int.TryParse(res["PayWay"].ToString().Trim(), out payway);
                cacheKey += uid;
                UserFinancialManager ufm            = new UserFinancialManager();
                SysSettingManager    settingManager = new SysSettingManager();
                string depositMoney = settingManager.GetValueByKey("GoldDepositAmount");
                decimal.TryParse(depositMoney, out money);

                //在充值时进行身份验证
                UserInfoManager uim  = new UserInfoManager();
                Hashtable       user = uim.GetUserInfoByUserID(uid);
                if (user == null || user.Keys.Count <= 0)
                {
                    return(SiteHelper.GetJsonFromHashTable(null, "faild", "您不是有效会员"));
                }
                //----------------------------------------------------------------------------------

                //判断用户是否已缴纳押金
                decimal deposit = 0.00m;
                decimal.TryParse(user["DEPOSIT"].ToString(), out deposit);
                if (deposit > 0.00m)
                {
                    return(SiteHelper.GetJsonFromHashTable(null, "faild", "您当前已缴纳用车押金"));
                }
                //-------------------------------------------------------------------------------------

                #region 检测前一笔未确认支付交易是否成功,成功则禁止重复支付

                Hashtable financial_ht = ufm.GetLatestUserFinancialInfo(uid, UserFinancialState.NewSubmit, UserFinancialChangesType.Deposit);
                if (financial_ht != null && financial_ht.Keys.Count > 0)
                {
                    //是否添加前一笔和当前时间差判断逻辑??????
                    string order_payid  = SiteHelper.GetHashTableValueByKey(financial_ht, "OrderPayID");
                    string operator_way = SiteHelper.GetHashTableValueByKey(financial_ht, "OperatorWay");
                    if (operator_way == UserFinancialOperatorWay.WeixinPay.GetHashCode().ToString())
                    {
                        WxOrderQuery     orderQuery  = new WxOrderQuery();
                        OrderQueryResult queryResult = orderQuery.Query(order_payid);
                        if (queryResult.trade_state == TradeStateEnum.SUCCESS)
                        {
                            Hashtable hashuf = new Hashtable();
                            hashuf["ID"]       = SiteHelper.GetHashTableValueByKey(financial_ht, "ID");
                            hashuf["UserID"]   = SiteHelper.GetHashTableValueByKey(financial_ht, "UserID");
                            hashuf["State"]    = UserFinancialState.Effect.GetHashCode();
                            hashuf["TradeNo"]  = queryResult.transaction_id;
                            hashuf["TotalFee"] = queryResult.total_fee;
                            hashuf["PayWay"]   = UserFinancialOperatorWay.WeixinPay;
                            decimal changesAmount = 0.00m;
                            decimal.TryParse(SiteHelper.GetHashTableValueByKey(financial_ht, "ChangesAmount"), out changesAmount);
                            bool isSuccess = false;
                            if (Math.Abs(changesAmount) == queryResult.total_fee)
                            {
                                isSuccess = uim.DepositCallBack(hashuf);
                            }
                            if (isSuccess)
                            {
                                return(SiteHelper.GetJsonFromHashTable(null, "faild", "您当前已缴纳用车押金"));
                            }
                        }
                    }
                    else if (operator_way == UserFinancialOperatorWay.Alipay.GetHashCode().ToString())
                    {
                        AlipayOrderQuery orderQuery  = new AlipayOrderQuery();
                        OrderQueryResult queryResult = orderQuery.Query(order_payid);
                        if (queryResult.trade_state == TradeStateEnum.SUCCESS)
                        {
                            Hashtable hashuf = new Hashtable();
                            hashuf["ID"]       = SiteHelper.GetHashTableValueByKey(financial_ht, "ID");
                            hashuf["UserID"]   = SiteHelper.GetHashTableValueByKey(financial_ht, "UserID");
                            hashuf["State"]    = UserFinancialState.Effect.GetHashCode();
                            hashuf["TradeNo"]  = queryResult.transaction_id;
                            hashuf["TotalFee"] = queryResult.total_fee;
                            hashuf["PayWay"]   = UserFinancialOperatorWay.Alipay;
                            decimal changesAmount = 0.00m;
                            decimal.TryParse(SiteHelper.GetHashTableValueByKey(financial_ht, "ChangesAmount"), out changesAmount);
                            bool isSuccess = false;
                            if (Math.Abs(changesAmount) == queryResult.total_fee)
                            {
                                isSuccess = uim.DepositCallBack(hashuf);
                            }
                            if (isSuccess)
                            {
                                return(SiteHelper.GetJsonFromHashTable(null, "faild", "您当前已缴纳用车押金"));
                            }
                        }
                    }
                }

                #endregion

                webRoot         = SiteHelper.GetWebRoot();
                weixinNotifyUrl = string.Format("{0}{1}", webRoot, "/api/app/pay/wxpay/deposit_notify_url.aspx");
                alipayNotifyUrl = string.Format("{0}{1}", webRoot, "/api/app/pay/alipay/deposit_notify_url.aspx");

                string result = "";
                ICache cache  = null;
                switch (payway)
                {
                case 1:
                    cache = CacheFactory.GetCache();
                    if (!string.IsNullOrEmpty(cache.Get <string>(cacheKey)))
                    {
                        cache.Dispose();
                        Logger.Error("保证金支付宝支付5秒内," + uid);
                        return(SiteHelper.GetJsonFromHashTable(null, "faild", "5秒内请勿重复点击"));
                    }
                    cache.Dispose();
                    result = AliPay(uid, money);
                    break;

                case 2:
                    cache = CacheFactory.GetCache();
                    if (!string.IsNullOrEmpty(cache.Get <string>(cacheKey)))
                    {
                        cache.Dispose();
                        Logger.Error("保证金微信支付5秒内," + uid);
                        return(SiteHelper.GetJsonFromHashTable(null, "faild", "5秒内请勿重复点击"));
                    }
                    cache.Dispose();
                    result = WxPay(uid, money);
                    break;

                default:
                    break;
                }
                return(result);
            }
        }
        protected void Save_Click(object sender, EventArgs e)
        {
            try
            {
                bool      result         = false;
                int       returnType     = 0;
                Hashtable ht             = depositManager.GetDataByID(_key);
                string    depositMoney   = SiteHelper.GetHashTableValueByKey(ht, "DepositMoney");
                string    depositPayWay  = SiteHelper.GetHashTableValueByKey(ht, "DepositPayWay");
                string    depositTradeNo = SiteHelper.GetHashTableValueByKey(ht, "DepositTradeNo");
                string    realName       = SiteHelper.GetHashTableValueByKey(ht, "RealName");
                string    bindPhone      = SiteHelper.GetHashTableValueByKey(ht, "BindPhone");
                decimal   refundMoney    = 0.00m;
                refundMoney = decimal.Parse(depositMoney);
                if (State.Value == "2")
                {
                    string errmsg = "";
                    string code   = "";
                    if (depositPayWay == "1")
                    {
                        //支付宝退款
                        AlipayRefund alipay = new AlipayRefund();
                        result = alipay.Refund2(depositTradeNo, refundMoney, out errmsg, out code);
                        Logger.Warn(string.Format("{0},{1}支付宝退款:{2}", realName, bindPhone, errmsg));
                        if (!result && "40004".Equals(code))
                        {
                            //ShowMsgHelper.Alert_Error("支付宝退款失败:" + errmsg + "!");
                            //return;

                            //判断是否保存了buyer_id
                            string buyer_id = SiteHelper.GetHashTableValueByKey(ht, "buyer_id");
                            if (string.IsNullOrEmpty(buyer_id))
                            {
                                //buyer_id为空需要查询订单
                                AlipayOrderQuery orderQuery  = new AlipayOrderQuery();
                                OrderQueryResult queryResult = orderQuery.QueryByTradeNO(depositTradeNo);
                                buyer_id = queryResult.buyer_user_id;
                            }

                            if (!string.IsNullOrEmpty(buyer_id))
                            {
                                //执行单笔转账到支付宝账户
                                result = alipay.Transfer(depositTradeNo, buyer_id, refundMoney, out errmsg);
                                Logger.Warn(string.Format("{0},{1}支付宝转账退款:{2}", realName, bindPhone, errmsg));
                                returnType = 1;
                                if (!result)
                                {
                                    ShowMsgHelper.Alert_Error("支付宝转账退款失败:" + errmsg + "!");
                                    return;
                                }
                            }
                        }
                    }
                    else if (depositPayWay == "2")
                    {
                        //微信退款
                        WxRefund wxpay = new WxRefund();
                        result = wxpay.refund2(depositTradeNo, refundMoney, out errmsg);
                        if (!result)
                        {
                            ShowMsgHelper.Alert_Error("微信退款失败:" + errmsg + "!");
                            return;
                        }
                    }
                    else if (depositPayWay == "5")
                    {
                        //微信公众号退款
                        api.weapp.pay.wxpay.WxRefund wxpay = new api.weapp.pay.wxpay.WxRefund();
                        result = wxpay.refund2(depositTradeNo, refundMoney, out errmsg);
                        if (!result)
                        {
                            ShowMsgHelper.Alert_Error("微信公众号退款失败:" + errmsg + "!");
                            return;
                        }
                    }
                }
                else
                {
                    result = true;
                }
                if (result)
                {
                    result = depositManager.HandleReturnDeposit(_key, State.Value, Remark.Text.Trim(), RequestSession.GetSessionUser().UserName.ToString(), returnType);
                    if (result)
                    {
                        ShowMsgHelper.AlertMsgNoFresh("操作成功!");
                    }
                    else
                    {
                        ShowMsgHelper.Alert_Error("操作失败!");
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #6
0
        public string Execute(Hashtable params_ht)
        {
            Hashtable res = params_ht;

            if (res["UID"] == null || res["UID"].ToString().Trim().Length <= 0 ||
                res["PayWay"] == null || res["PayWay"].ToString().Trim().Length <= 0 ||
                res["OrderNum"] == null || res["OrderNum"].ToString().Trim().Length <= 0)
            {
                return(SiteHelper.GetJsonFromHashTable(null, "faild", "参数不完整"));
            }
            else
            {
                uid = res["UID"].ToString().Trim();
                int.TryParse(res["PayWay"].ToString().Trim(), out payway);
                cacheKey += uid;
                string ordernum                    = res["OrderNum"].ToString().Trim();
                string couponID                    = "";
                UserFinancialManager ufm           = new UserFinancialManager();
                UserInfoManager      uim           = new UserInfoManager();
                OrdersManager        om            = new OrdersManager();
                UserCouponManager    couponManager = new UserCouponManager();
                Hashtable            order_ht      = om.GetOrderInfoByNum(ordernum);
                if (order_ht == null)
                {
                    return(SiteHelper.GetJsonFromHashTable(null, "faild", "未找到订单数据,支付失败"));
                }
                int     payState   = int.Parse(SiteHelper.GetHashTableValueByKey(order_ht, "PayState"));
                int     orderState = int.Parse(SiteHelper.GetHashTableValueByKey(order_ht, "OrderState"));
                decimal payMoney   = decimal.Parse(SiteHelper.GetHashTableValueByKey(order_ht, "PayMoney"));
                decimal totalMoney = decimal.Parse(SiteHelper.GetHashTableValueByKey(order_ht, "TotalMoney"));

                if (OrderState.UnPay.GetHashCode() != orderState)
                {
                    return(SiteHelper.GetJsonFromHashTable(null, "faild", "订单支付失败"));
                }
                if (totalMoney <= 0)
                {
                    return(SiteHelper.GetJsonFromHashTable(null, "faild", "未产生支付费用,无需进行支付操作"));
                }

                #region 检测前一笔未确认支付交易是否成功,成功则禁止重复支付

                Hashtable financial_ht = ufm.GetLatestUserFinancialInfo(uid, UserFinancialState.NewSubmit, UserFinancialChangesType.Consumption);
                if (financial_ht != null && financial_ht.Keys.Count > 0)
                {
                    string order_num    = SiteHelper.GetHashTableValueByKey(financial_ht, "OrderNum");
                    string order_payid  = SiteHelper.GetHashTableValueByKey(financial_ht, "OrderPayID");
                    string operator_way = SiteHelper.GetHashTableValueByKey(financial_ht, "OperatorWay");
                    if (operator_way == UserFinancialOperatorWay.WeixinPay.GetHashCode().ToString())
                    {
                        WxOrderQuery     orderQuery  = new WxOrderQuery();
                        OrderQueryResult queryResult = orderQuery.Query(order_payid);
                        if (queryResult.trade_state == TradeStateEnum.SUCCESS)
                        {
                            Hashtable hashuf = new Hashtable();
                            hashuf["ID"]       = SiteHelper.GetHashTableValueByKey(financial_ht, "ID");
                            hashuf["OrderNum"] = SiteHelper.GetHashTableValueByKey(financial_ht, "OrderNum");
                            hashuf["UserID"]   = SiteHelper.GetHashTableValueByKey(financial_ht, "UserID");
                            hashuf["State"]    = UserFinancialState.Effect.GetHashCode();
                            hashuf["TradeNo"]  = queryResult.transaction_id;
                            hashuf["TotalFee"] = queryResult.total_fee;
                            hashuf["PayWay"]   = UserFinancialOperatorWay.WeixinPay;
                            decimal changesAmount = 0.00m;
                            decimal.TryParse(SiteHelper.GetHashTableValueByKey(financial_ht, "ChangesAmount"), out changesAmount);
                            bool isSuccess = false;
                            if (Math.Abs(changesAmount) == queryResult.total_fee)
                            {
                                isSuccess = uim.OrderPayCallback(hashuf);
                            }
                            if (isSuccess && ordernum == order_num)
                            {
                                return(SiteHelper.GetJsonFromHashTable(null, "faild", "您当前订单已成功支付"));
                            }
                        }
                    }
                    else if (operator_way == UserFinancialOperatorWay.Alipay.GetHashCode().ToString())
                    {
                        AlipayOrderQuery orderQuery  = new AlipayOrderQuery();
                        OrderQueryResult queryResult = orderQuery.Query(order_payid);
                        if (queryResult.trade_state == TradeStateEnum.SUCCESS)
                        {
                            Hashtable hashuf = new Hashtable();
                            hashuf["ID"]       = SiteHelper.GetHashTableValueByKey(financial_ht, "ID");
                            hashuf["OrderNum"] = SiteHelper.GetHashTableValueByKey(financial_ht, "OrderNum");
                            hashuf["UserID"]   = SiteHelper.GetHashTableValueByKey(financial_ht, "UserID");
                            hashuf["State"]    = UserFinancialState.Effect.GetHashCode();
                            hashuf["TradeNo"]  = queryResult.transaction_id;
                            hashuf["TotalFee"] = queryResult.total_fee;
                            hashuf["PayWay"]   = UserFinancialOperatorWay.Alipay;
                            decimal changesAmount = 0.00m;
                            decimal.TryParse(SiteHelper.GetHashTableValueByKey(financial_ht, "ChangesAmount"), out changesAmount);
                            bool isSuccess = false;
                            if (Math.Abs(changesAmount) == queryResult.total_fee)
                            {
                                isSuccess = uim.OrderPayCallback(hashuf);
                            }
                            if (isSuccess && ordernum == order_num)
                            {
                                return(SiteHelper.GetJsonFromHashTable(null, "faild", "您当前订单已成功支付"));
                            }
                        }
                    }
                }

                #endregion

                if (res["CouponID"] != null && res["CouponID"].ToString().Trim().Length > 0)
                {
                    couponID = res["CouponID"].ToString().Trim();
                    Hashtable coupon_ht = couponManager.GetDataByID(couponID);
                    if (coupon_ht == null || coupon_ht.Keys.Count == 0)
                    {
                        return(SiteHelper.GetJsonFromHashTable(null, "faild", "使用骑行券失败,支付失败"));
                    }
                    string  orderid     = SiteHelper.GetHashTableValueByKey(coupon_ht, "OrderID");
                    string  begintime   = SiteHelper.GetHashTableValueByKey(coupon_ht, "BeginTime");
                    string  endtime     = SiteHelper.GetHashTableValueByKey(coupon_ht, "EndTime");
                    string  userid      = SiteHelper.GetHashTableValueByKey(coupon_ht, "UserID");
                    decimal couponMoney = 0.00m;
                    decimal.TryParse(SiteHelper.GetHashTableValueByKey(coupon_ht, "Money"), out couponMoney);
                    if (userid != uid)
                    {
                        return(SiteHelper.GetJsonFromHashTable(null, "faild", "使用骑行券失败,支付失败"));
                    }
                    if (!string.IsNullOrEmpty(orderid))
                    {
                        return(SiteHelper.GetJsonFromHashTable(null, "faild", "使用骑行券失败,支付失败"));
                    }
                    if (DateTime.Parse(begintime) > DateTime.Now || DateTime.Parse(endtime) < DateTime.Now)
                    {
                        return(SiteHelper.GetJsonFromHashTable(null, "faild", "使用骑行券失败,支付失败"));
                    }
                    if (couponMoney > totalMoney)
                    {
                        return(SiteHelper.GetJsonFromHashTable(null, "faild", "使用骑行券失败,支付失败"));
                    }

                    Hashtable update_order_ht = new Hashtable();
                    update_order_ht["CouponID"]    = couponID;
                    update_order_ht["CouponMoney"] = couponMoney;
                    update_order_ht["PayMoney"]    = totalMoney - couponMoney;
                    bool rrr = om.AddOrEditOrdersInfo(update_order_ht, SiteHelper.GetHashTableValueByKey(order_ht, "ID"));
                }

                webRoot         = SiteHelper.GetWebRoot();
                weixinNotifyUrl = string.Format("{0}{1}", webRoot, "/api/app/pay/wxpay/order_notify_url.aspx");
                alipayNotifyUrl = string.Format("{0}{1}", webRoot, "/api/app/pay/alipay/order_notify_url.aspx");

                string result = "";
                ICache cache  = null;
                switch (payway)
                {
                case 1:
                    cache = CacheFactory.GetCache();
                    if (!string.IsNullOrEmpty(cache.Get <string>(cacheKey)))
                    {
                        cache.Dispose();
                        Logger.Error("订单支付宝支付5秒内," + uid);
                        return(SiteHelper.GetJsonFromHashTable(null, "faild", "5秒内请勿重复点击"));
                    }
                    cache.Dispose();
                    result = AliPay(uid, ordernum);
                    break;

                case 2:
                    cache = CacheFactory.GetCache();
                    if (!string.IsNullOrEmpty(cache.Get <string>(cacheKey)))
                    {
                        cache.Dispose();
                        Logger.Error("订单微信支付5秒内," + uid);
                        return(SiteHelper.GetJsonFromHashTable(null, "faild", "5秒内请勿重复点击"));
                    }
                    cache.Dispose();
                    result = WxPay(uid, ordernum);
                    break;

                case 3:
                    result = BalancePay(uid, ordernum);
                    break;

                default:
                    break;
                }
                return(result);
            }
        }