Exemplo n.º 1
0
            /// <summary>
            /// 获得商品评价信息(DTO)
            /// </summary>
            /// <param name="__idatareader">要转换的数据</param>
            /// <returns>返回商品评价信息</returns>
            public static GoodsrateinfoCollection GetGoodsRateInfoList(IDataReader reader)
            {
                GoodsrateinfoCollection goodsRateInfoColl = new GoodsrateinfoCollection();

                while (reader.Read())
                {
                    Goodsrateinfo goodsRateInfo = new Goodsrateinfo();
                    goodsRateInfo.Id = TypeConverter.ObjectToInt(reader["id"]);
                    goodsRateInfo.Goodstradelogid = TypeConverter.ObjectToInt(reader["goodstradelogid"]);
                    goodsRateInfo.Message         = reader["message"].ToString().Trim();
                    goodsRateInfo.Explain         = reader["explain"].ToString().Trim();
                    goodsRateInfo.Ip           = reader["ip"].ToString().Trim();
                    goodsRateInfo.Uid          = TypeConverter.ObjectToInt(reader["uid"]);
                    goodsRateInfo.Uidtype      = Convert.ToInt16(reader["uidtype"].ToString());
                    goodsRateInfo.Ratetouid    = TypeConverter.ObjectToInt(reader["ratetouid"]);
                    goodsRateInfo.Username     = reader["username"].ToString().Trim();
                    goodsRateInfo.Postdatetime = Convert.ToDateTime(reader["postdatetime"]);
                    goodsRateInfo.Goodsid      = TypeConverter.ObjectToInt(reader["goodsid"]);
                    goodsRateInfo.Goodstitle   = reader["goodstitle"].ToString().Trim();
                    goodsRateInfo.Price        = Convert.ToDecimal(reader["price"].ToString());
                    goodsRateInfo.Ratetype     = Convert.ToInt16(reader["ratetype"].ToString());

                    goodsRateInfoColl.Add(goodsRateInfo);
                }
                reader.Close();
                return(goodsRateInfoColl);
            }
Exemplo n.º 2
0
            /// <summary>
            /// 获得商品评价信息(DTO)
            /// </summary>
            /// <param name="dt">要转换的数据表</param>
            /// <returns>返回商品评价信息</returns>
            public static Goodsrateinfo[] GetGoodsRatesInfoArray(DataTable dt)
            {
                if (dt == null || dt.Rows.Count == 0)
                {
                    return(null);
                }

                Goodsrateinfo[] goodsratesinfoarray = new Goodsrateinfo[dt.Rows.Count];
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    goodsratesinfoarray[i]    = new Goodsrateinfo();
                    goodsratesinfoarray[i].Id = TypeConverter.ObjectToInt(dt.Rows[i]["id"]);
                    goodsratesinfoarray[i].Goodstradelogid = TypeConverter.ObjectToInt(dt.Rows[i]["goodstradelogid"]);
                    goodsratesinfoarray[i].Message         = dt.Rows[i]["message"].ToString();
                    goodsratesinfoarray[i].Explain         = dt.Rows[i]["explain"].ToString();
                    goodsratesinfoarray[i].Ip           = dt.Rows[i]["ip"].ToString();
                    goodsratesinfoarray[i].Uid          = TypeConverter.ObjectToInt(dt.Rows[i]["uid"]);
                    goodsratesinfoarray[i].Uidtype      = TypeConverter.ObjectToInt(dt.Rows[i]["uidtype"]);
                    goodsratesinfoarray[i].Ratetouid    = TypeConverter.ObjectToInt(dt.Rows[i]["ratetouid"]);
                    goodsratesinfoarray[i].Username     = dt.Rows[i]["username"].ToString();
                    goodsratesinfoarray[i].Postdatetime = Convert.ToDateTime(dt.Rows[i]["postdatetime"].ToString());
                    goodsratesinfoarray[i].Goodsid      = TypeConverter.ObjectToInt(dt.Rows[i]["goodsid"]);
                    goodsratesinfoarray[i].Goodstitle   = dt.Rows[i]["goodstitle"].ToString();
                    goodsratesinfoarray[i].Price        = Convert.ToDecimal(dt.Rows[i]["price"].ToString());
                    goodsratesinfoarray[i].Ratetype     = TypeConverter.ObjectToInt(dt.Rows[i]["ratetype"]);
                }
                dt.Dispose();
                return(goodsratesinfoarray);
            }
