Esempio n. 1
0
        public void ProcessRequest(HttpContext context)
        {
            var userid = context.Request.Params["userid"];
            var shopid = context.Request.Params["shopid"];
            var code   = context.Request.Params["code"];

            context.Response.ContentType = "text/json";
            if (userid == null || shopid == null || code == null)
            {
                context.Response.Write(JsonConvert.ToString(new { code = 0 }));
            }
            else
            {
                var sid         = Convert.ToInt32(shopid);
                var userCoupons =
                    UserCouponBll.GetUserCouponsByUserId(Convert.ToInt32(userid))
                    .Where(p => p.IsUsed == false && p.IsUserDeleted == false && p.ShopId == sid)
                    .ToArray();
                var shopCoupon = ShopCouponBll.GetShopCouponsByShopId(sid).SingleOrDefault(p => p.CouponCode == code);
                if (shopCoupon != null && userCoupons.Count(p => p.CouponId == shopCoupon.CouponID) > 0)
                {
                    context.Response.Write(JsonConvert.SerializeObject(new { code = 1, dollor = shopCoupon.UnitCost }));
                }
                else
                {
                    context.Response.Write(JsonConvert.ToString(new { code = 0 }));
                }
            }
        }
Esempio n. 2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         var idstr = Request.QueryString["shopid"];
         int id;
         if (idstr == null || !int.TryParse(idstr, out id))
         {
             Response.Redirect("ShopList.aspx");
             return;
         }
         VisitingShop = ShopBll.GetShopById(id);
         if (VisitingShop == null)
         {
             Response.Redirect("ShopList.aspx");
             return;
         }
         YeShopCoupon = ShopCouponBll.GetShopCouponsByShopId(VisitingShop.ShopID).FirstOrDefault(c => c.BeginDate <DateTime.Now && c.EndDate> DateTime.Now);
         var sb = new StringBuilder();
         for (int i = 0; i < VisitingShop.Rank; i++)
         {
             sb.Append("<i class='fa fa-star' style='color:#F07202'></i>");
         }
         ltlRank.Text           = sb.ToString();
         rptProducts.DataSource = ProductBll.GetProductsByShopId(VisitingShop.ShopID).OrderBy(p => p.RecommendLevel).Take(10).ToList();
         rptProducts.DataBind();
         rptProductTypes.DataSource = ProductBll.GetProductTypesByShopId(VisitingShop.ShopID).Take(2).ToList();
         rptProductTypes.DataBind();
     }
 }
Esempio n. 3
0
 private void BindData()
 {
     pager1.DataItemCount = ShopCouponBll.GetShopCouponsByShopId(YeShopId).Count(o => o.IsShopDeleted == false);
     rpt.DataSource       = ShopCouponBll.GetShopCouponsByShopId(YeShopId)
                            .Where(o => o.IsShopDeleted == false)
                            .OrderBy(p => p.EndDate)
                            .Skip(pager1.PageSize * pager1.CurrentPagerIndex)
                            .Take(pager1.PageSize).ToArray();
     rpt.DataBind();
 }
Esempio n. 4
0
        //提交订单
        protected void btnOK_OnClick(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(tbxReceiver.Text))
            {
                WebUtil.Alert("请输入收货人!");
                return;
            }
            if (string.IsNullOrWhiteSpace(tbxAddress.Text))
            {
                WebUtil.Alert("请输入收货地址!");
                return;
            }
            if (string.IsNullOrWhiteSpace(tbxMobile.Text))
            {
                WebUtil.Alert("请输入收货人地址!");
                return;
            }
            if (Convert.ToDecimal(hfTotalPrice.Value) <= 0)
            {
                WebUtil.Alert("请先选好数量!");
                return;
            }
            //订单信息
            var order = new Ye_Order()
            {
                UserID          = YeUser.UserID,
                ShopID          = OrderingShop.ShopID,
                OrderSN         = lblOrderSN.Text,
                OrderDesc       = tbxOrderDesc.Text,
                OrderCreateTime = DateTime.Now,
                OrderCheckTime  = null,
                OrderPayTime    = null,
                IsUserDeleted   = false,
                IsShopDeleted   = false,
                Receiver        = tbxReceiver.Text,
                ReceiveAddress  = tbxAddress.Text,
                ReceiverMobile  = tbxMobile.Text,
                TotalPrice      = Convert.ToDecimal(hfTotalPrice.Value),
                Tax             = Convert.ToDecimal(hfFax.Value),
                OrderStatus     = (int)OrderStatus.已下单
            };

            if (!string.IsNullOrWhiteSpace(tbxCode.Text))
            {
                var coupon = ShopCouponBll.GetShopCouponsByShopId(OrderingShop.ShopID)
                             .SingleOrDefault(
                    s => s.BeginDate <DateTime.Now && s.EndDate> DateTime.Now && s.CouponCode == tbxCode.Text);
                if (coupon == null)
                {
                    WebUtil.Alert("优惠券验证码无效!");
                    return;
                }
                else
                {
                    var userCoupon =
                        UserCouponBll.GetUserCouponsByUserId(YeUser.UserID)
                        .SingleOrDefault(p => p.CouponId == coupon.CouponID);
                    if (userCoupon == null)
                    {
                        WebUtil.Alert("您没有该验证码的使用权限!");
                        return;
                    }
                    else
                    {
                        if (userCoupon.IsUsed)
                        {
                            WebUtil.Alert("该验证码已被使用作废!");
                            return;
                        }
                        else
                        {
                            UserCouponBll.UseCoupon(YeUser.UserID, userCoupon.UserCouponId);
                            order.ShopCouponID   = coupon.CouponID;
                            order.UnitCouponCost = coupon.UnitCost;
                        }
                    }
                }
                //
            }
            var orderDetails = new List <Ye_OrderDetail>();//获取订单详情

            rptProduct.Controls.OfType <RepeaterItem>().ToList().ForEach(p =>
            {
                var lbl = p.FindControl("lblAmount") as Label;
                var hf  = p.FindControl("hfAmount") as HiddenField;
                orderDetails.Add(new Ye_OrderDetail()
                {
                    ProductID = Convert.ToInt32(lbl.Attributes["data-pid"]),
                    Quantity  = Convert.ToInt32(hf.Value),
                    UnitCost  = Convert.ToDecimal(lbl.Attributes["data-unitcost"])
                });
            });
            if (OrderBll.AddOrder(order, orderDetails))
            {
                Response.Cookies["shop_" + OrderingShop.ShopID.ToString()].Expires = DateTime.Now.AddDays(-1);//清空Cookie信息
                //WebUtil.AlertAndRedirect("您的订单已提交,请等候我们的回复!","ShopDetail.aspx?shopid="+OrderingShop.ShopID);
                WebUtil.AlertAndRedirect("您的订单已提交,请等候我们的回复!", "UserOrders.aspx");
            }
        }