Example #1
0
        /// <summary>
        /// 获取指定userid的店铺信息
        /// </summary>
        /// <param name="userid">用户id</param>
        /// <returns>店铺信息</returns>
        public static Shopinfo GetShopByUserId(int userId)
        {
            Shopinfo shopinfo = DTO.GetShopInfo(DbProvider.GetInstance().GetShopByUserId(userId));

            //当无该店铺时, 则创建该店铺
            if (shopinfo == null)
            {
                shopinfo                = new Shopinfo();
                shopinfo.Bulletin       = "";
                shopinfo.Createdatetime = DateTime.Now;
                shopinfo.Introduce      = "";
                shopinfo.Lid            = -1;
                shopinfo.Locus          = "";
                shopinfo.Logo           = "";
                shopinfo.Shopname       = "";
                shopinfo.Themeid        = 0;
                shopinfo.Themepath      = "";
                shopinfo.Uid            = userId;
                shopinfo.Username       = "";
                Shops.CreateShop(shopinfo);

                shopinfo = Shops.GetShopByUserId(userId);
            }
            return(shopinfo);
        }
Example #2
0
            /// <summary>
            /// 获得店铺信息(DTO)
            /// </summary>
            /// <param name="__idatareader">要转换的数据表</param>
            /// <returns>返回店铺信息</returns>
            public static Shopinfo[] GetShopInfoArray(DataTable dt)
            {
                if (dt == null || dt.Rows.Count == 0)
                {
                    return(null);
                }

                Shopinfo[] shopInfoArray = new Shopinfo[dt.Rows.Count];
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    shopInfoArray[i]                = new Shopinfo();
                    shopInfoArray[i].Shopid         = TypeConverter.ObjectToInt(dt.Rows[i]["shopid"]);
                    shopInfoArray[i].Logo           = dt.Rows[i]["logo"].ToString();
                    shopInfoArray[i].Shopname       = dt.Rows[i]["shopname"].ToString();
                    shopInfoArray[i].Themeid        = TypeConverter.ObjectToInt(dt.Rows[i]["themeid"]);
                    shopInfoArray[i].Themepath      = dt.Rows[i]["themepath"].ToString();
                    shopInfoArray[i].Uid            = TypeConverter.ObjectToInt(dt.Rows[i]["uid"]);
                    shopInfoArray[i].Username       = dt.Rows[i]["username"].ToString();
                    shopInfoArray[i].Introduce      = dt.Rows[i]["introduce"].ToString();
                    shopInfoArray[i].Lid            = TypeConverter.ObjectToInt(dt.Rows[i]["lid"]);
                    shopInfoArray[i].Locus          = dt.Rows[i]["locus"].ToString();
                    shopInfoArray[i].Bulletin       = dt.Rows[i]["bulletin"].ToString();
                    shopInfoArray[i].Createdatetime = Convert.ToDateTime(dt.Rows[i]["createdatetime"].ToString());
                    shopInfoArray[i].Invisible      = TypeConverter.ObjectToInt(dt.Rows[i]["invisible"]);
                    shopInfoArray[i].Viewcount      = TypeConverter.ObjectToInt(dt.Rows[i]["viewcount"]);
                }
                dt.Dispose();
                return(shopInfoArray);
            }
Example #3
0
            /// <summary>
            /// 获得店铺信息(DTO)
            /// </summary>
            /// <param name="__idatareader">要转换的数据</param>
            /// <returns>返回店铺信息</returns>
            public static Shopinfo GetShopInfo(IDataReader reader)
            {
                Shopinfo shopInfo = null;

                if (reader.Read())
                {
                    shopInfo                = new Shopinfo();
                    shopInfo.Shopid         = TypeConverter.ObjectToInt(reader["shopid"].ToString());
                    shopInfo.Logo           = reader["logo"].ToString().Trim();
                    shopInfo.Shopname       = reader["shopname"].ToString().Trim();
                    shopInfo.Themeid        = TypeConverter.ObjectToInt(reader["themeid"].ToString());
                    shopInfo.Themepath      = reader["themepath"].ToString().Trim();
                    shopInfo.Uid            = TypeConverter.ObjectToInt(reader["uid"].ToString());
                    shopInfo.Username       = reader["username"].ToString().Trim();
                    shopInfo.Introduce      = reader["introduce"].ToString().Trim();
                    shopInfo.Lid            = TypeConverter.ObjectToInt(reader["lid"].ToString());
                    shopInfo.Locus          = reader["locus"].ToString().Trim();
                    shopInfo.Bulletin       = reader["bulletin"].ToString().Trim();
                    shopInfo.Createdatetime = Convert.ToDateTime(reader["createdatetime"].ToString());
                    shopInfo.Invisible      = TypeConverter.ObjectToInt(reader["invisible"].ToString());
                    shopInfo.Viewcount      = TypeConverter.ObjectToInt(reader["viewcount"].ToString());

                    reader.Close();
                }
                return(shopInfo);
            }
Example #4
0
        protected override void ShowPage()
        {
            if (userid == -1)
            {
                AddErrLine("你尚未登录");
                return;
            }
            if (config.Enablemall < 2)
            {
                AddErrLine("当前操作只有在开启商城(高级)模式时才可以使用!");
                return;
            }

            user     = Users.GetUserInfo(userid);
            shopinfo = Shops.GetShopByUserId(user.Uid);

            if (DNTRequest.IsPost())
            {
                if (ForumUtils.IsCrossSitePost())
                {
                    AddErrLine("您的请求来路不正确,无法提交。如果您安装了某种默认屏蔽来路信息的个人防火墙软件(如 Norton Internet Security),请设置其不要禁止来路信息后再试。");
                    return;
                }

                shopinfo.Bulletin  = Utils.CutString(DNTRequest.GetString("bulletin"), 0, 500);
                shopinfo.Introduce = Utils.CutString(DNTRequest.GetString("introduce"), 0, 500);
                shopinfo.Uid       = userid;
                shopinfo.Username  = username;
                shopinfo.Shopname  = Utils.CutString(DNTRequest.GetString("shopname"), 0, 50);

                int lid = DNTRequest.GetInt("locus_2", 0);
                //当店铺所在地信息发生变化时
                if (shopinfo.Lid != lid && lid > 0)
                {
                    shopinfo.Lid   = lid;
                    shopinfo.Locus = Locations.GetLocusByLID(lid);
                }

                string uploadfileinfo = MallUtils.SaveRequestFile(1024000, "jpg\r\ngif\r\njpeg", config, "postfile").ToLower();
                //当店标发生变化时
                if (uploadfileinfo.EndsWith(".jpg") || uploadfileinfo.EndsWith(".gif"))
                {
                    if (Utils.FileExists(Utils.GetMapPath(BaseConfigs.GetForumPath + "upload/" + shopinfo.Logo)))
                    {
                        System.IO.File.Delete(Utils.GetMapPath(BaseConfigs.GetForumPath + "upload/" + shopinfo.Logo));
                    }

                    shopinfo.Logo = uploadfileinfo;
                }
                else if (!Utils.StrIsNullOrEmpty(uploadfileinfo))
                {
                    AddErrLine(uploadfileinfo);
                    return;
                }

                int themeid = DNTRequest.GetInt("themeid", 0);
                //当店铺主题发生变化时
                if (shopinfo.Themeid != themeid && themeid > 0)
                {
                    shopinfo.Themeid   = themeid;
                    shopinfo.Themepath = ShopThemes.GetShopThemeByThemeId(themeid).Directory;
                }

                Shops.UpdateShop(shopinfo);

                SetUrl("usercpshopconfig.aspx");
                SetMetaRefresh();
                AddMsgLine("操作成功. <br />(<a href=\"usercpshopconfig.aspx\">点击这里返回</a>)<br />");
            }
        }
