Example #1
0
        protected override void LoadPage(string themecode, int siteid, string languagecode, string pcode)
        {
            LoadTheme(themecode, siteid, languagecode, pcode);
            if (CurrentUser.id == 0)
            {
                Response.Write("<script type=\"text/javascript\">alert('" + Tag("已购买商品在已收货之后才可以发表评价") + "');window.location.href='" + URL("P_Login", "" + HttpUtility.UrlEncode(RequestTool.GetRequestUrlNonDomain()) + "") + "';</script>");
                Response.End();
                //Response.Redirect(URL("P_Login", "" + HttpUtility.UrlEncode(RequestTool.GetRequestUrlNonDomain()) + "," + GetUrlToken(RequestTool.GetRequestUrlNonDomain())+ ""));
            }
            path        = "<a href=\"" + URL("P_Index", "") + "\" class=\"home\" title=\"" + Tag("首页") + "\"><span>" + Tag("首页") + "</span></a><em class=\"home\">&raquo;</em><a href=\"" + URL("P_UserCenter", "") + "\"><span>" + Tag("会员中心") + "</span></a><em>&raquo;</em><a href=\"" + URL("P_UserComment", "1") + "\"><span>" + Tag("商品评价") + "</span></a><em>&raquo;</em><a href=\"" + URL("P_UserCommentWrite", "") + "\"><span>" + Tag("发表评价") + "</span></a>";
            CurrentPage = B_Lebi_Theme_Page.GetModel("Code='P_UserCommentWrite'");

            id = Rint("id");
            int pid = Rint("pid");

            if (pid > 0)
            {
                List <Lebi_Order_Product> Order_Products = B_Lebi_Order_Product.GetList("Product_id=" + pid + " and IsCommented = 0 and User_id=" + CurrentUser.id + "", "id desc");
                if (Order_Products.Count > 0)
                {
                    order_product = Order_Products.FirstOrDefault();
                    id            = order_product.id;
                }
            }
            order_product = B_Lebi_Order_Product.GetModel("id = " + id + " and IsCommented = 0 and User_id=" + CurrentUser.id + "");
            if (order_product == null)
            {
                Response.Write("<script type=\"text/javascript\">alert('" + Tag("已购买商品在已收货之后才可以发表评价") + "');location.href='" + URL("P_UserComment", "1", "") + "';</script>");
                Response.End();
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            int    orderid = RequestTool.RequestInt("orderid", 0);
            int    id      = RequestTool.RequestInt("id", 0);
            string pnumber = RequestTool.RequestString("pnumber").Trim();

            order        = B_Lebi_Order.GetModel("Supplier_id = " + CurrentSupplier.id + " and id = " + orderid);
            orderproduct = B_Lebi_Order_Product.GetModel("Supplier_id = " + CurrentSupplier.id + " and id = " + id);
            if (orderproduct == null)
            {
                product      = B_Lebi_Product.GetModel("Number=lbsql{'" + pnumber + "'} order by id desc");
                orderproduct = new Lebi_Order_Product();
            }
            else
            {
                product = B_Lebi_Product.GetModel(orderproduct.Product_id);
            }
            if (order == null || product == null)
            {
                Response.Write(Tag("参数错误"));
                Response.End();
                return;
            }
            //int pid = product.Product_id == 0 ? product.id : product.Product_id;
            if (product.Product_id > 0)
            {
                models = B_Lebi_Product.GetList("Product_id=" + product.Product_id + "", "");
            }
            else
            {
                models = new List <Lebi_Product>();
                models.Add(product);
            }
        }
Example #3
0
        /// <summary>
        /// 发表商品评价
        /// </summary>
        public void Comment_Write()
        {
            int id = RequestTool.RequestInt("id", 0);

            //int Product_id = 0;
            if (!Comment.CheckSafeWord(RequestTool.RequestSafeString("Content")))
            {
                Response.Write("{\"msg\":\"" + Tag("内容中包含敏感词") + "\"}");
                return;
            }
            Lebi_Order_Product Order_Product = B_Lebi_Order_Product.GetModel("User_id=" + CurrentUser.id + " and id = " + id);

            if (Order_Product == null)
            {
                Response.Write("{\"msg\":\"" + Tag("该商品已经下架") + "\"}");
                return;
            }
            else
            {
                Lebi_Order order = B_Lebi_Order.GetModel(Order_Product.Order_id);
                if (order == null)
                {
                    Response.Write("{\"msg\":\"" + Tag("无效订单") + "\"}");
                    return;
                }
                else
                {
                    if (order.IsReceived == 0)
                    {
                        Response.Write("{\"msg\":\"" + Tag("已购买商品在已收货之后才可以发表评价") + "\"}");
                        return;
                    }
                }
                Order_Product.IsCommented = 1;
                B_Lebi_Order_Product.Update(Order_Product);
            }
            Lebi_Product checkproduct = B_Lebi_Product.GetModel(Order_Product.Product_id);

            if (checkproduct == null)
            {
                Response.Write("{\"msg\":\"" + Tag("该商品已经下架") + "\"}");
                return;
            }
            Lebi_Comment model = new Lebi_Comment();

            model.TableName      = "Product";
            model.Keyid          = Order_Product.Product_id;
            model.Admin_UserName = "******";
            model.Admin_id       = 0;
            model.User_id        = CurrentUser.id;
            model.User_UserName  = CurrentUser.NickName;
            model.Content        = RequestTool.RequestSafeString("Content");
            model.Star           = RequestTool.RequestInt("Star", 5);
            model.Parentid       = 0;
            model.Status         = 280;
            model.Time_Add       = System.DateTime.Now;
            model.Language_Code  = CurrentLanguage.Code;
            model.Images         = RequestTool.RequestSafeString("Images");
            model.ImagesSmall    = RequestTool.RequestSafeString("ImagesSmall");
            model.Product_id     = Order_Product.Product_id;
            model.IsRead         = 1;
            model.Supplier_id    = checkproduct.Supplier_id;
            B_Lebi_Comment.Add(model);
            //List<Lebi_Order_Product> modelproducts = B_Lebi_Order_Product.GetList("User_id=" + CurrentUser.id + " and id = " + id + "", "");
            //foreach (Lebi_Order_Product modelproduct in modelproducts)
            //{
            //    modelproduct.IsCommented = 1;
            //    B_Lebi_Order_Product.Update(modelproduct);
            //}
            Lebi_Product product = B_Lebi_Product.GetModel(Order_Product.Product_id);

            if (product != null)
            {
                EX_Product.UpdateStar(product);
            }
            model.id = B_Lebi_Comment.GetMaxId();
            //处理图片
            ImageHelper.LebiImagesUsed(model.Images, "comment", model.id);
            //发送邮件
            Lebi_User user = B_Lebi_User.GetModel(CurrentUser.id);

            Email.SendEmail_comment(user, model);
            //发送短信
            SMS.SendSMS_comment(user, model);
            Response.Write("{\"msg\":\"OK\"}");
        }