Ejemplo n.º 1
0
        public async Task <IHttpActionResult> SpotGoods(SpotGoodsQueryRequest request)
        {
            var manager   = new SpotGoodsManager();
            var spotGoods = await manager.GetSpotGoodsAsync(request.GetSpotGoodsListQueryFilter());

            if (spotGoods == null)
            {
                return(NotFound("现货不存在"));
            }

            var spotGoodsViewModel    = new SpotGoodListItemViewModel(spotGoods);
            var dailyGoldPriceManager = new DailyGoldPriceManager();
            var dailyGoldPrice        = await dailyGoldPriceManager.GetNewDailyGoldPriceAsync(spotGoodsViewModel.ColorFormId);

            spotGoodsViewModel.DailyGoldPrice = dailyGoldPrice.Price;
            if (spotGoodsViewModel.Price == 0)
            {
                var goldCost = dailyGoldPrice.Price * spotGoodsViewModel.GoldWeight * (1 + (double)spotGoodsViewModel.Loss18KRate / 100);
                spotGoodsViewModel.Price = decimal.Round(((decimal)(spotGoodsViewModel.BasicCost + goldCost + spotGoods.SetStoneInfos.Sum(r => r.Price * r.Weight + r.Number * r.WorkingCost))), 2);
            }
            return(Ok(spotGoodsViewModel));
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> List(SpotGoodsQueryRequest request)
        {
            if (!Request.IsAjaxRequest())
            {
                return(View(request));
            }

            var manager = new SpotGoodsManager(User);
            var paging  = await manager.GetSpotGoodsListAsync(request.Start, request.Take, request.GetSpotGoodsListQueryFilter());

            var spotGoodList = paging.List.Select(u =>
            {
                var spotGoods = Mapper.Map <SpotGoods, SpotGoodsListItemViewModel>(u);
                return(spotGoods);
            });

            return(Json(true, string.Empty, new
            {
                paging.Total,
                List = spotGoodList
            }));
        }