Exemplo n.º 3
0
        /// <summary>
        /// 设置用户信用(该方法会在用户进行评价之后调用)
        /// </summary>
        /// <param name="goodsrateinfo">评价信息</param>
        /// <param name="uid">被评价人的uid</param>
        /// <returns></returns>
        public static bool SetUserCredit(Goodsrateinfo goodsRateInfo, int uid)
        {
            //获取被评价人的信用信息
            GoodsusercreditinfoCollection goodsUserCreditInfoColl = GetUserCreditList(uid);

            //如果信用表中不存在, 则创建被评价人的信息
            if (goodsUserCreditInfoColl.Count == 0)
            {
                //当初始化信息失败时则返回
                if (DbProvider.GetInstance().InitGoodsUserCredit(uid) <= 0)
                {
                    return(false);
                }

                //再次获取被评价人的信用信息
                goodsUserCreditInfoColl = GetUserCreditList(uid);
            }

            //用于绑定要更新的用户信用
            Goodsusercreditinfo cur_creditInfo = null;

            foreach (Goodsusercreditinfo goodsUserCreditInfo in goodsUserCreditInfoColl)
            {
                //查找符合条件的用户信用
                if (goodsRateInfo.Uidtype == goodsUserCreditInfo.Ratefrom && goodsRateInfo.Ratetype == goodsUserCreditInfo.Ratetype)
                {
                    cur_creditInfo = goodsUserCreditInfo;
                }
                break;
            }

            //当不为空, 表示找到了要更新的用户信用信息, 则进行下面的绑定操作
            if (cur_creditInfo != null)
            {
                IDataReader iDataReader = DbProvider.GetInstance().GetGoodsRateCount(uid, goodsRateInfo.Uidtype, goodsRateInfo.Ratetype);
                //绑定新的查询数据
                if (iDataReader.Read())
                {
                    cur_creditInfo.Ratefrom    = goodsRateInfo.Uidtype;
                    cur_creditInfo.Ratetype    = goodsRateInfo.Ratetype;
                    cur_creditInfo.Oneweek     = TypeConverter.ObjectToInt(iDataReader["oneweek"]);
                    cur_creditInfo.Onemonth    = TypeConverter.ObjectToInt(iDataReader["onemonth"]);
                    cur_creditInfo.Sixmonth    = TypeConverter.ObjectToInt(iDataReader["sixmonth"]);
                    cur_creditInfo.Sixmonthago = TypeConverter.ObjectToInt(iDataReader["sixmonthago"]);
                    UpdateUserCredit(cur_creditInfo);
                }
                iDataReader.Close();
            }
            return(true);
        }
Exemplo n.º 4
0
 /// <summary>
 /// 创建商品评价信息
 /// </summary>
 /// <param name="goodsrateinfo">要创建的商品评价信息</param>
 /// <returns></returns>
 public static int CreateGoodsRate(Goodsrateinfo goodsRateInfo)
 {
     return(DbProvider.GetInstance().CreateGoodsRate(goodsRateInfo));
 }
