Exemplo n.º 1
0
        public async Task <PagedResultDto <OrderListDto> > GetPaged(GetOrdersInput input)
        {
            var query = _orderManager.QueryAsNoTracking
                        .WhereIf(!input.FilterText.IsNullOrWhiteSpace(),
                                 o => o.ProductName.Contains(input.FilterText) ||
                                 o.ProductCode.Contains(input.FilterText) ||
                                 o.UserName.Contains(input.FilterText) ||
                                 o.OrderCode.Contains(input.FilterText)
                                 );
            // TODO:根据传入的参数添加过滤条件

            var count = await query.CountAsync();

            var entityList = await query
                             .OrderBy(input.Sorting).AsNoTracking()
                             .PageBy(input)
                             .ToListAsync();

            var entityListDtos = ObjectMapper.Map <List <OrderListDto> >(entityList);

            //var entityListDtos = entityList.MapTo<List<OrderListDto>>();
            foreach (var item in entityListDtos)
            {
                item.StatusStr = GetStatusString(item.Status);
            }

            return(new PagedResultDto <OrderListDto>(count, entityListDtos));
        }
        public override void HandleCore(PrivateMessageReceivedContext context)
        {
            MahuaApi.SendPrivateMessage(context.FromQq)
            .Text("Begin Get User Orders")
            .Done();

            var userAssets = _assetService.GetUserAssets();

            if (userAssets.Any())
            {
                var orderApi = _okexApiFactory.Create <IOrderApi>();
                var orders   = new List <Order>();
                var assets   = userAssets.OrderByDescending(x => x.Value.AsUsdt).ToArray();
                foreach (var kv in assets)
                {
                    if (kv.Key == "usdt")
                    {
                        continue;
                    }
                    var market         = $"{kv.Key}_usdt";
                    var getOrdersInput = new GetOrdersInput
                    {
                        Order_Id = "-1",
                        Symbol   = market,
                    }.WithSign();
                    var output = orderApi.GetOrders(getOrdersInput).GetAwaiter().GetResult();
                    if (output.Result)
                    {
                        orders.AddRange(output.Orders);
                    }
                    else
                    {
                        MahuaApi.SendPrivateMessage(context.FromQq)
                        .Text($"{market} No Orders")
                        .Done();
                    }
                }

                foreach (var order in orders.Where(x => x.Status == Order.OrderStatus.Doing || x.Status == Order.OrderStatus.Some))
                {
                    var dealPercetion = order.DealAmount / order.Amount * 100M;
                    var ticker        = _tickerProvider.GetTikcer(order.Symbol);
                    MahuaApi.SendPrivateMessage(context.FromQq)
                    .Text($"{order.Symbol} {order.Type:G}")
                    .Newline()
                    .Text($"Price:{order.Price:E6}")
                    .Newline()
                    .Text($"Amount:({dealPercetion:###.00}){order.DealAmount:e2}/{order.Amount:e2} ")
                    .Newline()
                    .Text($"USD:{order.DealAmount * ticker.Last:0000000.00}/{order.Amount * ticker.Last:0000000.00}")
                    .Done();
                }
            }
            else
            {
                MahuaApi.SendPrivateMessage(context.FromQq)
                .Text("No Orders")
                .Done();
            }
        }
        /// <summary>
        /// TODO: type endpoint description here
        /// </summary>
        /// <param name="GetOrdersInput">Object containing request parameters</param>
        /// <return>Returns the Models.GetOrdersResponseModel response from the API call</return>
        public Models.GetOrdersResponseModel GetOrders(GetOrdersInput input)
        {
            Task <Models.GetOrdersResponseModel> t = GetOrdersAsync(input);

            APIHelper.RunTaskSynchronously(t);
            return(t.Result);
        }
        /// <summary>
        /// TODO: type endpoint description here
        /// </summary>
        /// <param name="GetOrdersInput">Object containing request parameters</param>
        /// <return>Returns the Models.GetOrdersResponseModel response from the API call</return>
        public async Task <Models.GetOrdersResponseModel> GetOrdersAsync(GetOrdersInput input)
        {
            //the base uri for api requests
            string _baseUri = Configuration.GetBaseURI();

            //prepare query string for API call
            StringBuilder _queryBuilder = new StringBuilder(_baseUri);

            _queryBuilder.Append("/orders");

            //process optional query parameters
            APIHelper.AppendUrlWithQueryParameters(_queryBuilder, new Dictionary <string, object>()
            {
                { "accountIdentifier", input.AccountIdentifier },
                { "customerIdentifier", input.CustomerIdentifier },
                { "externalRefID", input.ExternalRefID },
                { "startDate", (input.StartDate.HasValue) ? input.StartDate.Value.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss.FFFFFFFK") : null },
                { "endDate", (input.EndDate.HasValue) ? input.EndDate.Value.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss.FFFFFFFK") : null },
                { "elementsPerBlock", input.ElementsPerBlock },
                { "page", input.Page }
            }, ArrayDeserializationFormat, ParameterSeparator);


            //validate and preprocess url
            string _queryUrl = APIHelper.CleanUrl(_queryBuilder);

            //append request with appropriate headers and parameters
            var _headers = new Dictionary <string, string>()
            {
                { "user-agent", "TangoCardv2NGSDK" },
                { "accept", "application/json" }
            };

            //prepare the API call request to fetch the response
            HttpRequest _request = ClientInstance.Get(_queryUrl, _headers, Configuration.PlatformName, Configuration.PlatformKey);

            //invoke request and get response
            HttpStringResponse _response = (HttpStringResponse)await ClientInstance.ExecuteAsStringAsync(_request).ConfigureAwait(false);

            HttpContext _context = new HttpContext(_request, _response);

            //handle errors defined at the API level
            base.ValidateResponse(_response, _context);

            try
            {
                return(APIHelper.JsonDeserialize <Models.GetOrdersResponseModel>(_response.Body));
            }
            catch (Exception _ex)
            {
                throw new APIException("Failed to parse the response: " + _ex.Message, _context);
            }
        }
        /// <summary>
        /// 获取所有订单
        /// </summary>
        /// <returns></returns>
        public async Task <PagedResultDto <OrderListDto> > GetOrders(GetOrdersInput input)
        {
            string provinceName = input.ProvinceId.HasValue ?
                                  (await _stateManager.GetProvinceByIdAsync(input.ProvinceId.Value)).Name : null;
            string cityName = input.CityId.HasValue ?
                              (await _stateManager.GetCityByIdAsync(input.CityId.Value)).Name : null;
            string districtName = input.DistrictId.HasValue ?
                                  (await _stateManager.FindDistrictByIdAsync(input.DistrictId.Value)).Name : null;

            var query = _orderManager
                        .Orderes
                        .Include(o => o.Items)
                        .Include(o => o.Shipments)
                        .WhereIf(!input.OrderTypes.IsNullOrEmpty(), r => input.OrderTypes.Contains(r.OrderType))
                        .WhereIf(!input.OrderSources.IsNullOrEmpty(), r => input.OrderSources.Contains(r.OrderSource))
                        .WhereIf(!input.OrderStatuses.IsNullOrEmpty(), r => input.OrderStatuses.Contains(r.OrderStatus))
                        .WhereIf(!input.ShippingStatuses.IsNullOrEmpty(), r => input.ShippingStatuses.Contains(r.ShippingStatus))
                        .WhereIf(!input.PaymentStatuses.IsNullOrEmpty(), r => input.PaymentStatuses.Contains(r.PaymentStatus))
                        .WhereIf(!input.OrderNumber.IsNullOrWhiteSpace(), r => r.OrderNumber.Contains(input.OrderNumber))
                        .WhereIf(input.StoreIds != null && input.StoreIds.Any(), r => input.StoreIds.Contains(r.StoreId))
                        .WhereIf(input.ProductIds != null && input.ProductIds.Any(), r => r.Items.Any(i => input.ProductIds.Contains(i.ProductId)))
                        .WhereIf(!input.LogisticsNumber.IsNullOrWhiteSpace(), r => r.Shipments.Any(s => s.LogisticsNumber.Contains(input.LogisticsNumber)))
                        .WhereIf(!input.ShippingName.IsNullOrWhiteSpace(), r => r.ShippingName.Contains(input.ShippingName))
                        .WhereIf(!input.PhoneNumber.IsNullOrWhiteSpace(), r => r.ShippingPhoneNumber.Contains(input.PhoneNumber))
                        .WhereIf(!provinceName.IsNullOrWhiteSpace(), r => r.ShippingProvince.Contains(provinceName))
                        .WhereIf(!cityName.IsNullOrWhiteSpace(), r => r.ShippingCity.Contains(cityName))
                        .WhereIf(!districtName.IsNullOrWhiteSpace(), r => r.ShippingDistrict.Contains(districtName))
                        .WhereIf(input.CreatedOn.FormDateNotEmpty(), r => r.CreationTime >= input.CreatedOn.FormDate)
                        .WhereIf(input.CreatedOn.ToDateNotEmpty(), r => r.CreationTime <= input.CreatedOn.ToDate)
                        .WhereIf(input.ReceivedOn.FormDateNotEmpty(), r => (r.ReceivedOn != null && r.ReceivedOn >= input.ReceivedOn.FormDate))
                        .WhereIf(input.ReceivedOn.ToDateNotEmpty(), r => (r.ReceivedOn != null && r.ReceivedOn <= input.ReceivedOn.ToDate));

            var orderCount = await query.CountAsync();

            var orders = await query
                         .OrderBy(input.Sorting)
                         .PageBy(input)
                         .ToListAsync();

            var orderListDtos = orders.Select(o =>
            {
                var orderDto = PrepareOrderListDto(o).Result;
                return(orderDto);
            }).ToList();

            return(new PagedResultDto <OrderListDto>(
                       orderCount,
                       orderListDtos));
        }
Exemplo n.º 6
0
        /// <summary>
        /// 获取Order的分页列表信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <PagedResultDto <OrderListDto> > GetPagedOrders(GetOrdersInput input)
        {
            var query = _orderRepository.GetAll();
            // TODO:根据传入的参数添加过滤条件

            var orderCount = await query.CountAsync();

            var orders = await query
                         .OrderBy(input.Sorting)
                         .PageBy(input)
                         .ToListAsync();

            var orderListDtos = orders.MapTo <List <OrderListDto> >();

            return(new PagedResultDto <OrderListDto>(
                       orderCount,
                       orderListDtos
                       ));
        }
Exemplo n.º 7
0
        public async Task Execute(GetOrdersInput input)
        {
            if (input == null)
            {
                _outputHandler.Error("Input is null.");
                return;
            }
            var orders = await _clientRepository.GetSentOrders(input.SenderId);

            List <CreateOrdersOutput> outputOrders = new List <CreateOrdersOutput>();
            CreateOrdersOutput        tempOutput;

            foreach (var o in orders)
            {
                var sender = _clientRepository.GetById(o.SenderId);
                var parcel = _parcelRepository.GetParcelById(o.ParcelId);
                tempOutput = new CreateOrdersOutput(o.Id, sender.Result, o.RecipientName, o.RecipientSurname, parcel.Result, o.Status);
                outputOrders.Add(tempOutput);
            }
            _outputHandler.Standard(outputOrders);
        }
Exemplo n.º 8
0
        public PagedResultDto <GetOrdersListDto> GetOrdersList(GetOrdersInput input)
        {
            long userId = input.UserID;
            var  dbSrc  = _orderRepository.GetOrdersForUser(input.UserID).WhereIf(input.OrderNo.IsNullOrWhiteSpace(), m => m.OrderNo == input.OrderNo)
                          .WhereIf(input.OrderStartDate.HasValue, m => m.CreationTime >= input.OrderStartDate)
                          .WhereIf(input.OrderEndDate.HasValue, m => m.CreationTime <= input.OrderEndDate)
                          .WhereIf(input.Status.IsNullOrWhiteSpace(), m => m.Status == input.Status)
                          .OrderBy(input.Sorting);

            string startDate = (input.OrderStartDate ?? DateTime.MinValue).ToShortTimeString();
            string endDate   = (input.OrderEndDate ?? DateTime.MinValue).ToShortTimeString();
            var    cacheKey  = @"GetOrdersList_{userId.ToString()}_{startDate}_{endDate}_{input.TradeType}";

            var list =
                _cacheManager.GetCache <string, List <DX.Loan.Order> >(AppConsts.Cache_OrderAppService_Method_OrdersList).Get(cacheKey, () => dbSrc.ToList());

            var count = list.Count();
            var lists = list.Skip(input.SkipCount).Take(input.MaxResultCount).ToList();

            var dtoList = Mapper.Map <List <GetOrdersListDto> >(lists);

            return(new PagedResultDto <GetOrdersListDto>(count, dtoList));
        }
Exemplo n.º 9
0
        /// <summary>
        /// 分页获取订单列表
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <PagedResultDto <OrderListDto> > GetPagedOrderListsAsync(GetOrdersInput input)
        {
            var orderList = _orderRepository.GetAll();
            var activity  = _activityRepository.GetAll();
            var user      = _userinfoRepository.GetAll();
            var result    = (from o in orderList
                             join a in activity on o.ActivityId equals a.ActivityId
                             join u in user on o.UserId equals u.OpenId
                             select new OrderListDto()
            {
                Id = o.Id,
                OrderId = o.OrderId,
                Title = a.Title,
                AllManSum = o.AllManSum,
                Money = o.Money,
                Price = o.Price,
                WXPriceArray = a.WXPriceArray,
                PriceIndex = o.PriceIndex,
                PpriceTitle = o.PpriceTitle,
                State = o.State,
                OpenId = u.OpenId
            });
            var orderListCount = await result.CountAsync();

            var orderLists = await result
                             .OrderBy(v => v.Id).AsNoTracking()
                             .PageBy(input)
                             .ToListAsync();

            var orderListDtos = orderLists.MapTo <List <OrderListDto> >();

            return(new PagedResultDto <OrderListDto>(
                       orderListCount,
                       orderListDtos
                       ));
        }
Exemplo n.º 10
0
        public async Task <PagedResultDto <UserCenterOrderListDto> > GetUserCenterPaged(GetOrdersInput input)
        {
            var query = _orderManager.QueryAsNoTracking
                        .Where(o => o.UserId == AbpSession.UserId)
                        .WhereIf(!input.FilterText.IsNullOrWhiteSpace(),
                                 o => o.ProductName.Contains(input.FilterText)
                                 );

            var count = await query.CountAsync();

            // 设置排序,根据创建时间倒叙
            input.Sorting = "CreationTime Desc";
            var entityList = await query
                             .OrderBy(input.Sorting).AsNoTracking()
                             .PageBy(input)
                             .ToListAsync();

            var entityListDtos = ObjectMapper.Map <List <UserCenterOrderListDto> >(entityList);

            //var entityListDtos = entityList.MapTo<List<UserCenterOrderListDto>>();
            foreach (var item in entityListDtos)
            {
                item.StatusStr = GetStatusString(item.Status);
            }

            return(new PagedResultDto <UserCenterOrderListDto>(count, entityListDtos));
        }
Exemplo n.º 11
0
 public PagedResultDto <GetOrdersListDto> GetOrdersListForUser(GetOrdersInput input)
 {
     input.UserID = AbpSession.GetUserId();
     return(GetOrdersList(input));
 }