コード例 #1
0
ファイル: WMGoodsTest.cs プロジェクト: honj51/micro-emall
        public void Test_GetList()
        {
            //添加category
            WMGoodCategories cateToAdd = new WMGoodCategories();
            cateToAdd.ParentId = "root";
            cateToAdd.Name = "珠宝";
            bool isCateAdded = cateToAdd.Add();
            Assert.IsTrue(isCateAdded);

            //添加good
            WMGoods goodToAdd = new WMGoods();
            goodToAdd.CategoryId = cateToAdd.Id;
            goodToAdd.Name = "砖石项链";
            goodToAdd.Unit = "件";
            goodToAdd.OriginalPrice = 10000;
            goodToAdd.StatusId = 501;
            bool isGoodAdded = goodToAdd.Add();
            Assert.IsTrue(isGoodAdded);

            //获取good
            int pageCount;
            List<WMGoods> goodsToGet = WMGoods.GetList(out pageCount, pageIndex: 0, pageSize: 10);

            //Assert
            Assert.AreEqual(1, goodsToGet.Count);
        }
コード例 #2
0
ファイル: WMGoodsTest.cs プロジェクト: honj51/micro-emall
        public void Test_Add_Get()
        {
            //添加category
            WMGoodCategories cateToAdd = new WMGoodCategories();
            cateToAdd.ParentId = "root";
            cateToAdd.Name = "珠宝";
            bool isCateAdded = cateToAdd.Add();
            Assert.IsTrue(isCateAdded);

            //添加good
            WMGoods goodToAdd = new WMGoods();
            goodToAdd.CategoryId = cateToAdd.Id;
            goodToAdd.Name = "砖石项链";
            goodToAdd.Unit = "件";
            goodToAdd.OriginalPrice = 10000;
            goodToAdd.StatusId = 501;
            bool isGoodAdded = goodToAdd.Add();
            Assert.IsTrue(isGoodAdded);

            //获取good
            WMGoods goodGetted = WMGoods.Get(goodToAdd.Id);

            //Assertion
            Assert.IsNotNull(goodGetted);
            Assert.AreEqual("砖石项链", goodGetted.Name);
        }
コード例 #3
0
        public void Test_Add_Get()
        {
            //添加category
            WMGoodCategories cateToAdd = new WMGoodCategories();
            cateToAdd.ParentId = "root";
            cateToAdd.Name = "珠宝";
            bool isCateAdded = cateToAdd.Add();
            Assert.IsTrue(isCateAdded);

            //添加good
            WMGoods goodToAdd = new WMGoods();
            goodToAdd.CategoryId = cateToAdd.Id;
            goodToAdd.Name = "砖石项链";
            goodToAdd.Unit = "件";
            goodToAdd.OriginalPrice = 10000;
            goodToAdd.StatusId = 501;
            bool isGoodAdded = goodToAdd.Add();
            Assert.IsTrue(isGoodAdded);

            WMUserClicks click = new WMUserClicks()
            {
                PromoterId = "promoter123456",
                CustomerId = "customer123456",
                GoodId = goodToAdd.Id,
            };
            Assert.IsTrue(click.Add());

            int clickCount = WMUserClicks.GetClickCount("Promoter123456");
            Assert.AreEqual(1, clickCount);
        }