Exemplo n.º 5
0
        protected override void ShowPage()
        {
            if (config.Enablemall == 0) //未启用交易服务
            {
                AddErrLine("系统未开启交易服务, 当前页面暂时无法访问!");
                return;
            }

            if (userid == -1)
            {
                AddErrLine("你尚未登录");
                return;
            }

            headerad = "";
            footerad = "";

            // 如果商品交易日志不正确
            if (goodstradelogid <= 0)
            {
                AddErrLine("无效的交易日志信息.");
                return;
            }

            goodstradelog = TradeLogs.GetGoodsTradeLogInfo(goodstradelogid);
            int oldstatus = goodstradelog.Status;

            if (config.Enablemall == 1) //开启普通模式
            {
                forumid = GoodsCategories.GetCategoriesFid(goodstradelog.Categoryid);
            }
            else
            {
                forumid = 0;
            }

            ///得到广告列表
            ///头部
            headerad = Advertisements.GetOneHeaderAd("", forumid);
            footerad = Advertisements.GetOneFooterAd("", forumid);
            doublead = Advertisements.GetDoubleAd("", forumid);
            floatad  = Advertisements.GetFloatAd("", forumid);

            if (goodstradelog.Sellerid != userid && goodstradelog.Buyerid != userid)
            {
                AddErrLine("您的身份不是买卖双方, 因为不能评价");
                return;
            }
            if (goodstradelog.Status != 7 && goodstradelog.Status != 17)
            {
                AddErrLine("交易尚未结束, 因为不能评价");
                return;
            }
            if (!GoodsRates.CanRate(goodstradelog.Id, userid)) //如果当前用户已评价过则不允许再评价
            {
                AddErrLine("不能重复评价");
                return;
            }


            //如果是提交...
            if (ispost)
            {
                Goodsrateinfo goodsrateinfo = new Goodsrateinfo();
                goodsrateinfo.Ip              = DNTRequest.GetIP();
                goodsrateinfo.Postdatetime    = DateTime.Now;
                goodsrateinfo.Price           = goodstradelog.Number * goodstradelog.Price + goodstradelog.Transportfee;
                goodsrateinfo.Ratetype        = DNTRequest.GetInt("ratetype", 0);
                goodsrateinfo.Uid             = userid;
                goodsrateinfo.Username        = username;
                goodsrateinfo.Message         = DNTRequest.GetString("message");
                goodsrateinfo.Goodstradelogid = goodstradelog.Id;
                goodsrateinfo.Goodstitle      = goodstradelog.Subject;
                goodsrateinfo.Goodsid         = goodstradelog.Goodsid;
                goodsrateinfo.Explain         = "";

                if (goodstradelog.Buyerid == userid)  //买家
                {
                    goodsrateinfo.Uidtype        = 2;
                    goodsrateinfo.Ratetouid      = goodstradelog.Sellerid;
                    goodsrateinfo.Ratetousername = goodstradelog.Seller;
                    goodstradelog.Ratestatus     = 2;
                }
                else //卖家
                {
                    goodsrateinfo.Uidtype        = 1;
                    goodsrateinfo.Ratetouid      = goodstradelog.Buyerid;
                    goodsrateinfo.Ratetousername = goodstradelog.Buyer;
                    goodstradelog.Ratestatus     = 1;
                }
                if (GoodsRates.CreateGoodsRate(goodsrateinfo) > 0) //如果评价成功
                {
                    if (GoodsRates.RateClosed(goodsrateinfo.Goodstradelogid, goodstradelog.Sellerid, goodstradelog.Buyerid))
                    {
                        goodstradelog.Ratestatus = 3;
                        TradeLogs.UpdateTradeLog(goodstradelog, oldstatus); //更新交易的评价状态
                    }

                    GoodsUserCredits.SetUserCredit(goodsrateinfo, goodsrateinfo.Uidtype == 1 ? goodstradelog.Buyerid : goodstradelog.Sellerid);

                    SetUrl(base.ShowGoodsAspxRewrite(goodsrateinfo.Goodsid));
                    SetMetaRefresh();
                    AddMsgLine("您的评价已经成功<br />(<a href=\"" + base.ShowGoodsAspxRewrite(goodsrateinfo.Goodsid) + "\">点击这里返回商品页面</a>)<br />");
                }
            }
        }