protected void Page_Load(object sender, EventArgs e)
    {
        var BookList     = BookUtil.CreateBookList();
        var CategoryList = BookList.Select(p => new { p.Category, p.CategoryImageUrl, p.CategoryUrl }).Distinct();

        RptCategory.DataSource = CategoryList;
        RptCategory.DataBind();

        RptBooks.DataSource = BookList;
        RptBooks.DataBind();
    }
Beispiel #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string queryString = Request.QueryString["book"];

        if ((queryString != String.Empty) && (queryString != null))
        {
            var book = BookUtil.CreateBookList().Where(p => p.ItemUrl == queryString).FirstOrDefault();
            if (book != null)
            {
                LitTitle.Text    = book.Title;
                ImgBook.ImageUrl = book.BooksImageUrl;
                LitWriter.Text   = book.Writer;
                LitCategory.Text = book.Category;
            }
        }
    }
Beispiel #3
0
        public BookQuery()
        {
            FieldAsync <ListGraphType <BookType> >(
                name: "books",
                description: "get all books",
                resolve: async context => await BookUtil.BooksAsync());

            FieldAsync <BookType>(
                name: "book",
                description: "get book by id",
                arguments: new QueryArguments(new QueryArgument <IdGraphType> {
                Name = "id"
            }),
                resolve: async context =>
            {
                var id    = context.GetArgument <int>("id");
                var model = await BookUtil.BookByIdAsync(id);
                return(model);
            });
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        var BookList = BookUtil.CreateBookList();

        string queryString = Request.QueryString["category"];

        if ((queryString != String.Empty) && (queryString != null))
        {
            LitTitle.Text             = "Books";
            PnlSectionItemRow.Visible = true;
            string categoryUrl = "category/" + queryString;
            RptBooks.DataSource = BookList.Where(p => p.CategoryUrl == categoryUrl);
            RptBooks.DataBind();
        }
        else
        {
            LitTitle.Text       = "Categories";
            RptCategory.Visible = true;
            var CategoryList = BookList.Select(p => new { p.Category, p.CategoryImageUrl, p.CategoryUrl }).Distinct();
            RptCategory.DataSource = CategoryList;
            RptCategory.DataBind();
        }
    }
Beispiel #5
0
        protected override CommandResult <ProductData> OnExecute(object commandParameter)
        {
            var result = new CommandResult <ProductData>();
            var param  = commandParameter as LoadBookProductDetailParameter;

            using (CoreContext context = new CoreContext())
            {
                var bookConfig = new BookUtil();
                if (bookConfig._Config == null)
                {
                    result.ErrorCode    = -1;
                    result.ErrorMessage = "活动已结束";
                    return(result);
                }
                if (DateTime.Now < bookConfig._Config.StartTime)
                {
                    result.ErrorCode    = -1;
                    result.ErrorMessage = "活动未开始";
                    return(result);
                }
                if (bookConfig._Config.EndTime < DateTime.Now)
                {
                    result.ErrorCode    = -1;
                    result.ErrorMessage = "活动已结束";
                    return(result);
                }

                var pmodel = bookConfig._ProductConfig.Where(p => p.ProductNo == param.ProductNo).FirstOrDefault();
                if (pmodel == null)
                {
                    result.ErrorCode    = -1;
                    result.ErrorMessage = "产品对象为空";
                    return(result);
                }
                var productInfo = context.ProductInfo.Where(p => p.ProductNo == pmodel.ProductNo).FirstOrDefault();
                var pinfo       = context.Set <ShopProductInfo>().FromSql($@"select * from shop_product_info where product_no ={pmodel.ProductNo}").FirstOrDefault();
                if (pinfo != null)
                {
                    pmodel.ProductImage = pinfo.ProductImg;
                    pmodel.Description  = pinfo.Description;
                    pmodel.ThumbnailImg = pinfo.ThumbnailImg;
                }
                if (productInfo != null)
                {
                    if (!string.IsNullOrEmpty(productInfo.ProductName))
                    {
                        pmodel.ProductName = productInfo.ProductName;
                    }
                    if (!string.IsNullOrEmpty(productInfo.ProductDesc))
                    {
                        pmodel.ShortDesc = productInfo.ProductDesc;
                    }
                    if (!string.IsNullOrEmpty(productInfo.ImageUrl))
                    {
                        pmodel.ThumbnailImg = productInfo.ImageUrl;
                    }
                }

                result.Data = pmodel;
            }

            return(result);
        }