コード例 #4
0
        public void Test_Add_Get()
        {
            //Add user
            WMUsers userToAdd = new WMUsers();
            userToAdd.Id = General.UniqueString(userToAdd.Id);
            userToAdd.RoleId = 101;
            userToAdd.UserName = "******";
            userToAdd.Password = "******";
            userToAdd.NickName = "nick";
            userToAdd.Mobile = "13512341234";
            Assert.IsTrue(userToAdd.Add());

            //Add address
            WMOrders order = new WMOrders()
            {
                UserId = userToAdd.Id,
                Address = "上海哪儿哪儿哪儿",
                Contact = "小李",
                Phone = "13512341235",
                ZipCode = "240101",
                ProvinceId = 110000,
                CityId = 110100,
                AreaId = 110101,
                PayId = 621
            };
            Assert.IsTrue(order.Add());
            Assert.AreEqual("小李", order.Contact);

            //添加category
            WMGoodCategories cateToAdd = new WMGoodCategories();
            cateToAdd.ParentId = "root";
            cateToAdd.Name = "珠宝";
            bool isCateAdded = cateToAdd.Add();
            Assert.IsTrue(isCateAdded);

            //添加good
            WMGoods goodToAdd = new WMGoods();
            goodToAdd.CategoryId = cateToAdd.Id;
            goodToAdd.Name = "砖石项链";
            goodToAdd.Unit = "件";
            goodToAdd.OriginalPrice = 10000;
            goodToAdd.StatusId = 501;
            bool isGoodAdded = goodToAdd.Add();
            Assert.IsTrue(isGoodAdded);

            WMOrderGoods orderGood = new WMOrderGoods()
            {
                Count = 2,
                GoodId = goodToAdd.Id,
                OrderId = order.Id,
                Price = 100,
            };
            Assert.IsTrue(orderGood.Add());

            int pageCount;
            List<WMOrderGoods> orderGoodsGetted = WMOrderGoods.GetList(out pageCount, order.Id);
            Assert.AreEqual(1, orderGoodsGetted.Count);
            Assert.AreEqual("砖石项链", orderGoodsGetted[0].GoodName);
            Assert.AreEqual(2, orderGoodsGetted[0].Count);
        }
コード例 #5
0
        public static double GetClickBonus(string promoterId, string goodId)
        {
            double clickBonus = 0;

            if (!General.IsNullable(promoterId) && !General.IsNullable(goodId))
            {
                int     count = GetClickCount(promoterId, goodId);
                WMGoods good  = WMGoods.Get(goodId);

                if (good != null && good.Clicks > 0)
                {
                    clickBonus = ((count / good.Clicks) * good.ClickBonuses);
                }
            }

            return(clickBonus);
        }
コード例 #6
0
        public void Test_Add_GetList()
        {
            //User
            WMUsers user = new WMUsers();
            user.Id = General.UniqueString(user.Id);
            user.RoleId = 101;
            user.UserName = "******";
            user.Password = "******";
            user.NickName = "nick";
            user.Mobile = "13512341234";
            Assert.IsTrue(user.Add());

            //Category
            WMGoodCategories cate = new WMGoodCategories();
            cate.ParentId = "root";
            cate.Name = "珠宝";
            Assert.IsTrue(cate.Add());

            //Good
            WMGoods good = new WMGoods();
            good.CategoryId = cate.Id;
            good.Name = "砖石项链";
            good.Unit = "件";
            good.OriginalPrice = 10000;
            good.StatusId = 501;
            bool isGoodAdded = good.Add();
            Assert.IsTrue(isGoodAdded);

            //Car
            WMShopCars car = new WMShopCars()
            {
                GoodId = good.Id,
                UserId = user.Id,
                Price = 100,
                Count = 2,
            };
            Assert.IsTrue(car.Add());

            int pageCount;
            List<WMShopCars> carsGetted = WMShopCars.GetList(out pageCount, user.Id, null, 0, 0);
            Assert.IsNotNull(carsGetted);
            Assert.AreEqual(1, carsGetted.Count);
            Assert.AreEqual("砖石项链", carsGetted[0].GoodName);
        }
コード例 #7
0
        public static WMGoods Get(string id)
        {
            WMGoods good = null;

            if (!General.IsNullable(id))
            {
                using (WMContext context = new WMContext())
                {
                    good = (
                        from g in context.Goods
                        join s in context.Options on g.StatusId equals s.Id
                        join ba in context.GoodBrands on g.BrandId equals ba.Id into brand
                        from b in brand.DefaultIfEmpty()
                        where g.Id.Equals(id)
                        select new WMGoods
                    {
                        Id = g.Id,
                        CategoryId = g.CategoryId,
                        BrandId = g.BrandId,
                        BrandName = (b != null ? b.Name : ""),
                        Name = g.Name,
                        OriginalPrice = g.OriginalPrice,
                        PresentPrice = g.PresentPrice,
                        Unit = g.Unit,
                        Desc = g.Desc,
                        Spec = g.Spec,
                        Service = g.Service,
                        Integral = g.Integral,
                        Clicks = g.Clicks,
                        Saves = g.Saves,
                        Bonus = g.Bonus,
                        GoldPool = g.GoldPool,
                        StatusId = g.StatusId,
                        StatusName = s.Name,
                        AddDate = g.AddDate
                    }
                        ).FirstOrDefault();
                }
            }

            return(good);
        }
