Exemple #1
0
        /// <summary>
        /// 获取当前价
        /// </summary>
        /// <param name="carSourceID"></param>
        /// <param name="pId"></param>
        /// <returns></returns>
        public AuctionPriceHistoryModel GetBidRecord(int carSourceID, long pId)
        {
            AuctionMainFormBiz       biz   = new AuctionMainFormBiz();
            string                   key   = string.Format("price_{0}", pId);
            AuctionPriceHistoryModel model = base.CurrentContext.Cache.Get <AuctionPriceHistoryModel>(key);

            if (model == null)
            {
                model = new AuctionPriceHistoryModel();
                model = biz.GetBidRecord(carSourceID, pId);
                base.CurrentContext.Cache.Insert <AuctionPriceHistoryModel>(key, model);
            }
            else
            {
                AuctionPriceHistoryModel aphm = biz.GetBidRecord(carSourceID, pId);
                if (model.AuctionPrice < aphm.AuctionPrice)
                {
                    model = aphm;
                    base.CurrentContext.Cache.Remove(key);
                    base.CurrentContext.Cache.Insert <AuctionPriceHistoryModel>(key, aphm);
                }
                else
                {
                    return(null);
                }
            }
            return(model);
        }
Exemple #2
0
        /// <summary>
        /// 获取主窗体数据
        /// </summary>
        /// <param name="TvaID"></param>
        /// <param name="dateTime"></param>
        /// <param name="carName"></param>
        /// <param name="TypeOrderbyStr"></param>
        /// <returns></returns>
        public List <AuctionHallDataModel> GetAuctionFormDataList(int TvaID, string dateTime)
        {
            PublishContext              pc         = new PublishContext();
            AuctionMainFormBiz          amfb       = new AuctionMainFormBiz();
            AuctionHallBiz              biz        = new AuctionHallBiz();
            List <AuctionHallDataModel> pidnewlist = new List <AuctionHallDataModel>();
            string key     = string.Format("form_{0}", dateTime);
            string hallkey = string.Format("hall_{0}", dateTime);
            List <AuctionHallDataModel> pidlist = base.CurrentContext.Session.Get <List <AuctionHallDataModel> >(key);

            if (pidlist == null)
            {
                pidlist = new List <AuctionHallDataModel>();
                pidlist = biz.GetAuctionHallDataList(TvaID, dateTime, "", "", 1);
                base.CurrentContext.Session.Set <List <AuctionHallDataModel> >(key, pidlist);
                pidnewlist = pidlist;
            }
            else if (pidlist.Count >= 0)
            {
                //所有数据都更新成初始状态
                pidlist.RemoveAll(p => p.DataStatus == 2);
                pidlist.ForEach(p => p.DataStatus = 0);
                string      key1       = "add";
                List <long> addList    = base.CurrentContext.Session.Get <List <long> >(key1);
                string      key2       = "cancel";
                List <long> cancelList = base.CurrentContext.Session.Get <List <long> >(key2);

                #region 更改关注相关
                //修改增加关注的状态
                if (addList != null)
                {
                    foreach (long l in addList.ToArray())
                    {
                        AuctionHallDataModel ahdm = pidlist.Where(p => p.PublishId == l).FirstOrDefault();
                        if (ahdm == null)
                        {
                            //if (base.CurrentContext.Session.Get<List<AuctionHallDataModel>>(hallkey) == null)
                            //{
                            //    if (base.CurrentContext.Session.Get<List<AuctionHallDataModel>>("hall_" + DateTime.Now.ToString("yyyy-MM-dd")) != null)
                            //    {
                            //        AuctionHallDataModel model = base.CurrentContext.Session.Get<List<AuctionHallDataModel>>("hall_" + DateTime.Now.ToString("yyyy-MM-dd")).Where(p => p.PublishId == l).FirstOrDefault();
                            //        if (model != null)
                            //        {
                            //            AuctionHallDataModel model1 = (AuctionHallDataModel)base.CurrentContext.Session.Get<List<AuctionHallDataModel>>("hall_" + DateTime.Now.ToString("yyyy-MM-dd")).Where(p => p.PublishId == l).FirstOrDefault().Clone();
                            //            model1.DataStatus = 3;
                            //            model1.AttentionState = "1";
                            //            pidlist.Add(model1);
                            //        }
                            //    }
                            //}
                            if (base.CurrentContext.Session.Get <List <AuctionHallDataModel> >(hallkey) != null)
                            {
                                AuctionHallDataModel model = base.CurrentContext.Session.Get <List <AuctionHallDataModel> >(hallkey).Where(p => p.PublishId == l).FirstOrDefault();
                                if (model != null)
                                {
                                    AuctionHallDataModel model1 = (AuctionHallDataModel)base.CurrentContext.Session.Get <List <AuctionHallDataModel> >(hallkey).Where(p => p.PublishId == l).FirstOrDefault().Clone();
                                    model1.DataStatus     = 3;
                                    model1.AttentionState = "1";
                                    pidlist.Add(model1);
                                }
                            }
                        }
                    }
                }
                //修改取消关注的状态
                if (cancelList != null)
                {
                    foreach (long l in cancelList.ToArray())
                    {
                        AuctionHallDataModel ahdm = (AuctionHallDataModel)pidlist.Where(p => p.PublishId == l && p.AttentionState == "1").FirstOrDefault();
                        if (ahdm != null)
                        {
                            ahdm.AttentionState = "0";
                            ahdm.DataStatus     = 2;
                        }
                    }
                }
                #endregion

                #region  增加竞价的model
                //if (base.CurrentContext.Session.Get<List<AuctionHallDataModel>>(hallkey) != null)
                //{
                //    List<AuctionHallDataModel> addModelList = base.CurrentContext.Session.Get<List<AuctionHallDataModel>>(hallkey).Where(p => p.BidStatus == "1" || p.BidStatus == "2").ToList();
                //    if (addModelList != null)
                //    {
                //        foreach (AuctionHallDataModel model in addModelList)
                //        {
                //            if (pidlist.Where(p => p.PublishId == model.PublishId).FirstOrDefault() == null)
                //            {
                //                AuctionHallDataModel newmodel =(AuctionHallDataModel) model.Clone();
                //                newmodel.DataStatus = 3;
                //                pidlist.Add(newmodel);
                //            }
                //        }
                //    }

                //}
                #endregion


                //判断状态是0,1,2,3的拍品
                List <AuctionHallDataModel> Sta1List = pidlist.Where(p => p.BidStatus == BidStatusType.确认条件 || p.BidStatus == BidStatusType.您是最高价 || p.BidStatus == BidStatusType.出价不是最高).ToList();
                if (Sta1List != null)
                {
                    foreach (AuctionHallDataModel ahdm in Sta1List)
                    {
                        //更改拍品状态
                        if (ahdm.AuctionStatus != biz.GetPublishTime(ahdm.PublishId, TvaID).AuctionStatus)
                        {
                            //更改数据源状态
                            ahdm.DataStatus    = 1;
                            ahdm.AuctionStatus = biz.GetPublishTime(ahdm.PublishId, TvaID).AuctionStatus;
                        }
                        //判断机器人状态是否改变
                        if (ahdm.IsSetRebot != amfb.isSetRobotFromCache(TvaID, ahdm.PublishId))
                        {
                            //更改数据源状态
                            if (ahdm.DataStatus == 0)
                            {
                                ahdm.DataStatus = 1;
                            }
                            ahdm.IsSetRebot = amfb.isSetRobotFromCache(TvaID, ahdm.PublishId);
                        }
                        //判断关注是否发生变化
                        //if (ahdm.AttentionState != amfb.isSetAttention(TvaID, ahdm.PublishId).ToString())
                        //{
                        //    //更改数据源状态
                        //    ahdm.DataStatus = 1;
                        //    ahdm.AttentionState = amfb.isSetAttention(TvaID, ahdm.PublishId).ToString();
                        //}
                        //提前选择成交
                        if (Convert.ToInt32(ahdm.AuctionStatus) > 2)
                        {
                            //更改数据源状态
                            ahdm.DataStatus = 1;

                            pc.ahdm = ahdm;
                            pc.StartStatus();
                        }
                        //竞价时间结束
                        if (DateTime.Compare(Convert.ToDateTime(ahdm.StopTime), DateTime.Now) < 0)
                        {
                            //更改数据源状态
                            ahdm.DataStatus = 1;

                            pc.ahdm = ahdm;
                            pc.StartStatus();
                        }
                        //价格变化更改状态
                        AuctionPriceHistoryModel currModel = amfb.GetHighestBidRecord(ahdm.CarSourceId, ahdm.PublishId);
                        if (ahdm.CurrentPrices < currModel.AuctionPrice)
                        {
                            // 不是新增,删除的状态更改状态
                            if (ahdm.DataStatus == 0)
                            {
                                ahdm.DataStatus = 1;
                            }
                            //更改当前价
                            ahdm.CurrentPrices = currModel.AuctionPrice;
                            //更改结束时间
                            ahdm.StopTime = biz.GetPublishTime(ahdm.PublishId, TvaID).StopTime;
                            //更改拍品状态
                            ahdm.AuctionStatus = biz.GetPublishTime(ahdm.PublishId, TvaID).AuctionStatus;
                            pc.ahdm            = ahdm;
                            pc.StartStatus();
                        }
                    }
                }
                //判断状态是3的拍品
                List <AuctionHallDataModel> Sta3List = pidlist.Where(p => p.BidStatus == BidStatusType.竞价结束).ToList();
                if (Sta3List != null)
                {
                    foreach (AuctionHallDataModel ahdm in Sta3List)
                    {
                        //更改拍品状态
                        if (ahdm.AuctionStatus != biz.GetPublishTime(ahdm.PublishId, TvaID).AuctionStatus)
                        {
                            //更改数据源状态
                            ahdm.DataStatus    = 1;
                            ahdm.AuctionStatus = biz.GetPublishTime(ahdm.PublishId, TvaID).AuctionStatus;
                        }
                        pc.ahdm = ahdm;
                        pc.StartStatus();
                    }
                }
                pidnewlist = pidlist.Where(p => p.DataStatus > 0).ToList();
            }
            return(pidnewlist);
        }