Example #5
0
        public bool InitDatabase(Shopinfo shopinfo)
        {
            try
            {
                //创建商户信息表
                string sql = "CREATE TABLE `yg_local_shopinfo` (`shopid` VARCHAR( 24 ) NOT NULL primary key," +
                             "`shopname` VARCHAR( 30 ) NOT NULL ,`reserve1` VARCHAR( 100 ) DEFAULT NULL ,`reserve2` VARCHAR( 100 ) " +
                             "DEFAULT  NULL) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci; ";
                DBOperation dbo = new DBOperation();
                if (0 != dbo.AddDelUpdate(sql))
                {
                    this.DebugPrint("激活失败!errorcode : 1");
                    return(false);
                }

                //写入商户信息
                sql = string.Format("INSERT INTO yg_local_shopinfo (shopid,shopname) VALUES ('{0}','{1}')",
                                    shopinfo.shopId, shopinfo.shopRealname);
                if (1 != dbo.AddDelUpdate(sql))
                {
                    this.DebugPrint("激活失败!errorcode : 2");
                    return(false);
                }


                //创建图书信息表
                sql = "DROP TABLE IF EXISTS `yg_bookinfo`;";
                if (0 != dbo.AddDelUpdate(sql))
                {
                    this.DebugPrint("激活失败!errorcode : 3");
                    return(false);
                }
                sql = "CREATE TABLE `yg_bookinfo` (`id` int(10) unsigned NOT NULL AUTO_INCREMENT," +
                      "`gbookid` varchar(32) NOT NULL COMMENT '喵校园全局bookid',`name` varchar(255) NOT NULL COMMENT '书名'," +
                      "`author` varchar(255) DEFAULT NULL COMMENT '作者',`press` varchar(50) DEFAULT NULL COMMENT '出版社'," +
                      "`price` varchar(10) NOT NULL COMMENT '定价',`ISBN` varchar(15) NOT NULL COMMENT 'ISBN'," +
                      "`imgpath` varchar(100) DEFAULT NULL COMMENT '图片路径',PRIMARY KEY (`id`)) ENGINE=InnoDB " +
                      "AUTO_INCREMENT=1018 DEFAULT CHARSET=utf8;";
                if (0 != dbo.AddDelUpdate(sql))
                {
                    this.DebugPrint("激活失败!errorcode : 4");
                    return(false);
                }

                //创建新书库存表
                sql = "DROP TABLE IF EXISTS `yg_bookstock`;";
                if (0 != dbo.AddDelUpdate(sql))
                {
                    this.DebugPrint("激活失败!errorcode : 5");
                    return(false);
                }
                sql = "CREATE TABLE `yg_bookstock` (`bookid` int(11) NOT NULL,`count` int(11) NOT NULL," +
                      " PRIMARY KEY (`bookid`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;";
                if (0 != dbo.AddDelUpdate(sql))
                {
                    this.DebugPrint("激活失败!errorcode : 6");
                    return(false);
                }

                //创建进货渠道表
                sql = "DROP TABLE IF EXISTS `yg_jinhuoqudao`;";
                if (0 != dbo.AddDelUpdate(sql))
                {
                    this.DebugPrint("激活失败!errorcode : 7");
                    return(false);
                }
                sql = "CREATE TABLE `yg_jinhuoqudao` (`id` int(11) unsigned NOT NULL AUTO_INCREMENT," +
                      "`name` varchar(20) NOT NULL COMMENT '进货渠道名称', PRIMARY KEY (`id`)) ENGINE=InnoDB " +
                      "AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;";
                if (0 != dbo.AddDelUpdate(sql))
                {
                    this.DebugPrint("激活失败!errorcode : 8");
                    return(false);
                }


                //创建二手书详情表
                sql = "DROP TABLE IF EXISTS `yg_oldbookdetail`;";
                if (0 != dbo.AddDelUpdate(sql))
                {
                    this.DebugPrint("激活失败!errorcode : 9");
                    return(false);
                }
                sql = "CREATE TABLE `yg_oldbookdetail` (`guid` varchar(20) NOT NULL COMMENT '图书唯一编码'," +
                      "`bookid` varchar(10) NOT NULL,`status` varchar(1) NOT NULL DEFAULT '0' COMMENT '状态:0,未出售;1,已出售'," +
                      "`intime` varchar(20) NOT NULL COMMENT '入库时间',`outtime` varchar(20) DEFAULT NULL COMMENT '出售时间'," +
                      "`mallid` varchar(24) DEFAULT NULL,`price` float DEFAULT NULL,PRIMARY KEY (`guid`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;";
                if (0 != dbo.AddDelUpdate(sql))
                {
                    this.DebugPrint("激活失败!errorcode : 10");
                    return(false);
                }

                //创建订单信息表
                sql = "DROP TABLE IF EXISTS `yg_orderinfo`;";
                if (0 != dbo.AddDelUpdate(sql))
                {
                    this.DebugPrint("激活失败!errorcode : 11");
                    return(false);
                }
                sql = "CREATE TABLE `yg_orderinfo` (`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '序号'," +
                      "`datetime` varchar(30) NOT NULL COMMENT '时间',`jinhuoqudao` int(11) NOT NULL COMMENT '进货渠道ID'," +
                      "`name` varchar(40) DEFAULT NULL COMMENT '订单名称',`price` float NOT NULL,PRIMARY KEY (`id`)" +
                      ") ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8;";
                if (0 != dbo.AddDelUpdate(sql))
                {
                    this.DebugPrint("激活失败!errorcode : 12");
                    return(false);
                }

                //创建订单详情表
                sql = "DROP TABLE IF EXISTS `yg_orderdetail`;";
                if (0 != dbo.AddDelUpdate(sql))
                {
                    this.DebugPrint("激活失败!errorcode : 13");
                    return(false);
                }
                sql = "CREATE TABLE `yg_orderdetail` (`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '序号'," +
                      " `orderid` int(11) NOT NULL,`bookid` int(11) NOT NULL,`count` int(11) NOT NULL,`off` float NOT NULL " +
                      "COMMENT '折扣',PRIMARY KEY (`id`)) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=utf8;";
                if (0 != dbo.AddDelUpdate(sql))
                {
                    this.DebugPrint("激活失败!errorcode : 14");
                    return(false);
                }

                //创建财务出账表
                sql = "DROP TABLE IF EXISTS `yg_outbookmoney`;";
                if (0 != dbo.AddDelUpdate(sql))
                {
                    this.DebugPrint("激活失败!errorcode : 15");
                    return(false);
                }
                sql = "CREATE TABLE `yg_outbookmoney` (`id` int(10) unsigned NOT NULL AUTO_INCREMENT,`outtime` varchar(15) NOT NULL," +
                      "`price` float NOT NULL,PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;";
                if (0 != dbo.AddDelUpdate(sql))
                {
                    this.DebugPrint("激活失败!errorcode : 16");
                    return(false);
                }


                //创建根据ID获取订单详情的视图VIEW
                sql = "DROP VIEW IF EXISTS `oldbooksellinfo`;";
                if (0 != dbo.AddDelUpdate(sql))
                {
                    this.DebugPrint("激活失败!errorcode : 17");
                    return(false);
                }
                sql = "CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `oldbooksellinfo`" +
                      " AS select `yg_oldbookdetail`.`guid` AS `id`,`yg_bookinfo`.`gbookid` AS `gbookid`,`yg_bookinfo`.`id` " +
                      "AS `lbookid`,`yg_bookinfo`.`name` AS `name`,`yg_bookinfo`.`author` AS `author`,`yg_bookinfo`.`press` " +
                      "AS `press`,`yg_bookinfo`.`price` AS `price`,`yg_bookinfo`.`ISBN` AS `ISBN`,`yg_bookinfo`.`imgpath` AS " +
                      "`imgpath`,`yg_oldbookdetail`.`status` AS `status`,`yg_oldbookdetail`.`intime` AS `intime`," +
                      "`yg_oldbookdetail`.`outtime` AS `outtime`,`yg_oldbookdetail`.`mallid` AS `mallid` from (`yg_bookinfo` " +
                      "join `yg_oldbookdetail`) where (`yg_bookinfo`.`id` = `yg_oldbookdetail`.`bookid`) ;";
                if (0 != dbo.AddDelUpdate(sql))
                {
                    this.DebugPrint("激活失败!errorcode : 18");
                    return(false);
                }
                return(true);
            }
            catch (Exception ex)
            {
                this.DebugPrint("激活失败!errorcode : " + ex.Message);
                return(false);
            }
        }
        protected override void ShowPage()
        {
            if (userid == -1)
            {
                AddErrLine("你尚未登录");
                return;
            }
            if (config.Enablemall < 2)
            {
                AddErrLine("当前操作只有在开启商城(高级)模式时才可以使用!");
                return;
            }

            user     = Users.GetUserInfo(userid);
            shopinfo = Shops.GetShopByUserId(user.Uid);

            if (!DNTRequest.IsPost())
            {
                shopcategorydt       = ShopCategories.GetShopCategoryTable(shopinfo.Shopid);
                shopcategorydt_count = shopcategorydt.Rows.Count;
                shopcategorydata     = ShopCategories.GetShopCategoryJson(shopcategorydt);
                categoryoptions      = ShopCategories.GetShopCategoryOption(shopcategorydt, false);
            }
            else
            {
                if (ForumUtils.IsCrossSitePost())
                {
                    AddErrLine("您的请求来路不正确,无法提交。如果您安装了某种默认屏蔽来路信息的个人防火墙软件(如 Norton Internet Security),请设置其不要禁止来路信息后再试。");
                    return;
                }
                string operation = DNTRequest.GetFormString("operation");
                if (operation != "add")
                {
                    int shopcategoryid = DNTRequest.GetFormInt("categoryid", 0);
                    if (shopcategoryid <= 0)
                    {
                        AddErrLine("店铺商品分类参数无效<br />");
                        return;
                    }

                    shopcategoryinfo = ShopCategories.GetShopCategoryByCategoryId(shopcategoryid);
                }

                shopid = 0;
                item   = DNTRequest.GetString("item");

                switch (operation)
                {
                case "delete":     //删除分类
                {
                    if (shopcategoryinfo == null || shopcategoryinfo.Categoryid <= 0)
                    {
                        AddErrLine("要删除的店铺商品分类参数无效<br />");
                        return;
                    }
                    if (!ShopCategories.DeleteCategoryByCategoryId(shopcategoryinfo))
                    {
                        AddErrLine("对不起,当前节点下面还有子结点,因此不能删除<br />");
                        return;
                    }
                    break;
                }

                case "edit":     //编辑分类名称
                {
                    if (shopcategoryinfo == null || shopcategoryinfo.Categoryid <= 0)
                    {
                        AddErrLine("要修改的店铺商品分类参数无效<br />");
                        return;
                    }
                    string editname = DNTRequest.GetString("editcategoryname");
                    if (editname == "")
                    {
                        AddErrLine("店铺商品分类名称未变更或不能为空<br />");
                        return;
                    }
                    shopcategoryinfo.Name = editname;
                    ShopCategories.UpdateShopCategory(shopcategoryinfo);
                    break;
                }

                case "add":     //添加分类
                {
                    shopcategoryinfo        = new Shopcategoryinfo();
                    shopcategoryinfo.Name   = DNTRequest.GetFormString("addcategoryname");
                    shopcategoryinfo.Shopid = shopinfo.Shopid;

                    int addtype = DNTRequest.GetInt("addtype", 0);
                    if (addtype > 0 && addtype <= 2)
                    {
                        int targetcategoryid = DNTRequest.GetFormInt("selectcategoryid", 0);

                        if (targetcategoryid <= 0)
                        {
                            AddErrLine("要添加到的目标分类参数无效<br />");
                            return;
                        }

                        targetshopcategoryinfo = ShopCategories.GetShopCategoryByCategoryId(targetcategoryid);
                        if (targetshopcategoryinfo == null || targetshopcategoryinfo.Categoryid <= 0)
                        {
                            AddErrLine("要添加到的目标分类参数无效<br />");
                            return;
                        }
                    }

                    ShopCategories.CreateShopCategory(shopcategoryinfo, targetshopcategoryinfo, addtype);
                    break;
                }

                case "move":     //移动分类
                {
                    int targetcategoryid = DNTRequest.GetFormInt("targetcategoryid", 0);

                    if (targetcategoryid <= 0)
                    {
                        AddErrLine("要移动到的目标分类参数无效<br />");
                        return;
                    }

                    targetshopcategoryinfo = ShopCategories.GetShopCategoryByCategoryId(targetcategoryid);
                    if (targetshopcategoryinfo == null || targetshopcategoryinfo.Categoryid <= 0)
                    {
                        AddErrLine("要移动到的目标分类参数无效<br />");
                        return;
                    }
                    string target_parentidlist = "," + targetshopcategoryinfo.Parentidlist.Trim() + ",";
                    if (target_parentidlist.IndexOf("," + shopcategoryinfo.Categoryid.ToString() + ",") > 0)
                    {
                        AddErrLine("不能将当前分类移动到其子分类<br />");
                        return;
                    }
                    ShopCategories.MoveShopCategory(shopcategoryinfo, targetshopcategoryinfo, DNTRequest.GetInt("isaschildnode", 0) == 1 ? true : false);
                    break;
                }
                }

                SetUrl("usercpshopcategory.aspx?item=" + item);
                SetMetaRefresh();
                AddMsgLine("操作成功. <br />(<a href=\"usercpmygoods.aspx?item=" + item + "\">点击这里返回</a>)<br />");
            }
        }
        protected override void ShowPage()
        {
            if (userid == -1)
            {
                AddErrLine("你尚未登录");
                return;
            }

            if (config.Enablemall < 2)
            {
                AddErrLine("当前操作只有在开启商城(高级)模式时才可以使用!");
                return;
            }

            user = Users.GetUserInfo(userid);

            if (item == "")
            {
                item = "shopcategory";
            }

            if (item == "recommend")
            {
                recommendgoodslist = Goods.GetGoodsRecommendManageList(userid, 6, 1, "");
            }

            reccount = (shopgoodscategoryid <= 0) ? Goods.GetGoodsCountBySellerUid(userid, true) : Goods.GetGoodsCountByShopCategory(shopgoodscategoryid, "");

            // 得到分页大小设置
            int pagesize = 10;

            //修正请求页数中可能的错误
            if (pageid < 1)
            {
                pageid = 1;
            }

            //获取总页数
            pagecount = reccount % pagesize == 0 ? reccount / pagesize : reccount / pagesize + 1;
            if (pagecount == 0)
            {
                pagecount = 1;
            }

            if (pageid > pagecount)
            {
                pageid = pagecount;
            }

            shopinfo = Shops.GetShopByUserId(user.Uid);
            //如果不是提交...
            if (!ispost)
            {
                if (shopgoodscategoryid <= 0)
                {
                    goodslist = Goods.GetGoodsListBySellerUID(userid, true, pagesize, pageid, "lastupdate", 1);
                }
                else
                {
                    goodslist = Goods.GetGoodsInfoListByShopCategory(shopgoodscategoryid, pagesize, pageid, "", "lastupdate", 1);
                }

                pagenumbers          = Utils.GetPageNumbers(pageid, pagecount, "usercpshopgoodsmanage.aspx?item=" + item + "&shopgoodscategoryid=" + shopgoodscategoryid, 8);
                shopcategorydt       = ShopCategories.GetShopCategoryTable(shopinfo.Shopid);
                shopcategorydt_count = shopcategorydt.Rows.Count;
                shopcategorydata     = ShopCategories.GetShopCategoryJson(shopcategorydt);
                categoryoptions      = ShopCategories.GetShopCategoryOption(shopcategorydt, true);
            }
            else
            {
                string operation = DNTRequest.GetString("operation");

                if (operation == "")
                {
                    operation = "movecategory";
                }

                switch (operation)
                {
                case "movecategory":     //移动到商品分类
                {
                    if (goodsidlist == "")
                    {
                        AddErrLine("你未选中任何商品");
                        return;
                    }

                    int selectcategoryid = DNTRequest.GetInt("selectcategoryid", 0);
                    if (selectcategoryid <= 0)
                    {
                        AddErrLine("你未选择要移动到的商品分类");
                        return;
                    }
                    if (Goods.IsSeller(goodsidlist, userid))
                    {
                        if (Goods.MoveGoodsShopCategory(goodsidlist, selectcategoryid) > 0)
                        {
                            SetUrl("usercpshopgoodsmanage.aspx?item=" + item + "&shopgoodscategoryid=" + shopgoodscategoryid);
                            SetMetaRefresh();
                            AddMsgLine("操作成功. <br />(<a href=\"usercpshopgoodsmanage.aspx?item=" + item + "&shopgoodscategoryid=" + shopgoodscategoryid + "\">点击这里返回</a>)<br />");
                        }
                        else
                        {
                            AddErrLine("商品参数信息无效或所选商品已在该分类下");
                            return;
                        }
                    }
                    else
                    {
                        AddErrLine("你不是当前商品的卖家,因此无法移动该商品到指定的分类");
                        return;
                    }
                    break;
                }

                case "removecategory":     //移除商品分类
                {
                    int removeshopgoodscategoryid = DNTRequest.GetInt("removeshopgoodscategoryid", 0);

                    int removegoodsid = DNTRequest.GetInt("removegoodsid", 0);

                    if (removeshopgoodscategoryid <= 0 || removegoodsid <= 0)
                    {
                        AddErrLine("移除分类信息错误");
                        return;
                    }

                    if (Goods.IsSeller(removegoodsid.ToString(), userid))
                    {
                        if (Goods.RemoveGoodsShopCategory(removegoodsid, removeshopgoodscategoryid) > 0)
                        {
                            SetUrl("usercpshopgoodsmanage.aspx?item=" + item + "&shopgoodscategoryid=" + shopgoodscategoryid);
                            SetMetaRefresh();
                            AddMsgLine("操作成功. <br />(<a href=\"usercpshopgoodsmanage.aspx?item=" + item + "&shopgoodscategoryid=" + shopgoodscategoryid + "\">点击这里返回</a>)<br />");
                        }
                        else
                        {
                            AddErrLine("商品参数信息无效或所选商品已在该分类下");
                            return;
                        }
                    }
                    else
                    {
                        AddErrLine("您不是当前商品的卖家,因此无法移除该商品的分类");
                        return;
                    }
                    break;
                }

                case "recommend":     //推荐商品
                {
                    if (goodsidlist == "")
                    {
                        AddErrLine("您未选中任何商品");
                        return;
                    }
                    if ((recommendgoodslist.Count + goodsidlist.Split(',').Length) > 5)
                    {
                        AddErrLine("您推荐的商品总数已大于5, 因为无法进行推荐");
                        return;
                    }

                    if (Goods.IsSeller(goodsidlist, userid))
                    {
                        Goods.RecommendGoods(goodsidlist);
                        SetUrl("usercpshopgoodsmanage.aspx?item=" + item + "&shopgoodscategoryid=" + shopgoodscategoryid);
                        SetMetaRefresh();
                        AddMsgLine("操作成功. <br />(<a href=\"usercpshopgoodsmanage.aspx?item=" + item + "&shopgoodscategoryid=" + shopgoodscategoryid + "\">点击这里返回</a>)<br />");
                    }
                    else
                    {
                        AddErrLine("您不是当前商品的卖家,因此无法推荐该商品");
                        return;
                    }
                    break;
                }

                case "cancelrecommend":     //取消推荐商品
                {
                    goodsidlist = DNTRequest.GetString("cancelrecommendgoodsid");
                    if (goodsidlist == "")
                    {
                        AddErrLine("您未选中任何商品");
                        return;
                    }

                    if (Goods.IsSeller(goodsidlist, userid))
                    {
                        Goods.CancelRecommendGoods(goodsidlist);
                        SetUrl("usercpshopgoodsmanage.aspx?item=" + item + "&shopgoodscategoryid=" + shopgoodscategoryid);
                        SetMetaRefresh();
                        AddMsgLine("操作成功. <br />(<a href=\"usercpshopgoodsmanage.aspx?item=" + item + "&shopgoodscategoryid=" + shopgoodscategoryid + "\">点击这里返回</a>)<br />");
                    }
                    else
                    {
                        AddErrLine("你不是当前商品的卖家,因此无法取消推荐该商品");
                        return;
                    }
                    break;
                }

                case "updatedisplayorder":     //更新商品显示顺序
                {
                    foreach (Goodsinfo goodsinfo in recommendgoodslist)
                    {
                        //当显示顺序值发生变化时,则更新相应的商品信息
                        if (goodsinfo.Displayorder != DNTRequest.GetInt("displayorder_" + goodsinfo.Goodsid, 0))
                        {
                            goodsinfo.Displayorder = DNTRequest.GetInt("displayorder_" + goodsinfo.Goodsid, 0);
                            Goods.UpdateGoods(goodsinfo);
                        }
                    }

                    SetUrl("usercpshopgoodsmanage.aspx?item=" + item + "&shopgoodscategoryid=" + shopgoodscategoryid);
                    SetMetaRefresh();
                    AddMsgLine("操作成功. <br />(<a href=\"usercpshopgoodsmanage.aspx?item=" + item + "&shopgoodscategoryid=" + shopgoodscategoryid + "\">点击这里返回</a>)<br />");
                    break;
                }
                }
            }
        }