コード例 #8
0
ファイル: WMUserSetsTest.cs プロジェクト: honj51/micro-emall
        public void Test_Fav_Add_Get()
        {
            WMUsers userToAdd = new WMUsers();
            userToAdd.Id = General.UniqueString(userToAdd.Id);
            userToAdd.RoleId = 101;
            userToAdd.UserName = "******";
            userToAdd.Password = "******";
            userToAdd.NickName = "nick";
            userToAdd.Mobile = "13512341234";
            Assert.IsTrue(userToAdd.Add());

            //添加category
            WMGoodCategories cateToAdd = new WMGoodCategories();
            cateToAdd.ParentId = "root";
            cateToAdd.Name = "珠宝";
            bool isCateAdded = cateToAdd.Add();
            Assert.IsTrue(isCateAdded);

            //添加good
            WMGoods goodToAdd = new WMGoods();
            goodToAdd.CategoryId = cateToAdd.Id;
            goodToAdd.Name = "砖石项链";
            goodToAdd.Unit = "件";
            goodToAdd.OriginalPrice = 10000;
            goodToAdd.StatusId = 501;
            bool isGoodAdded = goodToAdd.Add();
            Assert.IsTrue(isGoodAdded);

            WMUserSets userSet = new WMUserSets()
            {
                TypeId = 401,
                UserId = userToAdd.Id,
                GoodId = goodToAdd.Id,
            };
            Assert.IsTrue(userSet.Add());

            int pageCount;
            List<WMUserSets> favs = WMUserSets.GetList(out pageCount, 401, userToAdd.Id);
            Assert.AreEqual(1, favs.Count);
            Assert.AreEqual("砖石项链", favs[0].GoodName);
        }
コード例 #9
0
ファイル: add.aspx.cs プロジェクト: chinaq/micro-emall
    protected void SubmitButton_Click(object sender, EventArgs e)
    {
        bool flag = false;

        if (this.IsValid)
        {
            string cid = CategoryId.Value;
            if (General.IsNullable(cid))
            {
                CategoryValid.CssClass = CategoryValid.CssClass.Replace(" hide", "");
                return;
            }

            WMGoods good = new WMGoods();

            good.Name = GoodName.Text;
            good.CategoryId = cid;
            good.BrandId = BrandList.SelectedValue;
            good.OriginalPrice = OriginalPrice.Text.ToDouble().Value;
            good.PresentPrice = PresentPrice.Text.ToDouble();
            good.Unit = GoodUnit.Text;
            good.Integral = GoodInte.Text.ToInt32();
            good.Bonus = GoodBonus.Text.ToInt32();
            good.GoldPool = GoodGoldPool.Text.ToInt32();
            good.Desc = GoodDsec.Text;
            good.Spec = GoodSpec.Text;
            good.Service = GoodService.Text;
            good.StatusId = StateList.SelectedValue.ToInt32();

            flag = good.Add();

            if(flag)
            {
                string url = string.Format("~/admin/modules/good/goods/upload.aspx?gid={0}", good.Id);
                Response.Redirect(url);
                return;
            }
        }

        Helper.MessageBox(flag);
    }
