Exemplo n.º 1
0
        //处理基于拍卖时间、其他人加价、拍卖是否成功做的处理
        //会出现四种情况,三种用于显示:
        //1表示未到时间有其他人加价;2表示到时间拍中商品;3表示到时间没拍中;4表示到时间,卖家确认交易成功,待买家评价
        public JsonpResult BuyerAuctionEvent(int userid)
        {
            var awlist = db.AuctionWishlists.Where(x => x.UserId == userid).ToList();
            List <BuyerAuction> balist = new List <BuyerAuction>();

            foreach (AuctionWishlist aw in awlist)
            {
                var auction      = db.Auctions.Find(aw.AucId);
                var userPrice    = aw.NewAucPrice;
                var auctionPrice = auction.NewPrice;
                var ba           = new BuyerAuction()
                {
                    AucId            = auction.Id,
                    AucTitle         = auction.AucTitle,
                    AucPrice         = auctionPrice,
                    NewAucPrice      = userPrice,
                    CompleteDealTime = db.UserAuctions.Single(x => x.AucId == aw.AucId).CompleteDealTime
                };
                if (!(_auctionService.IsOverTime(auction.EndTime)) && userPrice < auctionPrice)
                {
                    ba.Option = "1";
                    balist.Add(ba);
                }
                else if (_auctionService.IsOverTime(auction.EndTime))
                {
                    var buyerid = db.Auctions.Find(aw.AucId).Buyerid;
                    var ua      = db.UserAuctions.Single(x => x.AucId == aw.AucId);
                    if (userid == buyerid)
                    {
                        ba.Option = "2";
                        balist.Add(ba);
                    }
                    else
                    {
                        ba.Option = "3";
                        balist.Add(ba);
                    }
                    if (aw.IsTransactionSuccessful == true && ua.Evaluated == false)
                    {
                        ba.Option = "4";
                        balist.Add(ba);
                    }
                }
            }
            if (balist.Count() == 0)
            {
                return(this.Jsonp(this.WrapNoKey("no events")));
            }
            else
            {
                return(this.Jsonp(this.WrapNoKey(balist.AsEnumerable <BuyerAuction>())));
            }
        }
Exemplo n.º 2
0
        //获取买家信息
        //返回拍卖品信息(显示拍卖标题,最终价格)和买家信息(买家姓名、联系方式)
        public JsonpResult GetBuyerMsg(int aucid)
        {
            var          auction = db.Auctions.Find(aucid);
            var          buyerid = auction.Buyerid;
            var          buyer   = db.Users.Find(buyerid);
            var          judge   = db.AuctionWishlists.Single(x => x.AucId == aucid && x.UserId == buyerid).IsTransactionSuccessful;
            BuyerAuction ba      = new BuyerAuction()
            {
                AucTitle      = auction.AucTitle,
                AucPrice      = auction.NewPrice,
                UserName      = buyer.UserName,
                UserTel       = buyer.Tel,
                IsTranSuccess = judge
            };

            return(this.Jsonp(this.WrapNoKey(ba)));
            //return this.Jsonp(this.WrapNoKey(buyer));
        }