Example #8
0
        protected override void ShowPage()
        {
            if (userid == -1)
            {
                AddErrLine("你尚未登录");
                return;
            }

            if (config.Enablemall < 2)
            {
                AddErrLine("当前操作只有在开启商城(高级)模式时才可以使用!");
                return;
            }

            user = Users.GetUserInfo(userid);

            shopinfo = Shops.GetShopByUserId(user.Uid);

            shoplinkinfolist = ShopLinks.GetShopLinkByShopId(shopinfo.Shopid);
            //如果不是提交...
            if (ispost)
            {
                string operation = DNTRequest.GetString("operation");

                if (operation == "")
                {
                    operation = "add";
                }

                switch (operation)
                {
                case "add":     //添加店铺友情链接
                {
                    if (shoplinkinfolist.Count >= 16)
                    {
                        AddErrLine("目前系统允许您最多添加 20 个友情链接");
                        return;
                    }

                    string addusername = DNTRequest.GetString("username");
                    if (addusername == "")
                    {
                        AddErrLine("请输入店主姓名!");
                        return;
                    }

                    int adduserid = Users.GetUserId(addusername);
                    if (adduserid < 0)
                    {
                        AddErrLine("用户名不存在!");
                        return;
                    }
                    if (adduserid == userid)
                    {
                        AddErrLine("店主不能将本人店铺作为友情链接!");
                        return;
                    }

                    Shopinfo add_shopinfo = Shops.GetShopByUserId(Users.GetUserId(addusername));
                    if (add_shopinfo == null && add_shopinfo.Shopid <= 0)
                    {
                        AddErrLine("用户:" + addusername + " 未在本站开店,因此无法添加该友情链接");
                        return;
                    }

                    Shoplinkinfo shoplinkinfo = new Shoplinkinfo();
                    shoplinkinfo.Displayorder = 0;
                    shoplinkinfo.Name         = add_shopinfo.Shopname;
                    shoplinkinfo.Linkshopid   = add_shopinfo.Shopid;
                    shoplinkinfo.Shopid       = shopinfo.Shopid;
                    ShopLinks.CreateShopLink(shoplinkinfo);
                    break;
                }

                case "delete":     //删除店铺友情链接
                {
                    string delshoplink = DNTRequest.GetString("shoplinkid");
                    if (delshoplink == "")
                    {
                        AddErrLine("您未选中友情链接");
                        return;
                    }
                    ShopLinks.DeleteShopLink(delshoplink);
                    break;
                }

                case "updatedisplayorder":     //更新店铺友情链接显示顺序
                {
                    foreach (Shoplinkinfo shoplinkinfo in shoplinkinfolist)
                    {
                        //当显示顺序值发生变化时,则更新相应的信息
                        if (shoplinkinfo.Displayorder != DNTRequest.GetInt("displayorder_" + shoplinkinfo.Id, 0))
                        {
                            shoplinkinfo.Displayorder = DNTRequest.GetInt("displayorder_" + shoplinkinfo.Id, 0);
                            ShopLinks.UpdateShopLink(shoplinkinfo);
                        }
                    }
                    break;
                }
                }

                SetUrl("usercpshoplink.aspx");
                SetMetaRefresh();
                AddMsgLine("操作成功. <br />(<a href=\"usercpshoplink.aspx\">点击这里返回</a>)<br />");
            }
        }