コード例 #10
0
ファイル: AddDatas.cs プロジェクト: honj51/micro-emall
        public void Test_AddAllDatas()
        {
            bool isAdded = false;

            //express
            WMOrderExpress express = new WMOrderExpress()
            {
                Name = "顺丰",
                URL = "www.shufen.com"
            };
            Assert.IsTrue(express.Add());

            //Admins
            WMAdministrators adminToAdd = new WMAdministrators();
            adminToAdd.RoleId = 302;
            adminToAdd.UserName = "******";
            adminToAdd.Password = "******";
            adminToAdd.Add();

            //Users
            WMUsers userToAdd = new WMUsers();
            userToAdd.Id = General.UniqueString(userToAdd.Id);
            userToAdd.RoleId = 101;
            userToAdd.UserName = "******";
            userToAdd.Password = "******";
            userToAdd.NickName = "nick";
            userToAdd.Mobile = "13512341234";
            Assert.IsTrue(userToAdd.Add());

            //Categories
            //珠宝
            WMGoodCategories cate_0 = new WMGoodCategories();
            cate_0.ParentId = "root";
            cate_0.Name = "珠宝";
            isAdded = cate_0.Add();
            Assert.IsTrue(isAdded);

            WMGoodCategories cate_0_0 = new WMGoodCategories();
            cate_0_0.ParentId = cate_0.Id;
            cate_0_0.Name = "项链";
            isAdded = cate_0_0.Add();
            Assert.IsTrue(isAdded);

            WMGoodCategories cate_0_1 = new WMGoodCategories();
            cate_0_1.ParentId = cate_0.Id;
            cate_0_1.Name = "手镯";
            isAdded = cate_0_1.Add();
            Assert.IsTrue(isAdded);

            //服装
            WMGoodCategories cate_1 = new WMGoodCategories();
            cate_1.ParentId = "root";
            cate_1.Name = "服装";
            isAdded = cate_1.Add();
            Assert.IsTrue(isAdded);

            WMGoodCategories cate_1_0 = new WMGoodCategories();
            cate_1_0.ParentId = cate_1.Id;
            cate_1_0.Name = "衬衫";
            isAdded = cate_1_0.Add();
            Assert.IsTrue(isAdded);

            WMGoodCategories cate_1_1 = new WMGoodCategories();
            cate_1_1.ParentId = cate_1.Id;
            cate_1_1.Name = "T恤";
            isAdded = cate_1_1.Add();
            Assert.IsTrue(isAdded);

            //添加good
            WMGoods goodToAdd = new WMGoods();
            goodToAdd.CategoryId = cate_0.Id;
            goodToAdd.Name = "砖石项链";
            goodToAdd.Unit = "件";
            goodToAdd.OriginalPrice = 10000;
            goodToAdd.StatusId = 501;
            bool isGoodAdded = goodToAdd.Add();
            Assert.IsTrue(isGoodAdded);

            WMGoods good2ToAdd = new WMGoods();
            good2ToAdd.CategoryId = cate_0_0.Id;
            good2ToAdd.Name = "黄金项链";
            good2ToAdd.Unit = "件";
            good2ToAdd.OriginalPrice = 10000;
            good2ToAdd.StatusId = 501;
            good2ToAdd.Add();

            WMGoods good3ToAdd = new WMGoods();
            good3ToAdd.CategoryId = cate_0_0.Id;
            good3ToAdd.Name = "红宝石项链";
            good3ToAdd.Unit = "件";
            good3ToAdd.OriginalPrice = 10000;
            good3ToAdd.StatusId = 501;
            good3ToAdd.Add();

            WMGoods good4ToAdd = new WMGoods();
            good4ToAdd.CategoryId = cate_0_0.Id;
            good4ToAdd.Name = "蓝宝石项链";
            good4ToAdd.Unit = "件";
            good4ToAdd.OriginalPrice = 10000;
            good4ToAdd.StatusId = 501;
            good4ToAdd.Add();

            WMGoods good5ToAdd = new WMGoods();
            good5ToAdd.CategoryId = cate_0_0.Id;
            good5ToAdd.Name = "绿宝石项链";
            good5ToAdd.Unit = "件";
            good5ToAdd.OriginalPrice = 10000;
            good5ToAdd.StatusId = 501;
            good5ToAdd.Add();

            WMGoods good6ToAdd = new WMGoods();
            good6ToAdd.CategoryId = cate_0_0.Id;
            good6ToAdd.Name = "黄宝石项链";
            good6ToAdd.Unit = "件";
            good6ToAdd.OriginalPrice = 10000;
            good6ToAdd.StatusId = 501;
            good6ToAdd.Add();

            WMGoods good7ToAdd = new WMGoods();
            good7ToAdd.CategoryId = cate_0_0.Id;
            good7ToAdd.Name = "珍珠项链";
            good7ToAdd.Unit = "件";
            good7ToAdd.OriginalPrice = 10000;
            good7ToAdd.StatusId = 501;
            good7ToAdd.Add();

            WMGoods good8ToAdd = new WMGoods();
            good8ToAdd.CategoryId = cate_0_0.Id;
            good8ToAdd.Name = "石头项链";
            good8ToAdd.Unit = "件";
            good8ToAdd.OriginalPrice = 10000;
            good8ToAdd.StatusId = 501;
            good8ToAdd.Add();

            WMGoods good9ToAdd = new WMGoods();
            good9ToAdd.CategoryId = cate_0_0.Id;
            good9ToAdd.Name = "水泥项链";
            good9ToAdd.Unit = "件";
            good9ToAdd.OriginalPrice = 10000;
            good9ToAdd.StatusId = 501;
            good9ToAdd.Add();

            WMGoods good10ToAdd = new WMGoods();
            good10ToAdd.CategoryId = cate_0_0.Id;
            good10ToAdd.Name = "1项链";
            good10ToAdd.Unit = "件";
            good10ToAdd.OriginalPrice = 10000;
            good10ToAdd.StatusId = 501;
            good10ToAdd.Add();

            WMGoods good11ToAdd = new WMGoods();
            good11ToAdd.CategoryId = cate_0_0.Id;
            good11ToAdd.Name = "2项链";
            good11ToAdd.Unit = "件";
            good11ToAdd.OriginalPrice = 10000;
            good11ToAdd.StatusId = 501;
            good11ToAdd.Add();

            WMGoods good12ToAdd = new WMGoods();
            good12ToAdd.CategoryId = cate_0_0.Id;
            good12ToAdd.Name = "3项链";
            good12ToAdd.Unit = "件";
            good12ToAdd.OriginalPrice = 10000;
            good12ToAdd.StatusId = 501;
            good12ToAdd.Add();

            WMGoods good13ToAdd = new WMGoods();
            good13ToAdd.CategoryId = cate_0_0.Id;
            good13ToAdd.Name = "4项链";
            good13ToAdd.Unit = "件";
            good13ToAdd.OriginalPrice = 10000;
            good13ToAdd.StatusId = 501;
            good13ToAdd.Add();

            WMGoods good14ToAdd = new WMGoods();
            good14ToAdd.CategoryId = cate_0_0.Id;
            good14ToAdd.Name = "5项链";
            good14ToAdd.Unit = "件";
            good14ToAdd.OriginalPrice = 10000;
            good14ToAdd.StatusId = 501;
            good14ToAdd.Add();

            WMGoods good15ToAdd = new WMGoods();
            good15ToAdd.CategoryId = cate_0_0.Id;
            good15ToAdd.Name = "6项链";
            good15ToAdd.Unit = "件";
            good15ToAdd.OriginalPrice = 10000;
            good15ToAdd.StatusId = 501;
            good15ToAdd.Add();

            WMGoods good16ToAdd = new WMGoods();
            good16ToAdd.CategoryId = cate_0_0.Id;
            good16ToAdd.Name = "7项链";
            good16ToAdd.Unit = "件";
            good16ToAdd.OriginalPrice = 10000;
            good16ToAdd.StatusId = 501;
            good16ToAdd.Add();

            WMGoods good17ToAdd = new WMGoods();
            good17ToAdd.CategoryId = cate_0_0.Id;
            good17ToAdd.Name = "8项链";
            good17ToAdd.Unit = "件";
            good17ToAdd.OriginalPrice = 10000;
            good17ToAdd.StatusId = 501;
            good17ToAdd.Add();

            //添加brand
            WMGoodBrands brand1 = new WMGoodBrands();
            brand1.Name = "卡地亚";
            Assert.IsTrue(brand1.Add());

            WMGoodBrands brand2 = new WMGoodBrands();
            brand2.Name = "爱马仕";
            Assert.IsTrue(brand2.Add());

            //Car
            WMShopCars car = new WMShopCars()
            {
                GoodId = goodToAdd.Id,
                UserId = userToAdd.Id,
                Price = 100,
                Count = 2,
            };
            Assert.IsTrue(car.Add());

            WMShopCars car2 = new WMShopCars()
            {
                GoodId = good2ToAdd.Id,
                UserId = userToAdd.Id,
                Price = 500,
                Count = 3,
            };
            Assert.IsTrue(car2.Add());

            WMOrders order = new WMOrders()
            {
                UserId = userToAdd.Id,
                Address = "上海哪儿哪儿哪儿",
                Contact = "小李",
                Phone = "13512341235",
                ZipCode = "240101",
                ProvinceId = 110000,
                CityId = 110100,
                AreaId = 110101,
                PayId = 621,
                ExpressId = express.Id
            };
            Assert.IsTrue(order.Add());

            WMOrderGoods orderGood = new WMOrderGoods()
            {
                Count = 2,
                GoodId = goodToAdd.Id,
                OrderId = order.Id,
                Price = 100,
            };
            Assert.IsTrue(orderGood.Add());

            //Add address
            WMUserReceipts receipt = new WMUserReceipts()
            {
                UserId = userToAdd.Id,
                Address = "上海哪儿哪儿哪儿",
                Contact = "小李",
                Phone = "13512341235",
                ZipCode = "240101",
                ProvinceId = 110000,
                CityId = 110100,
                AreaId = 110101,
            };
            Assert.IsTrue(receipt.Add());

            //用户收藏
            WMUserSets userSet = new WMUserSets()
            {
                TypeId = 401,
                UserId = userToAdd.Id,
                GoodId = goodToAdd.Id,
            };
            Assert.IsTrue(userSet.Add());

            //用户积分
            WMUserIntegrals intergral = new WMUserIntegrals()
            {
                UserId = userToAdd.Id,
                Integral = 100,
                SourceId = 451
            };
            Assert.IsTrue(intergral.Add());

            WMUserIntegrals intergral2 = new WMUserIntegrals()
            {
                UserId = userToAdd.Id,
                Integral = 100,
                SourceId = 451
            };
            Assert.IsTrue(intergral2.Add());

            WMUserIntegrals intergral3 = new WMUserIntegrals()
            {
                UserId = userToAdd.Id,
                Integral = 100,
                SourceId = 451
            };
            Assert.IsTrue(intergral3.Add());

            WMUserIntegrals intergral4 = new WMUserIntegrals()
            {
                UserId = userToAdd.Id,
                Integral = 100,
                SourceId = 451
            };
            Assert.IsTrue(intergral4.Add());

            WMUserIntegrals intergral5 = new WMUserIntegrals()
            {
                UserId = userToAdd.Id,
                Integral = 100,
                SourceId = 451
            };
            Assert.IsTrue(intergral5.Add());

            WMUserIntegrals intergral6 = new WMUserIntegrals()
            {
                UserId = userToAdd.Id,
                Integral = 100,
                SourceId = 451
            };
            Assert.IsTrue(intergral6.Add());

            WMUserIntegrals intergral7 = new WMUserIntegrals()
            {
                UserId = userToAdd.Id,
                Integral = 100,
                SourceId = 451
            };
            Assert.IsTrue(intergral7.Add());

            WMUserIntegrals intergral8 = new WMUserIntegrals()
            {
                UserId = userToAdd.Id,
                Integral = 100,
                SourceId = 451
            };
            Assert.IsTrue(intergral8.Add());

            //用户返利
            WMUserBonus bonus = new WMUserBonus()
            {
                UserId = userToAdd.Id,
                OrderId = order.Id,
                BonusSum = 101,
            };
            Assert.IsTrue(bonus.Add());

            WMUserBonus bonus2 = new WMUserBonus()
            {
                UserId = userToAdd.Id,
                OrderId = order.Id,
                BonusSum = 102,
                //AddDate = DateTime.Parse("2014-9-9")
            };
            Assert.IsTrue(bonus2.Add());

            WMUserBonus bonus3 = new WMUserBonus()
            {
                UserId = userToAdd.Id,
                OrderId = order.Id,
                BonusSum = 102,
                //AddDate = DateTime.Parse("2014-9-9")
            };
            Assert.IsTrue(bonus3.Add());

            WMUserBonus bonus4 = new WMUserBonus()
            {
                UserId = userToAdd.Id,
                OrderId = order.Id,
                BonusSum = 102,
                //AddDate = DateTime.Parse("2014-9-9")
            };
            Assert.IsTrue(bonus4.Add());

            WMUserBonus bonus5 = new WMUserBonus()
            {
                UserId = userToAdd.Id,
                OrderId = order.Id,
                BonusSum = 102,
                //AddDate = DateTime.Parse("2014-9-9")
            };
            Assert.IsTrue(bonus5.Add());

            WMUserBonus bonus6 = new WMUserBonus()
            {
                UserId = userToAdd.Id,
                OrderId = order.Id,
                BonusSum = 102,
                //AddDate = DateTime.Parse("2014-9-9")
            };
            Assert.IsTrue(bonus6.Add());
        }