Пример #1
0
        public CutDownInfo GetCutDown(int cutDownId)
        {
            CutDownInfo info             = null;
            DbCommand   sqlStringCommand = this.database.GetSqlStringCommand("SELECT * FROM vw_Hishop_CutDown WHERE CutDownId=@CutDownId;SELECT * FROM Hishop_cutdowndetail WHERE CutDownId=@CutDownId");

            this.database.AddInParameter(sqlStringCommand, "CutDownId", DbType.Int32, cutDownId);
            using (IDataReader reader = this.database.ExecuteReader(sqlStringCommand))
            {
                if (reader.Read())
                {
                    info = DataMapper.PopulateCutDown(reader);
                }
                reader.NextResult();
                while (reader.Read())
                {
                    CutDownDetailInfo item = new CutDownDetailInfo
                    {
                        CutDownId    = (int)reader["CutDownId"],
                        MemberId     = (int)reader["MemberId"],
                        CutTime      = (DateTime)reader["CutTime"],
                        CutDownPrice = (decimal)reader["CutDownPrice"]
                    };
                    info.CutDownDetails.Add(item);
                }
            }
            return(info);
        }
Пример #2
0
        /// <summary>
        /// 砍价
        /// </summary>
        public static string goCutDown(CutDownDetailInfo info)
        {
            CutDownInfo cutDown = GetCutDown(info.CutDownId);
            string      result  = "";

            //如果当前价格超过最低价, 并且活动时间结束,并且达到最大砍价次数,则返回提示信息
            if (cutDown.CurrentPrice <= cutDown.MinPrice)
            {
                return(result = "当前价格已经达到最低价,无法砍价!");
            }
            if (cutDown.EndDate <= DateTime.Now)
            {
                return(result = "活动已经结束,无法砍价!");
            }
            if (cutDown.MaxCount <= GetCutDownTotalCount(cutDown.CutDownId))
            {
                return(result = "当前砍价次数已经达到上限,无法砍价!");
            }
            //开始砍价
            if (new CutDownDao().goCutDown(info) && new CutDownDao().updateCurrentPrice(info.CutDownId, cutDown.PerCutPrice))
            {
                result = "success";
            }
            return(result);
        }
Пример #3
0
        /// <summary>
        /// 砍价
        /// </summary>
        public bool goCutDown(CutDownDetailInfo info)
        {
            DbCommand sqlStringCommand = this.database.GetSqlStringCommand("insert into hishop_CutDownDetail (CutDownId,memberId,cutTime,cutDownPrice) values(@CutDownId,@memberId,@cutTime,@cutDownPrice)");

            this.database.AddInParameter(sqlStringCommand, "CutDownId", DbType.Int32, info.CutDownId);
            this.database.AddInParameter(sqlStringCommand, "memberId", DbType.Int32, info.MemberId);
            this.database.AddInParameter(sqlStringCommand, "cutTime", DbType.DateTime, DateTime.Now);
            this.database.AddInParameter(sqlStringCommand, "cutDownPrice", DbType.Decimal, info.CutDownPrice);
            return(this.database.ExecuteNonQuery(sqlStringCommand) == 1);
        }
Пример #4
0
        /// <summary>
        /// 获取单个砍价信息
        /// </summary>
        public CutDownDetailInfo GetCutDownDetail(int cutDownId, int memberId)
        {
            CutDownDetailInfo info             = null;
            DbCommand         sqlStringCommand = this.database.GetSqlStringCommand("Select * from hishop_cutdowndetail where cutdownid=@cutdownid and memberId=@memberId");

            this.database.AddInParameter(sqlStringCommand, "cutdownid", DbType.Int32, cutDownId);
            this.database.AddInParameter(sqlStringCommand, "memberId", DbType.Int32, memberId);
            using (IDataReader reader = this.database.ExecuteReader(sqlStringCommand))
            {
                if (reader.Read())
                {
                    info = DataMapper.PopulateCutDownDetails(reader);
                }
            }
            return(info);
        }