Example #1
0
        public Result <long> OrderAutoAdd(OrderAutoAdd model)
        {
            if (model.count_min > model.count_max || model.price_min > model.price_max || model.time_min > model.time_max)
            {
                return(Result(ApiResultEnum.Parameter_Error, 0L));
            }

            HQItem hq    = HQService.Get(model.code);
            Order  order = new Order()
            {
                user_id  = user_id,
                unit_id  = model.unit_id,
                code     = model.code,
                price    = hq.Last,
                count    = model.count_total,
                type     = model.type,
                platform = platform
            };

            ApiResultEnum result = LimitBiz.CheckStatus(order);

            if (result != ApiResultEnum.Success)
            {
                return(Result(result, 0L));
            }
            result = LimitBiz.CheckUnit(order);
            if (result != ApiResultEnum.Success)
            {
                return(Result(result, 0L));
            }

            model.name     = StockInfoBiz.GetStock(model.code).name;
            model.id       = FuncHelper.GetUniqueID();
            model.user_id  = user_id;
            model.platform = platform;
            if (model.account_id > 0)
            {
                model.account_name = AccountRA.GetName(model.account_id);
            }
            else
            {
                model.account_name = "";
            }
            string key = "S_" + model.id + "_U_" + model.unit_id + "_D_0";

            OrderAutoRA.Add(model, key);
            return(Result(ApiResultEnum.Success, model.id));
        }