Example #9
0
        protected override void ShowPage()
        {
            if (config.Enablemall == 0) //未启用交易模式
            {
                AddErrLine("系统未开启交易模式, 当前页面暂时无法访问!");
                return;
            }

            #region 临时帐号发帖
            //int realuserid = -1;
            //string tempusername = DNTRequest.GetString("tempusername");
            //if (tempusername != "" && tempusername != username)
            //{
            //    string temppassword = DNTRequest.GetString("temppassword");
            //    int question = DNTRequest.GetInt("question", 0);
            //    string answer = DNTRequest.GetString("answer");
            //    realuserid = Users.CheckTempUserInfo(tempusername, temppassword, question, answer);
            //    if (realuserid == -1)
            //    {
            //        AddErrLine("临时帐号登录失败,无法继续发帖。");
            //        return;
            //    }
            //    else
            //    {
            //        userid = realuserid;
            //        username = tempusername;
            //        usergroupinfo = UserGroups.GetUserGroupInfo(Users.GetShortUserInfo(userid).Groupid);
            //        usergroupid = usergroupinfo.Groupid;
            //        useradminid = Users.GetShortUserInfo(userid).Adminid;
            //    }
            //}
            #endregion

            #region 获取分类对象信息
            int categoryid = DNTRequest.GetInt("categoryid", -1);

            //如果是提交...
            if (ispost)
            {
                categoryid = DNTRequest.GetInt("goodscategoryid", -1);
            }

            if (categoryid > 0)
            {
                goodscategoryinfo = GoodsCategories.GetGoodsCategoryInfoById(categoryid);
            }

            if (goodscategoryinfo == null)
            {
                goodscategoryinfo            = new Goodscategoryinfo();
                goodscategoryinfo.Categoryid = -1;
            }

            if (goodscategoryinfo.Fid <= 0)
            {
                allowpostgoods = false;
                forumnav       = "";
                AddErrLine("错误的商品分类ID");
                return;
            }
            #endregion

            canhtmltitle     = config.Htmltitle == 1 && Utils.InArray(usergroupid.ToString(), config.Htmltitleusergroup);
            firstpagesmilies = Caches.GetSmiliesFirstPageCache();

            //内容设置为空;
            message = "";

            if (config.Enablemall == 1) //开启普通模式
            {
                forumid  = GoodsCategories.GetCategoriesFid(categoryid);
                forumnav = "";
                if (forumid == -1)
                {
                    allowpostgoods = false;
                    AddErrLine("错误的商品分类ID");
                    return;
                }
                else
                {
                    forum = Forums.GetForumInfo(forumid);
                    if (forum == null || forum.Layer == 0)
                    {
                        allowpostgoods = false;
                        AddErrLine("错误的商品分类ID");
                        return;
                    }

                    if (forum.Istrade <= 0)
                    {
                        allowpostgoods = false;
                        AddErrLine("当前版块不允许发布商品");
                        return;
                    }

                    forumname = forum.Name;
                    pagetitle = Utils.RemoveHtml(forum.Name);
                    forumnav  = ForumUtils.UpdatePathListExtname(forum.Pathlist.Trim(), config.Extname);
                    enabletag = (config.Enabletag & forum.Allowtag) == 1;
                }
            }
            else if (config.Enablemall == 2) //当为高级模式时
            {
                pagetitle          = "发布商品";
                forumnav           = "";
                enabletag          = true;
                forum              = new ForumInfo();
                forum.Allowsmilies = 1;
                forum.Allowbbcode  = 1;
            }

            //得到用户可以上传的文件类型
            StringBuilder sbAttachmentTypeSelect = new StringBuilder();
            if (!usergroupinfo.Attachextensions.Trim().Equals(""))
            {
                sbAttachmentTypeSelect.Append("[id] in (");
                sbAttachmentTypeSelect.Append(usergroupinfo.Attachextensions);
                sbAttachmentTypeSelect.Append(")");
            }
            if (config.Enablemall == 1) //开启普通模式
            {
                if (!forum.Attachextensions.Equals(""))
                {
                    if (sbAttachmentTypeSelect.Length > 0)
                    {
                        sbAttachmentTypeSelect.Append(" AND ");
                    }
                    sbAttachmentTypeSelect.Append("[id] in (");
                    sbAttachmentTypeSelect.Append(forum.Attachextensions);
                    sbAttachmentTypeSelect.Append(")");
                }
            }
            attachextensions       = Attachments.GetAttachmentTypeArray(sbAttachmentTypeSelect.ToString());
            attachextensionsnosize = Attachments.GetAttachmentTypeString(sbAttachmentTypeSelect.ToString());

            //得到今天允许用户上传的附件总大小(字节)
            int MaxTodaySize = 0;
            if (userid > 0)
            {
                MaxTodaySize = Attachments.GetUploadFileSizeByuserid(userid); //今天已上传大小
            }
            attachsize = usergroupinfo.Maxsizeperday - MaxTodaySize;          //今天可上传得大小

            parseurloff = 0;
            bbcodeoff   = 1;

            if (config.Enablemall == 1) //开启普通模式
            {
                smileyoff = 1 - forum.Allowsmilies;
                allowimg  = forum.Allowimgcode;

                if (forum.Allowbbcode == 1 && usergroupinfo.Allowcusbbcode == 1)
                {
                    bbcodeoff = 0;
                }
            }


            // 如果当前用户非管理员并且论坛设定了禁止发布商品时间段,当前时间如果在其中的一个时间段内,不允许用户发布商品
            if (useradminid != 1 && usergroupinfo.Disableperiodctrl != 1)
            {
                string visittime = "";
                if (Scoresets.BetweenTime(config.Postbanperiods, out visittime))
                {
                    AddErrLine("在此时间段( " + visittime + " )内用户不可以发布商品");
                    return;
                }
            }

            if (config.Enablemall == 1) //开启普通模式
            {
                if (forum.Password != "" && Utils.MD5(forum.Password) != ForumUtils.GetCookie("forum" + forumid.ToString() + "password"))
                {
                    AddErrLine("本版块被管理员设置了密码");
                    SetBackLink(base.ShowForumAspxRewrite(forumid, 0));
                    return;
                }

                if (!Forums.AllowViewByUserId(forum.Permuserlist, userid))        //判断当前用户在当前版块浏览权限
                {
                    if (forum.Viewperm == null || forum.Viewperm == string.Empty) //当板块权限为空时,按照用户组权限
                    {
                        if (useradminid != 1 && (usergroupinfo.Allowvisit != 1 || usergroupinfo.Allowtrade != 1))
                        {
                            AddErrLine("您当前的身份 \"" + usergroupinfo.Grouptitle + "\" 没有发布商品的权限");
                            return;
                        }
                    }
                    else//当板块权限不为空,按照板块权限
                    {
                        if (!Forums.AllowView(forum.Viewperm, usergroupid))
                        {
                            AddErrLine("您没有发布商品的权限");
                            return;
                        }
                    }
                }

                if (!Forums.AllowPostByUserID(forum.Permuserlist, userid))        //判断当前用户在当前版块发布商品权限
                {
                    if (forum.Postperm == null || forum.Postperm == string.Empty) //权限设置为空时,根据用户组权限判断
                    {
                        // 验证用户是否有发布商品的权限
                        if (useradminid != 1 && usergroupinfo.Allowtrade != 1)
                        {
                            AddErrLine("您当前的身份 \"" + usergroupinfo.Grouptitle + "\" 没有发布商品的权限");
                            return;
                        }
                    }
                    else//权限设置不为空时,根据板块权限判断
                    {
                        if (!Forums.AllowPost(forum.Postperm, usergroupid))
                        {
                            AddErrLine("您没有发布商品的权限");
                            return;
                        }
                    }
                }

                //是否有上传附件的权限
                if (Forums.AllowPostAttachByUserID(forum.Permuserlist, userid))
                {
                    canpostattach = true;
                }
                else
                {
                    if (forum.Postattachperm == "")
                    {
                        if (usergroupinfo.Allowpostattach == 1)
                        {
                            canpostattach = true;
                        }
                    }
                    else
                    {
                        if (Forums.AllowPostAttach(forum.Postattachperm, usergroupid))
                        {
                            canpostattach = true;
                        }
                    }
                }
            }
            else if (config.Enablemall == 2) //当为高级模式时
            {
                canpostattach = true;
                allowimg      = 1;
                smileyoff     = 0;
            }


            ShortUserInfo user = Users.GetShortUserInfo(userid);
            if (canpostattach && user != null && apb != null && config.Enablealbum == 1 &&
                (UserGroups.GetUserGroupInfo(user.Groupid).Maxspacephotosize - apb.GetPhotoSizeByUserid(userid) > 0))
            {
                caninsertalbum = true;
                albumlist      = apb.GetSpaceAlbumByUserId(userid);
            }
            else
            {
                caninsertalbum = false;
            }

            // 如果是受灌水限制用户, 则判断是否是灌水
            AdminGroupInfo admininfo = AdminGroups.GetAdminGroupInfo(usergroupid);
            disablepost = 0;
            if (admininfo != null)
            {
                disablepost = admininfo.Disablepostctrl;
            }

            if (admininfo == null || admininfo.Disablepostctrl != 1)
            {
                int Interval = Utils.StrDateDiffSeconds(lastposttime, config.Postinterval);
                if (Interval < 0)
                {
                    AddErrLine("系统规定发布商品间隔为" + config.Postinterval.ToString() + "秒, 您还需要等待 " + (Interval * -1).ToString() + " 秒");
                    return;
                }
                else if (userid != -1)
                {
                    ShortUserInfo shortUserInfo = Discuz.Data.Users.GetShortUserInfo(userid);
                    string        joindate      = (shortUserInfo != null) ? shortUserInfo.Joindate : "";
                    if (joindate == "")
                    {
                        AddErrLine("您的用户资料出现错误");
                        return;
                    }

                    Interval = Utils.StrDateDiffMinutes(joindate, config.Newbiespan);
                    if (Interval < 0)
                    {
                        AddErrLine("系统规定新注册用户必须要在" + config.Newbiespan.ToString() + "分钟后才可以发布商品, 您还需要等待 " + (Interval * -1).ToString() + " 分");
                        return;
                    }
                }
            }

            creditstrans       = Scoresets.GetCreditsTrans();
            userextcreditsinfo = Scoresets.GetScoreSet(creditstrans);

            if (userid > 0)
            {
                spaceid = Users.GetShortUserInfo(userid).Spaceid;
            }

            //如果不是提交...
            if (!ispost)
            {
                AddLinkCss(BaseConfigs.GetForumPath + "templates/" + templatepath + "/editor.css", "css");
                smilies           = Caches.GetSmiliesCache();
                smilietypes       = Caches.GetSmilieTypesCache();
                customeditbuttons = Caches.GetCustomEditButtonList();
            }
            else
            {
                SetBackLink(string.Format("postgoods.aspx?categoryid={0}&restore=1", categoryid));

                string postmessage = DNTRequest.GetString("message");

                ForumUtils.WriteCookie("postmessage", postmessage);

                if (ForumUtils.IsCrossSitePost())
                {
                    AddErrLine("您的请求来路不正确,无法提交。如果您安装了某种默认屏蔽来路信息的个人防火墙软件(如 Norton Internet Security),请设置其不要禁止来路信息后再试。");
                    return;
                }

                if (DNTRequest.GetString("title").Trim().Equals(""))
                {
                    AddErrLine("商品标题不能为空");
                }
                else if (DNTRequest.GetString("title").IndexOf(" ") != -1)
                {
                    AddErrLine("商品标题不能包含全角空格符");
                }
                else if (DNTRequest.GetString("title").Length > 60)
                {
                    AddErrLine("商品标题最大长度为60个字符,当前为 " + DNTRequest.GetString("title").Length + " 个字符");
                }

                if (postmessage.Equals("") || postmessage.Replace(" ", "").Equals(""))
                {
                    AddErrLine("商品内容不能为空");
                }

                if (admininfo != null && admininfo.Disablepostctrl != 1)
                {
                    if (postmessage.Length < config.Minpostsize)
                    {
                        AddErrLine("您发表的内容过少, 系统设置要求商品内容不得少于 " + config.Minpostsize + " 字多于 " + config.Maxpostsize + " 字");
                    }
                    else if (postmessage.Length > config.Maxpostsize)
                    {
                        AddErrLine("您发表的内容过多, 系统设置要求商品内容不得少于 " + config.Minpostsize + " 字多于 " + config.Maxpostsize + " 字");
                    }
                }

                //新用户广告强力屏蔽检查
                if (config.Disablepostad == 1 || userid == -1)  //如果开启新用户广告强力屏蔽检查或是游客
                {
                    if (userid == -1 || (config.Disablepostadpostcount != 0 && user.Posts <= config.Disablepostadpostcount) ||
                        (config.Disablepostadregminute != 0 && DateTime.Now.AddMinutes(-config.Disablepostadregminute) <= Convert.ToDateTime(user.Joindate)))
                    {
                        foreach (string regular in config.Disablepostadregular.Replace("\r", "").Split('\n'))
                        {
                            if (Posts.IsAD(regular, DNTRequest.GetString("title"), postmessage))
                            {
                                AddErrLine("发布商品失败,商品内容中似乎有广告信息,请检查标题和内容,如有疑问请与管理员联系");
                                return;
                            }
                        }
                    }
                }

                if (IsErr())
                {
                    return;
                }

                // 如果用户上传了附件,则检测用户是否有上传附件的权限
                if (ForumUtils.IsPostFile())
                {
                    if (Attachments.GetAttachmentTypeArray(sbAttachmentTypeSelect.ToString()).Trim() == "")
                    {
                        AddErrLine("系统不允许上传附件");
                    }

                    if (config.Enablemall == 1) //开启普通模式
                    {
                        if (!Forums.AllowPostAttachByUserID(forum.Permuserlist, userid))
                        {
                            if (!Forums.AllowPostAttach(forum.Postattachperm, usergroupid))
                            {
                                AddErrLine("您没有在该版块上传附件的权限");
                            }
                            else if (usergroupinfo.Allowpostattach != 1)
                            {
                                AddErrLine(string.Format("您当前的身份 \"{0}\" 没有上传附件的权限", usergroupinfo.Grouptitle));
                            }
                        }
                    }
                }

                if (IsErr())
                {
                    return;
                }

                int iconid = DNTRequest.GetInt("iconid", 0);
                if (iconid > 15 || iconid < 0)
                {
                    iconid = 0;
                }

                string curdatetime = Utils.GetDateTime();

                Goodsinfo goodsinfo = new Goodsinfo();

                //当在高级模式下则绑定相应店铺信息
                if (config.Enablemall == 2)
                {
                    Shopinfo shopinfo = Shops.GetShopByUserId(user.Uid);
                    if (shopinfo != null)
                    {
                        goodsinfo.Shopid = shopinfo.Shopid;
                    }
                }
                goodsinfo.Categoryid         = goodscategoryinfo.Categoryid;
                goodsinfo.Parentcategorylist = goodscategoryinfo.Parentidlist;
                goodsinfo.Recommend          = DNTRequest.GetString("recommend") == "on" ? 1 : 0;
                goodsinfo.Discount           = DNTRequest.GetInt("discount", 0);
                goodsinfo.Selleruid          = userid;
                goodsinfo.Seller             = username;
                goodsinfo.Account            = DNTRequest.GetString("account");
                goodsinfo.Price     = Convert.ToDecimal(DNTRequest.GetFormFloat("price", 1).ToString());
                goodsinfo.Amount    = DNTRequest.GetInt("amount", 0);
                goodsinfo.Quality   = DNTRequest.GetInt("quality", 0);
                goodsinfo.Lid       = DNTRequest.GetInt("locus_2", 0);
                goodsinfo.Locus     = Locations.GetLocusByLID(goodsinfo.Lid);
                goodsinfo.Transport = DNTRequest.GetInt("transport", 0);
                if (goodsinfo.Transport != 0)
                {
                    goodsinfo.Ordinaryfee = Convert.ToDecimal(DNTRequest.GetFormFloat("postage_mail", 0).ToString());
                    goodsinfo.Expressfee  = Convert.ToDecimal(DNTRequest.GetFormFloat("postage_express", 0).ToString());
                    goodsinfo.Emsfee      = Convert.ToDecimal(DNTRequest.GetFormFloat("postage_ems", 0).ToString());
                }
                goodsinfo.Itemtype = DNTRequest.GetInt("itemtype", 0);

                DateTime dateline;
                switch (DNTRequest.GetInt("_now", 0))
                {
                case 1: dateline = Convert.ToDateTime(string.Format("{0} {1}:{2}:00", DNTRequest.GetString("_date"), DNTRequest.GetInt("_hour", 0), DNTRequest.GetInt("_minute", 0))); break; //设定

                case 2: dateline = Convert.ToDateTime("1900-01-01 00:00:00"); break;                                                                                                          //返回100年之后的日期作为"暂不设置"

                default: dateline = DateTime.Now; break;                                                                                                                                      //立即
                }

                goodsinfo.Dateline   = dateline;
                goodsinfo.Expiration = Convert.ToDateTime(DNTRequest.GetString("expiration"));
                goodsinfo.Lastbuyer  = "";
                goodsinfo.Lasttrade  = Convert.ToDateTime("1900-01-01 00:00:00");
                goodsinfo.Lastupdate = Convert.ToDateTime(Utils.GetDateTime());
                goodsinfo.Totalitems = 0;
                goodsinfo.Tradesum   = 0;
                goodsinfo.Closed     = 0;
                goodsinfo.Aid        = 0;
                goodsinfo.Costprice  = Convert.ToDecimal(DNTRequest.GetFormFloat("costprice", 1).ToString());
                goodsinfo.Invoice    = DNTRequest.GetInt("invoice", 0);
                goodsinfo.Repair     = DNTRequest.GetInt("repair", 0);
                if (useradminid == 1)
                {
                    goodsinfo.Message = Utils.HtmlEncode(postmessage);
                }
                else
                {
                    goodsinfo.Message = Utils.HtmlEncode(ForumUtils.BanWordFilter(postmessage));
                }

                goodsinfo.Otherlink = "";
                int readperm = DNTRequest.GetInt("readperm", 0);
                goodsinfo.Readperm  = readperm > 255 ? 255 : readperm;
                goodsinfo.Tradetype = DNTRequest.GetInt("tradetype", 0);

                if (goodsinfo.Tradetype == 1 && Utils.StrIsNullOrEmpty(goodsinfo.Account)) //当为支付宝在线支付方式下,如果"支付宝账户"为空时
                {
                    AddErrLine("请输入支付宝帐号信息。");
                    return;
                }

                goodsinfo.Viewcount    = 0;
                goodsinfo.Displayorder = DNTRequest.GetString("displayorder") == "on" ? 0 : -3;

                if (config.Enablemall == 1) //当为版块交易帖是时
                {
                    if (forum.Modnewposts == 1 && useradminid != 1)
                    {
                        if (useradminid > 1)
                        {
                            if (disablepost != 1)
                            {
                                goodsinfo.Displayorder = -2;
                                disablepost            = 0;
                            }
                        }
                        else
                        {
                            goodsinfo.Displayorder = -2;
                            disablepost            = 0;
                        }
                    }
                }

                goodsinfo.Smileyoff = smileyoff;
                if (smileyoff == 0 && forum.Allowsmilies == 1)
                {
                    goodsinfo.Smileyoff = Utils.StrToInt(DNTRequest.GetString("smileyoff"), 0);
                }

                goodsinfo.Bbcodeoff = 1;
                if (usergroupinfo.Allowcusbbcode == 1 && forum.Allowbbcode == 1)
                {
                    goodsinfo.Bbcodeoff = Utils.StrToInt(DNTRequest.GetString("bbcodeoff"), 0);
                }

                goodsinfo.Parseurloff = Utils.StrToInt(DNTRequest.GetString("parseurloff"), 0);

                if (useradminid == 1)
                {
                    goodsinfo.Title = Utils.HtmlEncode(DNTRequest.GetString("title"));
                }
                else
                {
                    goodsinfo.Title = Utils.HtmlEncode(ForumUtils.BanWordFilter(DNTRequest.GetString("title")));
                }

                string htmltitle = DNTRequest.GetString("htmltitle").Trim();
                if (htmltitle != string.Empty && Utils.HtmlDecode(htmltitle).Trim() != goodsinfo.Title)
                {
                    goodsinfo.Magic = 11000;
                    //按照  附加位/htmltitle(1位)/magic(3位)/以后扩展(未知位数) 的方式来存储
                    //例: 11001
                }

                //标签(Tag)操作
                string   tags      = DNTRequest.GetString("tags").Trim();
                string[] tagsArray = null;
                if (enabletag && tags != string.Empty)
                {
                    tagsArray = Utils.SplitString(tags, " ", true, 2, 10);
                    if (tagsArray.Length > 0)
                    {
                        if (goodsinfo.Magic == 0)
                        {
                            goodsinfo.Magic = 10000;
                        }

                        goodsinfo.Magic = Utils.StrToInt(goodsinfo.Magic.ToString() + "1", 0);
                    }
                }

                goodsinfo.Goodsid = Goods.CreateGoods(goodsinfo);
                //保存htmltitle
                if (canhtmltitle && htmltitle != string.Empty && htmltitle != goodsinfo.Title)
                {
                    Goods.WriteHtmlSubjectFile(htmltitle, goodsinfo.Goodsid);
                }

                if (enabletag && tagsArray != null && tagsArray.Length > 0)
                {
                    DbProvider.GetInstance().CreateGoodsTags(string.Join(" ", tagsArray), goodsinfo.Goodsid, userid, curdatetime);
                    GoodsTags.WriteGoodsTagsCacheFile(goodsinfo.Goodsid);
                }

                StringBuilder sb = new StringBuilder();
                sb.Remove(0, sb.Length);

                int watermarkstatus = (forum.Disablewatermark == 1) ? 0 : config.Watermarkstatus;

                Goodsattachmentinfo[] attachmentinfo = Discuz.Mall.MallUtils.SaveRequestFiles(categoryid, config.Maxattachments, usergroupinfo.Maxsizeperday, usergroupinfo.Maxattachsize, MaxTodaySize, attachextensions, watermarkstatus, config, "postfile");
                if (attachmentinfo != null)
                {
                    if (attachmentinfo.Length > config.Maxattachments)
                    {
                        AddErrLine("系统设置为每个商品附件不得多于" + config.Maxattachments + "个");
                        return;
                    }
                    int    errorAttachment = GoodsAttachments.BindAttachment(attachmentinfo, goodsinfo.Goodsid, sb, goodsinfo.Categoryid, userid);
                    int[]  aid             = GoodsAttachments.CreateAttachments(attachmentinfo);
                    string tempMessage     = GoodsAttachments.FilterLocalTags(aid, attachmentinfo, goodsinfo.Message);

                    goodsinfo.Goodspic = (attachmentinfo.Length > 0) ? attachmentinfo[0].Filename : "";
                    if (!tempMessage.Equals(goodsinfo.Message))
                    {
                        goodsinfo.Message = tempMessage;
                        goodsinfo.Aid     = aid[0];
                    }
                    Goods.UpdateGoods(goodsinfo);

                    UserCredits.UpdateUserExtCreditsByUploadAttachment(userid, aid.Length - errorAttachment);
                }

                //加入相册
                #region 相册
                if (config.Enablealbum == 1 && apb != null)
                {
                    sb.Append(apb.CreateAttachment(attachmentinfo, usergroupid, userid, username));
                }
                #endregion
                if (config.Enablemall == 1) //开启普通模式
                {
                    OnlineUsers.UpdateAction(olid, UserAction.PostTopic.ActionID, forumid, forumname, -1, "");
                }

                if (sb.Length > 0)
                {
                    SetShowBackLink(true);

                    sb.Insert(0, "<table cellspacing=\"0\" cellpadding=\"4\" border=\"0\"><tr><td colspan=2 align=\"left\"><span class=\"bold\"><nobr>发布商品成功,但以下附件上传失败:</nobr></span><br /></td></tr>");
                    sb.Append("</table>");
                    SetUrlAndMsgLine(base.ShowGoodsAspxRewrite(goodsinfo.Goodsid), sb.ToString());
                }
                else
                {
                    SetShowBackLink(false);

                    if (config.Enablemall == 1 && forum.Modnewposts == 1 && useradminid != 1)
                    {
                        if (useradminid != 1)
                        {
                            if (disablepost == 1)
                            {
                                if (goodsinfo.Displayorder == -3)
                                {
                                    SetUrlAndMsgLine(base.ShowGoodsListAspxRewrite(goodsinfo.Categoryid, 1), "发布商品成功, 但未上架. 您可到用户中心进行上架操作!");
                                }
                                else
                                {
                                    SetUrlAndMsgLine(base.ShowGoodsAspxRewrite(goodsinfo.Goodsid),
                                                     "发布商品成功, 返回该商品<br />(<a href=\"" + base.ShowGoodsAspxRewrite(goodsinfo.Goodsid) + "\">点击这里返回 " + forumname + "</a>)<br />");
                                }
                            }
                            else
                            {
                                SetUrlAndMsgLine(base.ShowGoodsListAspxRewrite(goodsinfo.Categoryid, 1), "发布商品成功, 但需要经过审核才可以显示. 返回商品列表");
                            }
                        }
                        else
                        {
                            SetUrlAndMsgLine(base.ShowGoodsListAspxRewrite(goodsinfo.Categoryid, 1), "发布商品成功, 返回商品列表");
                        }
                    }
                    else
                    {
                        if (goodsinfo.Displayorder == -3)
                        {
                            SetUrlAndMsgLine(base.ShowGoodsListAspxRewrite(goodsinfo.Categoryid, 1), "发布商品成功, 但未上架. 您可到用户中心进行上架操作!");
                        }
                        else
                        {
                            SetUrlAndMsgLine(base.ShowGoodsAspxRewrite(goodsinfo.Goodsid),
                                             "发布商品成功, 返回该商品<br />(<a href=\"" + base.ShowGoodsAspxRewrite(goodsinfo.Goodsid) + "\">点击这里返回</a>)<br />");
                        }
                    }
                }

                ForumUtils.WriteCookie("postmessage", "");
            }

            topicattachscorefield = 0;
        }
Example #10
0
 /// <summary>
 /// 更新店铺
 /// </summary>
 /// <param name="shopinfo">店铺信息</param>
 /// <returns>更新是否成功</returns>
 public static bool UpdateShop(Shopinfo shopInfo)
 {
     return(DbProvider.GetInstance().UpdateShop(shopInfo));
 }
Example #11
0
 /// <summary>
 /// 创建店铺
 /// </summary>
 /// <param name="shopinfo">店铺信息</param>
 /// <returns>创建店铺id</returns>
 public static int CreateShop(Shopinfo shopInfo)
 {
     return(DbProvider.GetInstance().CreateShop(shopInfo));
 }