Beispiel #6
0
        protected override CommandResult <CreateBookOrderResult> OnExecute(object commandParameter)
        {
            var param  = commandParameter as CreateBookOrderParameter;
            var result = new CommandResult <CreateBookOrderResult>();

            result.Data = new CreateBookOrderResult();
            using (CoreContext context = new CoreContext())
            {
                var book = new BookUtil();
                if (book._Config == null)
                {
                    result.ErrorCode    = -1;
                    result.ErrorMessage = "活动已结束";
                    return(result);
                }
                if (DateTime.Now < book._Config.StartTime)
                {
                    result.ErrorCode    = -1;
                    result.ErrorMessage = "活动未开始";
                    return(result);
                }
                if (book._Config.EndTime < DateTime.Now)
                {
                    result.ErrorCode    = -1;
                    result.ErrorMessage = "活动已结束";
                    return(result);
                }

                var pmodel = book._ProductConfig.Where(p => p.ProductNo == param.ProductNo).FirstOrDefault();
                if (pmodel == null)
                {
                    return(ErrorResult <CreateBookOrderResult> .ParameterError);
                }
                var pSku = pmodel.SkuList.Where(s => s.ProductSkuNo == param.ProductSkuNo).FirstOrDefault();
                if (pSku == null)
                {
                    return(ErrorResult <CreateBookOrderResult> .ParameterError);
                }

                PaymentConfig payment = (from p in context.PaymentConfig where p.Id == param.PayId select p).FirstOrDefault();

                if (payment == null)
                {
                    result.ErrorMessage = "请设置支付方式";
                    result.ErrorCode    = -1;
                    return(result);
                }

                var redisdb    = RedisClient.GetDatabase();
                var orderIndex = redisdb.HashIncrementAsync("zlan.membercart.index", "OrderIndex").Result;

                string mainNo = string.Format("{0:yyMMddHHmmss}{1:D6}", DateTime.Now, orderIndex);
                //订单号
                string orderNo = string.Format("AT{0}00", mainNo);

                decimal totalFee = 0, discountFee = 0, productFee = 0;
                productFee = pSku.SalePrice;

                //开启事务
                using (var tran = context.Database.BeginTransaction())
                {
                    try
                    {
                        totalFee = productFee - discountFee;
                        //金额小于等于0创建失败
                        if (totalFee <= 0)
                        {
                            return(ErrorResult <CreateBookOrderResult> .ParameterError);
                        }
                        var order = new PayOrder()
                        {
                            OrderNo       = orderNo,
                            PaymentId     = param.PayId,
                            PayFee        = totalFee,
                            MemberAccount = param.MemberAccount,
                            TotalFee      = totalFee,
                            CreateTime    = DateTime.Now,
                            Kind          = "gift",
                            Status        = 0,
                            ProductFee    = productFee,
                            DiscountFee   = discountFee,
                            Memo          = $"【{pmodel.ProductName}】预付订单"
                        };
                        context.Add(order);

                        var bookinfo = new BookInfo()
                        {
                            Address       = param.Address,
                            City          = param.City,
                            Province      = param.Province,
                            Area          = param.Araea,
                            Phone         = param.Phone,
                            Name          = param.Name,
                            Counter       = 1,
                            ProductNo     = pmodel.ProductNo,
                            ProductSkuNo  = pSku.ProductSkuNo,
                            Status        = 0,
                            OrderNo       = orderNo,
                            ConfigId      = 1,
                            ProductConfig = JsonConvert.SerializeObject(pmodel),
                            StartTime     = book._ValidDate["Start"].Value <DateTime>(),
                            EndTime       = book._ValidDate["End"].Value <DateTime>(),
                            MemberAccount = param.MemberAccount,
                            CouponId      = pmodel.CouponId,
                            AddressId     = param.AddressId == 0 ? param.AddressId = -99 : param.AddressId
                        };
                        context.Add(bookinfo);
                        context.SaveChanges();

                        result.Data.PayId = payment.Id;
                        result.Data.PayNo = orderNo;
                        tran.Commit();
                    }
                    catch (Exception ex)
                    {
                        tran.Rollback();
                        result = ErrorResult <CreateBookOrderResult> .ParameterError;
                        result.ErrorMessage = ex.Message;
                        return(result);
                    }
                }
            }

            return(result);
        }