示例#1
0
        /// <summary>
        /// 交易大厅列表
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private string TradingFloor(HttpContext context)
        {
            string struserid = context.Request["userid"] ?? "";
            string strtop    = context.Request["top"] ?? "0";
            bool   flag      = false;
            string message   = string.Empty;
            long   userid    = 0;

            if (string.IsNullOrEmpty(struserid))
            {
                return(ResultJson(ResultType.error, "请输入用户ID", ""));
            }
            if (!long.TryParse(struserid, out userid))
            {
                return(ResultJson(ResultType.error, "请输入有效的用户ID", ""));
            }
            int top = 0;

            if (!int.TryParse(strtop, out top))
            {
                return(ResultJson(ResultType.error, "请输入有效的查询数量", ""));
            }

            TradingService svc = new TradingService();
            //交易大厅
            TradingHallModel model = svc.TradingHall(top, userid, out flag, out message);

            if (flag)
            {
                return(ResultJson(ResultType.success, message, model));
            }
            else
            {
                return(ResultJson(ResultType.error, message, model));
            }
        }
示例#2
0
        private string TradingBuy(HttpContext context)
        {
            string struserid      = context.Request["userid"] ?? "";
            string strprice       = context.Request["price"] ?? "";
            string strnumber      = context.Request["number"] ?? "";
            string strpaypassword = context.Request["paypassword"] ?? "";
            string fromwhere      = context.Request["fromwhere"] ?? "";
            string message        = string.Empty;
            bool   flag           = false;

            #region 用户ID
            long userid = 0;
            if (string.IsNullOrEmpty(struserid))
            {
                return(ResultJson(ResultType.error, "请输入用户ID", ""));
            }
            if (!long.TryParse(struserid, out userid))
            {
                return(ResultJson(ResultType.error, "请输入有效的用户ID", ""));
            }
            #endregion

            #region 挂卖价格
            decimal price = 0;
            if (string.IsNullOrEmpty(strprice))
            {
                return(ResultJson(ResultType.error, "请输入买入价格", ""));
            }
            if (!decimal.TryParse(strprice, out price))
            {
                return(ResultJson(ResultType.error, "请输入有效的买入价格", ""));
            }
            #endregion

            #region 买入数量
            int number = 0;
            if (string.IsNullOrEmpty(strnumber))
            {
                return(ResultJson(ResultType.error, "请输入买入数量", ""));
            }
            if (!int.TryParse(strnumber, out number))
            {
                return(ResultJson(ResultType.error, "请输入有效的买入数量", ""));
            }
            if (number <= 0)
            {
                return(ResultJson(ResultType.error, "挂卖数量必须大于0", ""));
            }
            #endregion

            #region 支付密码
            if (string.IsNullOrEmpty(strpaypassword))
            {
                return(ResultJson(ResultType.error, "请输入支付密码", ""));
            }
            #endregion

            TradingService   svc   = new TradingService();
            TradingHallModel model = svc.Buy(userid, price, number, strpaypassword.ToUpper(), out flag, out message);
            if (flag)
            {
                return(ResultJson(ResultType.success, message, model));
            }
            else
            {
                return(ResultJson(ResultType.error, message, model));
            }
        }