private void IsDiscountProduct(System.Web.HttpContext context)
        {
            int num = Globals.RequestFormNum("productId");

            if (num > 0)
            {
                LimitedTimeDiscountProductInfo discountProductInfoByProductId = LimitedTimeDiscountHelper.GetDiscountProductInfoByProductId(num);
                if (discountProductInfoByProductId != null)
                {
                    LimitedTimeDiscountInfo discountInfo = LimitedTimeDiscountHelper.GetDiscountInfo(discountProductInfoByProductId.LimitedTimeDiscountId);
                    MemberInfo currentMember             = MemberProcessor.GetCurrentMember();
                    int        num2 = 0;
                    int        num3 = discountInfo.LimitNumber;
                    if (discountInfo != null)
                    {
                        if (currentMember != null)
                        {
                            if (MemberHelper.CheckCurrentMemberIsInRange(discountInfo.ApplyMembers, discountInfo.DefualtGroup, discountInfo.CustomGroup, currentMember.UserId))
                            {
                                int limitedTimeDiscountUsedNum = ShoppingCartProcessor.GetLimitedTimeDiscountUsedNum(discountProductInfoByProductId.LimitedTimeDiscountId, null, num, currentMember.UserId, false);
                                if (discountInfo.LimitNumber == 0)
                                {
                                    num2 = discountInfo.LimitedTimeDiscountId;
                                }
                                else if (discountInfo.LimitNumber - limitedTimeDiscountUsedNum > 0)
                                {
                                    num2 = discountInfo.LimitedTimeDiscountId;
                                    num3 = discountInfo.LimitNumber - limitedTimeDiscountUsedNum;
                                }
                                else
                                {
                                    num3 = 0;
                                }
                            }
                        }
                        else
                        {
                            num2 = discountInfo.LimitedTimeDiscountId;
                        }
                    }
                    if (discountInfo != null)
                    {
                        context.Response.Write(string.Concat(new object[]
                        {
                            "{\"msg\":\"success\",\"ActivityName\":\"",
                            Globals.String2Json(discountInfo.ActivityName),
                            "\",\"FinalPrice\":\"",
                            discountProductInfoByProductId.FinalPrice.ToString("f2"),
                            "\",\"LimitedTimeDiscountId\":\"",
                            num2,
                            "\",\"LimitNumber\":\"",
                            discountInfo.LimitNumber,
                            "\",\"RemainNumber\":\"",
                            num3,
                            "\"}"
                        }));
                    }
                }
            }
        }
Beispiel #2
0
        private void IsDiscountProduct(HttpContext context)
        {
            int productId = Globals.RequestFormNum("productId");

            if (productId > 0)
            {
                LimitedTimeDiscountProductInfo discountProductInfoByProductId = LimitedTimeDiscountHelper.GetDiscountProductInfoByProductId(productId);
                if (discountProductInfoByProductId != null)
                {
                    LimitedTimeDiscountInfo discountInfo = LimitedTimeDiscountHelper.GetDiscountInfo(discountProductInfoByProductId.LimitedTimeDiscountId);
                    MemberInfo currentMember             = MemberProcessor.GetCurrentMember();
                    int        limitedTimeDiscountId     = 0;
                    if (discountInfo != null)
                    {
                        if (currentMember != null)
                        {
                            if (MemberHelper.CheckCurrentMemberIsInRange(discountInfo.ApplyMembers, discountInfo.DefualtGroup, discountInfo.CustomGroup, currentMember.UserId))
                            {
                                int num3 = ShoppingCartProcessor.GetLimitedTimeDiscountUsedNum(limitedTimeDiscountId, null, productId, currentMember.UserId, false);
                                if ((discountInfo.LimitNumber - num3) > 0)
                                {
                                    limitedTimeDiscountId = discountInfo.LimitedTimeDiscountId;
                                }
                            }
                        }
                        else
                        {
                            limitedTimeDiscountId = discountInfo.LimitedTimeDiscountId;
                        }
                    }
                    if (discountInfo != null)
                    {
                        context.Response.Write(string.Concat(new object[] { "{\"msg\":\"success\",\"ActivityName\":\"", discountInfo.ActivityName, "\",\"FinalPrice\":\"", discountProductInfoByProductId.FinalPrice.ToString("f2"), "\",\"LimitedTimeDiscountId\":\"", limitedTimeDiscountId, "\",\"LimitNumber\":\"", discountInfo.LimitNumber, "\"}" }));
                    }
                }
            }
        }
Beispiel #3
0
        protected override void AttachChildControls()
        {
            this.litShipTo       = (Literal)this.FindControl("litShipTo");
            this.litCellPhone    = (Literal)this.FindControl("litCellPhone");
            this.litAddress      = (Literal)this.FindControl("litAddress");
            this.litShowMes      = (Literal)this.FindControl("litShowMes");
            this.GetUserCoupons  = MemberProcessor.GetUserCoupons();
            this.rptCartProducts = (VshopTemplatedRepeater)this.FindControl("rptCartProducts");
            this.rptCartProducts.ItemDataBound += new RepeaterItemEventHandler(this.rptCartProducts_ItemDataBound);
            this.litOrderTotal         = (Literal)this.FindControl("litOrderTotal");
            this.litPointNumber        = (Literal)this.FindControl("litPointNumber");
            this.litDisplayPointNumber = (Literal)this.FindControl("litDisplayPointNumber");
            this.aLinkToShipping       = (HtmlAnchor)this.FindControl("aLinkToShipping");
            this.groupbuyHiddenBox     = (HtmlInputControl)this.FindControl("groupbuyHiddenBox");
            this.rptAddress            = (VshopTemplatedRepeater)this.FindControl("rptAddress");
            this.selectShipTo          = (HtmlInputHidden)this.FindControl("selectShipTo");
            this.regionId      = (HtmlInputHidden)this.FindControl("regionId");
            this.litAddAddress = (Literal)this.FindControl("litAddAddress");
            IList <ShippingAddressInfo> shippingAddresses = MemberProcessor.GetShippingAddresses();

            //if (CS$<>9__CachedAnonymousMethodDelegate2 == null)
            //{
            //    CS$<>9__CachedAnonymousMethodDelegate2 = new Func<ShippingAddressInfo, bool>(null, (IntPtr) <AttachChildControls>b__0);
            //}
            //this.rptAddress.DataSource = Enumerable.OrderBy<ShippingAddressInfo, bool>(shippingAddresses, CS$<>9__CachedAnonymousMethodDelegate2);
            //this.rptAddress.DataBind();
            //if (CS$<>9__CachedAnonymousMethodDelegate3 == null)
            //{
            //    CS$<>9__CachedAnonymousMethodDelegate3 = new Func<ShippingAddressInfo, bool>(null, (IntPtr) <AttachChildControls>b__1);
            //}
            this.rptAddress.DataSource = from item in shippingAddresses
                                         orderby item.IsDefault
                                         select item;

            this.rptAddress.DataBind();
            ShippingAddressInfo info = shippingAddresses.FirstOrDefault <ShippingAddressInfo>(item => item.IsDefault);

            //ShippingAddressInfo info = Enumerable.FirstOrDefault<ShippingAddressInfo>(shippingAddresses, CS$<>9__CachedAnonymousMethodDelegate3);
            if (info == null)
            {
                info = (shippingAddresses.Count > 0) ? shippingAddresses[0] : null;
            }
            if (info != null)
            {
                this.litShipTo.Text    = info.ShipTo;
                this.litCellPhone.Text = info.CellPhone;
                this.litAddress.Text   = info.Address;
                this.selectShipTo.SetWhenIsNotNull(info.ShippingId.ToString());
                this.regionId.SetWhenIsNotNull(info.RegionId.ToString());
            }
            this.litAddAddress.Text = " href='/Vshop/AddShippingAddress.aspx?returnUrl=" + Globals.UrlEncode(HttpContext.Current.Request.Url.ToString()) + "'";
            if ((shippingAddresses == null) || (shippingAddresses.Count == 0))
            {
                this.Page.Response.Redirect(Globals.ApplicationPath + "/Vshop/AddShippingAddress.aspx?returnUrl=" + Globals.UrlEncode(HttpContext.Current.Request.Url.ToString()));
            }
            else
            {
                this.aLinkToShipping.HRef = Globals.ApplicationPath + "/Vshop/ShippingAddresses.aspx?returnUrl=" + Globals.UrlEncode(HttpContext.Current.Request.Url.ToString());
                List <ShoppingCartInfo> orderSummitCart = new List <ShoppingCartInfo>();
                if (((int.TryParse(this.Page.Request.QueryString["buyAmount"], out this.buyAmount) && !string.IsNullOrEmpty(this.Page.Request.QueryString["productSku"])) && !string.IsNullOrEmpty(this.Page.Request.QueryString["from"])) && ((this.Page.Request.QueryString["from"] == "signBuy") || (this.Page.Request.QueryString["from"] == "groupBuy")))
                {
                    this.productSku = this.Page.Request.QueryString["productSku"];
                    if (this.isbargain)
                    {
                        int bargainDetialId = Globals.RequestQueryNum("bargainDetialId");
                        orderSummitCart = ShoppingCartProcessor.GetListShoppingCart(this.productSku, this.buyAmount, bargainDetialId, 0);
                    }
                    else
                    {
                        int buyAmount = this.buyAmount;
                        int id        = Globals.RequestQueryNum("limitedTimeDiscountId");
                        if (id > 0)
                        {
                            bool flag = true;
                            LimitedTimeDiscountInfo discountInfo = LimitedTimeDiscountHelper.GetDiscountInfo(id);
                            if (discountInfo == null)
                            {
                                flag = false;
                            }
                            if (flag)
                            {
                                int num4 = ShoppingCartProcessor.GetLimitedTimeDiscountUsedNum(id, this.productSku, 0, base.CurrentMemberInfo.UserId, false);
                                if (MemberHelper.CheckCurrentMemberIsInRange(discountInfo.ApplyMembers, discountInfo.DefualtGroup, discountInfo.CustomGroup, base.CurrentMemberInfo.UserId))
                                {
                                    if ((discountInfo.LimitNumber > 0) && (this.buyAmount <= (discountInfo.LimitNumber - num4)))
                                    {
                                        buyAmount = discountInfo.LimitNumber - num4;
                                        if (buyAmount > this.buyAmount)
                                        {
                                            buyAmount = this.buyAmount;
                                        }
                                    }
                                    else if (discountInfo.LimitNumber != 0)
                                    {
                                        id = 0;
                                    }
                                }
                                else
                                {
                                    id = 0;
                                }
                            }
                            else
                            {
                                id = 0;
                            }
                        }
                        orderSummitCart = ShoppingCartProcessor.GetListShoppingCart(this.productSku, buyAmount, 0, id);
                    }
                }
                else
                {
                    orderSummitCart = ShoppingCartProcessor.GetOrderSummitCart();
                }
                if (orderSummitCart == null)
                {
                    HttpContext.Current.Response.Write("<script>alert('商品已下架或没有需要结算的订单!');location.href='/Vshop/ShoppingCart.aspx'</script>");
                }
                else
                {
                    if (orderSummitCart.Count > 1)
                    {
                        this.litShowMes.Text = "<div style=\"color: #F60; \"><img  src=\"/Utility/pics/u77.png\">您所购买的商品不支持同一个物流规则发货,系统自动拆分成多个子订单处理</div>";
                    }
                    this.rptCartProducts.DataSource = orderSummitCart;
                    this.rptCartProducts.DataBind();
                    decimal num5 = 0M;
                    decimal num6 = 0M;
                    decimal num7 = 0M;
                    int     num8 = 0;
                    foreach (ShoppingCartInfo info3 in orderSummitCart)
                    {
                        num8 += info3.GetPointNumber;
                        num5 += info3.Total;
                        num6 += info3.Exemption;
                        num7 += info3.ShipCost;
                    }
                    decimal num9 = num6;
                    this.litOrderTotal.Text = (num5 - num9).ToString("F2");
                    if (num8 == 0)
                    {
                        this.litDisplayPointNumber.Text = "style=\"display:none;\"";
                    }
                    this.litPointNumber.Text = num8.ToString();
                    PageTitle.AddSiteNameTitle("订单确认");
                }
            }
        }
Beispiel #4
0
 private void rptCartProducts_ItemDataBound(object sender, RepeaterItemEventArgs e)
 {
     if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem))
     {
         int     num;
         decimal num2;
         List <ShoppingCartItemInfo> list = (List <ShoppingCartItemInfo>)DataBinder.Eval(e.Item.DataItem, "LineItems");
         Literal literal = (Literal)e.Item.Controls[0].FindControl("LitCoupon");
         //Literal literal2 = (Literal)e.Item.Controls[0].FindControl("litExemption");
         //Literal literal3 = (Literal)e.Item.Controls[0].FindControl("litoldExemption");
         //Literal literal4 = (Literal)e.Item.Controls[0].FindControl("litoldTotal");
         //Literal literal5 = (Literal)e.Item.Controls[0].FindControl("litTotal");
         //Literal literal6 = (Literal)e.Item.Controls[0].FindControl("litbFreeShipping");
         string str  = "";
         string str2 = " <div class=\"btn-group coupon\">";
         object obj2 = str2;
         obj2 = string.Concat(new object[] { obj2, "<button type=\"button\" class=\"btn btn-default dropdown-toggle coupondropdown\" data-toggle=\"dropdown\"   id='coupondropdown", DataBinder.Eval(e.Item.DataItem, "TemplateId"), "'>选择优惠券<span class=\"caret\"></span></button>" });
         str2 = string.Concat(new object[] { obj2, "<ul id=\"coupon", DataBinder.Eval(e.Item.DataItem, "TemplateId"), "\" class=\"dropdown-menu\" role=\"menu\">" });
         if (!((this.GetUserCoupons.Rows.Count <= 0) || this.isbargain))
         {
             obj2 = str;
             str  = string.Concat(new object[] { obj2, "<li><a onclick=\"Couponasetselect('", DataBinder.Eval(e.Item.DataItem, "TemplateId"), "','不使用','0',0,'0')\"   value=\"0\">不使用</a></li>" });
         }
         if (!this.isbargain)
         {
             num = 0;
             while (num < this.GetUserCoupons.Rows.Count)
             {
                 if ((this.GetUserCoupons.Rows[num]["MemberGrades"].ToString() == "0") || (this.GetUserCoupons.Rows[num]["MemberGrades"].ToString() == base.CurrentMemberInfo.GradeId.ToString()))
                 {
                     if (bool.Parse(this.GetUserCoupons.Rows[num]["IsAllProduct"].ToString()))
                     {
                         num2 = 0M;
                         foreach (ShoppingCartItemInfo info in list)
                         {
                             if (info.Type == 0)
                             {
                                 num2 += info.SubTotal;
                             }
                         }
                         if (decimal.Parse(this.GetUserCoupons.Rows[num]["ConditionValue"].ToString()) <= num2)
                         {
                             obj2 = str;
                             str  = string.Concat(new object[] {
                                 obj2, "<li><a onclick=\"Couponasetselect('", DataBinder.Eval(e.Item.DataItem, "TemplateId"), "','", this.GetUserCoupons.Rows[num]["CouponValue"], "元现金券','", this.GetUserCoupons.Rows[num]["CouponValue"], "',", this.GetUserCoupons.Rows[num]["Id"], ",'", this.GetUserCoupons.Rows[num]["CouponValue"], "元现金券|", this.GetUserCoupons.Rows[num]["Id"], "|", this.GetUserCoupons.Rows[num]["ConditionValue"], "|",
                                 this.GetUserCoupons.Rows[num]["CouponValue"], "')\" id=\"acoupon", DataBinder.Eval(e.Item.DataItem, "TemplateId"), this.GetUserCoupons.Rows[num]["Id"], "\" value=\"", this.GetUserCoupons.Rows[num]["Id"], "\">", this.GetUserCoupons.Rows[num]["CouponValue"], "元现金券</a></li>"
                             });
                         }
                     }
                     else
                     {
                         num2 = 0M;
                         bool flag = false;
                         foreach (ShoppingCartItemInfo info in list)
                         {
                             if ((info.Type == 0) && (MemberProcessor.GetCouponByProducts(int.Parse(this.GetUserCoupons.Rows[num]["CouponId"].ToString()), info.ProductId).Rows.Count > 0))
                             {
                                 num2 += info.SubTotal;
                                 flag  = true;
                             }
                         }
                         if (flag && (decimal.Parse(this.GetUserCoupons.Rows[num]["ConditionValue"].ToString()) <= num2))
                         {
                             obj2 = str;
                             str  = string.Concat(new object[] {
                                 obj2, "<li><a onclick=\"Couponasetselect('", DataBinder.Eval(e.Item.DataItem, "TemplateId"), "','", this.GetUserCoupons.Rows[num]["CouponValue"], "元现金券','", this.GetUserCoupons.Rows[num]["CouponValue"], "',", this.GetUserCoupons.Rows[num]["Id"], ",'", this.GetUserCoupons.Rows[num]["CouponValue"], "元现金券|", this.GetUserCoupons.Rows[num]["Id"], "|", this.GetUserCoupons.Rows[num]["ConditionValue"], "|",
                                 this.GetUserCoupons.Rows[num]["CouponValue"], "')\" id=\"acoupon", DataBinder.Eval(e.Item.DataItem, "TemplateId"), this.GetUserCoupons.Rows[num]["Id"], "\" value=\"", this.GetUserCoupons.Rows[num]["Id"], "\">", this.GetUserCoupons.Rows[num]["CouponValue"], "元现金券</a></li>"
                             });
                         }
                     }
                 }
                 num++;
             }
         }
         obj2 = str2 + str;
         str2 = string.Concat(new object[] { obj2, "</ul></div><input type=\"hidden\"  class=\"ClassCoupon\"   id=\"selectCoupon", DataBinder.Eval(e.Item.DataItem, "TemplateId"), "\"/>  " });
         if (!string.IsNullOrEmpty(str))
         {
             literal.Text = string.Concat(new object[] { str2, "<input type=\"hidden\"   id='selectCouponValue", DataBinder.Eval(e.Item.DataItem, "TemplateId"), "' class=\"selectCouponValue\" />" });
         }
         else
         {
             literal.Text = "<input type=\"hidden\"   id='selectCouponValue" + DataBinder.Eval(e.Item.DataItem, "TemplateId") + "' class=\"selectCouponValue\" />";
         }
         decimal num3 = 0M;
         decimal num4 = 0M;
         decimal num5 = 0M;
         decimal num6 = 0M;
         decimal num7 = 0M;
         int     num8 = 0;
         foreach (ShoppingCartItemInfo info2 in list)
         {
             if (info2.Type == 0)
             {
                 num7 += info2.SubTotal;
                 num8 += info2.Quantity;
             }
         }
         num6 = num7;
         if (!this.isbargain)
         {
             for (int i = 0; i < this.dtActivities.Rows.Count; i++)
             {
                 if ((int.Parse(this.dtActivities.Rows[i]["attendTime"].ToString()) != 0) && (int.Parse(this.dtActivities.Rows[i]["attendTime"].ToString()) <= ActivityHelper.GetActivitiesMember(base.CurrentMemberInfo.UserId, int.Parse(this.dtActivities.Rows[i]["ActivitiesId"].ToString()))))
                 {
                     continue;
                 }
                 num2 = 0M;
                 int       num10  = 0;
                 DataTable table2 = ActivityHelper.GetActivities_Detail(int.Parse(this.dtActivities.Rows[i]["ActivitiesId"].ToString()));
                 foreach (ShoppingCartItemInfo info2 in list)
                 {
                     if ((info2.Type == 0) && (ActivityHelper.GetActivitiesProducts(int.Parse(this.dtActivities.Rows[i]["ActivitiesId"].ToString()), info2.ProductId).Rows.Count > 0))
                     {
                         num2  += info2.SubTotal;
                         num10 += info2.Quantity;
                     }
                 }
                 bool flag2 = false;
                 if (table2.Rows.Count > 0)
                 {
                     for (num = 0; num < table2.Rows.Count; num++)
                     {
                         if (MemberHelper.CheckCurrentMemberIsInRange(table2.Rows[num]["MemberGrades"].ToString(), table2.Rows[num]["DefualtGroup"].ToString(), table2.Rows[num]["CustomGroup"].ToString(), base.CurrentMemberInfo.UserId))
                         {
                             if (bool.Parse(this.dtActivities.Rows[i]["isAllProduct"].ToString()))
                             {
                                 if (decimal.Parse(table2.Rows[num]["MeetMoney"].ToString()) > 0M)
                                 {
                                     if ((num7 != 0M) && (num7 >= decimal.Parse(table2.Rows[table2.Rows.Count - 1]["MeetMoney"].ToString())))
                                     {
                                         num4 = decimal.Parse(table2.Rows[table2.Rows.Count - 1]["MeetMoney"].ToString());
                                         num3 = decimal.Parse(table2.Rows[table2.Rows.Count - 1]["ReductionMoney"].ToString());
                                         //literal6.Text = table2.Rows[table2.Rows.Count - 1]["bFreeShipping"].ToString();
                                         break;
                                     }
                                     if ((num7 != 0M) && (num7 <= decimal.Parse(table2.Rows[0]["MeetMoney"].ToString())))
                                     {
                                         num4 = decimal.Parse(table2.Rows[0]["MeetMoney"].ToString());
                                         num3 = decimal.Parse(table2.Rows[0]["ReductionMoney"].ToString());
                                         break;
                                     }
                                     if ((num7 != 0M) && (num7 >= decimal.Parse(table2.Rows[num]["MeetMoney"].ToString())))
                                     {
                                         num4 = decimal.Parse(table2.Rows[num]["MeetMoney"].ToString());
                                         num3 = decimal.Parse(table2.Rows[num]["ReductionMoney"].ToString());
                                         //literal6.Text = table2.Rows[num]["bFreeShipping"].ToString();
                                     }
                                 }
                                 else
                                 {
                                     if ((num8 != 0) && (num8 >= int.Parse(table2.Rows[table2.Rows.Count - 1]["MeetNumber"].ToString())))
                                     {
                                         num4  = decimal.Parse(table2.Rows[table2.Rows.Count - 1]["MeetMoney"].ToString());
                                         num5  = decimal.Parse(table2.Rows[table2.Rows.Count - 1]["ReductionMoney"].ToString());
                                         flag2 = true;
                                         //literal6.Text = table2.Rows[table2.Rows.Count - 1]["bFreeShipping"].ToString();
                                         break;
                                     }
                                     if ((num8 != 0) && (num8 <= int.Parse(table2.Rows[0]["MeetNumber"].ToString())))
                                     {
                                         num4  = decimal.Parse(table2.Rows[0]["MeetMoney"].ToString());
                                         num5  = decimal.Parse(table2.Rows[0]["ReductionMoney"].ToString());
                                         flag2 = true;
                                         break;
                                     }
                                     if ((num8 != 0) && (num8 >= int.Parse(table2.Rows[num]["MeetNumber"].ToString())))
                                     {
                                         num4  = decimal.Parse(table2.Rows[num]["MeetMoney"].ToString());
                                         num5  = decimal.Parse(table2.Rows[num]["ReductionMoney"].ToString());
                                         flag2 = true;
                                         //literal6.Text = table2.Rows[num]["bFreeShipping"].ToString();
                                     }
                                 }
                             }
                             else
                             {
                                 num7 = num2;
                                 num8 = num10;
                                 if (decimal.Parse(table2.Rows[num]["MeetMoney"].ToString()) > 0M)
                                 {
                                     if ((num7 != 0M) && (num7 >= decimal.Parse(table2.Rows[table2.Rows.Count - 1]["MeetMoney"].ToString())))
                                     {
                                         num4 = decimal.Parse(table2.Rows[table2.Rows.Count - 1]["MeetMoney"].ToString());
                                         num3 = decimal.Parse(table2.Rows[table2.Rows.Count - 1]["ReductionMoney"].ToString());
                                         //literal6.Text = table2.Rows[table2.Rows.Count - 1]["bFreeShipping"].ToString();
                                         break;
                                     }
                                     if ((num7 != 0M) && (num7 <= decimal.Parse(table2.Rows[0]["MeetMoney"].ToString())))
                                     {
                                         num4 = decimal.Parse(table2.Rows[0]["MeetMoney"].ToString());
                                         num3 = decimal.Parse(table2.Rows[0]["ReductionMoney"].ToString());
                                         break;
                                     }
                                     if ((num7 != 0M) && (num7 >= decimal.Parse(table2.Rows[num]["MeetMoney"].ToString())))
                                     {
                                         num4 = decimal.Parse(table2.Rows[num]["MeetMoney"].ToString());
                                         num3 = decimal.Parse(table2.Rows[num]["ReductionMoney"].ToString());
                                         //literal6.Text = table2.Rows[num]["bFreeShipping"].ToString();
                                     }
                                 }
                                 else
                                 {
                                     if ((num8 != 0) && (num8 >= int.Parse(table2.Rows[table2.Rows.Count - 1]["MeetNumber"].ToString())))
                                     {
                                         num4  = decimal.Parse(table2.Rows[table2.Rows.Count - 1]["MeetMoney"].ToString());
                                         num3  = decimal.Parse(table2.Rows[table2.Rows.Count - 1]["ReductionMoney"].ToString());
                                         flag2 = true;
                                         //literal6.Text = table2.Rows[table2.Rows.Count - 1]["bFreeShipping"].ToString();
                                         break;
                                     }
                                     if ((num8 != 0) && (num8 <= int.Parse(table2.Rows[0]["MeetNumber"].ToString())))
                                     {
                                         num4  = decimal.Parse(table2.Rows[0]["MeetMoney"].ToString());
                                         num3  = decimal.Parse(table2.Rows[0]["ReductionMoney"].ToString());
                                         flag2 = true;
                                         break;
                                     }
                                     if ((num8 != 0) && (num8 >= int.Parse(table2.Rows[num]["MeetNumber"].ToString())))
                                     {
                                         num4  = decimal.Parse(table2.Rows[num]["MeetMoney"].ToString());
                                         num3  = decimal.Parse(table2.Rows[num]["ReductionMoney"].ToString());
                                         flag2 = true;
                                         //literal6.Text = table2.Rows[num]["bFreeShipping"].ToString();
                                     }
                                 }
                             }
                         }
                     }
                     if (flag2)
                     {
                         if (num8 > 0)
                         {
                             num5 += num3;
                         }
                     }
                     else if (((num7 != 0M) && (num4 != 0M)) && (num7 >= num4))
                     {
                         num5 += num3;
                     }
                 }
             }
         }
         //literal2.Text = num5.ToString("F2");
         //literal3.Text = num5.ToString("F2");
         decimal num12 = num6 - num5;
         //literal5.Text = num12.ToString("F2");
         //literal4.Text = (num6 - num5).ToString("F2");
     }
 }
Beispiel #5
0
        protected override void AttachChildControls()
        {
            this.Vaid = Globals.RequestQueryStr("vaid");
            if (string.IsNullOrEmpty(this.Vaid))
            {
                base.GotoResourceNotFound("");
            }
            OneyuanTaoInfo oneyuanTaoInfoById = OneyuanTaoHelp.GetOneyuanTaoInfoById(this.Vaid);

            if (oneyuanTaoInfoById == null)
            {
                base.GotoResourceNotFound("");
            }
            this.productId = oneyuanTaoInfoById.ProductId;
            ProductInfo product = ProductBrowser.GetProduct(MemberProcessor.GetCurrentMember(), this.productId);

            if (product == null)
            {
                base.GotoResourceNotFound("");
            }
            OneTaoState oneTaoState = OneyuanTaoHelp.getOneTaoState(oneyuanTaoInfoById);

            this.rptProductImages      = (VshopTemplatedRepeater)this.FindControl("rptProductImages");
            this.litItemParams         = (System.Web.UI.WebControls.Literal) this.FindControl("litItemParams");
            this.litProdcutName        = (System.Web.UI.WebControls.Literal) this.FindControl("litProdcutName");
            this.litProdcutTag         = (System.Web.UI.WebControls.Literal) this.FindControl("litProdcutTag");
            this.litSalePrice          = (System.Web.UI.WebControls.Literal) this.FindControl("litSalePrice");
            this.litMarketPrice        = (System.Web.UI.WebControls.Literal) this.FindControl("litMarketPrice");
            this.litShortDescription   = (System.Web.UI.WebControls.Literal) this.FindControl("litShortDescription");
            this.litDescription        = (System.Web.UI.WebControls.Literal) this.FindControl("litDescription");
            this.litStock              = (System.Web.UI.WebControls.Literal) this.FindControl("litStock");
            this.litSoldCount          = (System.Web.UI.WebControls.Literal) this.FindControl("litSoldCount");
            this.litConsultationsCount = (System.Web.UI.WebControls.Literal) this.FindControl("litConsultationsCount");
            this.litReviewsCount       = (System.Web.UI.WebControls.Literal) this.FindControl("litReviewsCount");
            this.litActivityId         = (System.Web.UI.WebControls.Literal) this.FindControl("litActivityId");
            this.litState              = (System.Web.UI.WebControls.Literal) this.FindControl("litState");
            this.PrizeTime             = (System.Web.UI.HtmlControls.HtmlControl) this.FindControl("PrizeTime");
            this.buyNum           = (System.Web.UI.HtmlControls.HtmlControl) this.FindControl("buyNum");
            this.SaveBtn          = (System.Web.UI.HtmlControls.HtmlControl) this.FindControl("SaveBtn");
            this.ViewtReview      = (System.Web.UI.HtmlControls.HtmlControl) this.FindControl("ViewtReview");
            this.litMaxtxt        = (System.Web.UI.WebControls.Literal) this.FindControl("litMaxtxt");
            this.expandAttr       = (Common_ExpandAttributes)this.FindControl("ExpandAttributes");
            this.skuSelector      = (Common_SKUSelector)this.FindControl("skuSelector");
            this.NomachMember     = (System.Web.UI.HtmlControls.HtmlContainerControl) this.FindControl("NomachMember");
            this.litMinNum        = (System.Web.UI.WebControls.Literal) this.FindControl("litMinNum");
            this.litPrizeNum      = (System.Web.UI.WebControls.Literal) this.FindControl("litPrizeNum");
            this.litFinished      = (System.Web.UI.WebControls.Literal) this.FindControl("litFinished");
            this.Prizeprogress    = (System.Web.UI.HtmlControls.HtmlControl) this.FindControl("Prizeprogress");
            this.litBuytxt        = (System.Web.UI.WebControls.Literal) this.FindControl("litBuytxt");
            this.litPrizeNum.Text = oneyuanTaoInfoById.ReachNum.ToString();
            this.litFinished.Text = oneyuanTaoInfoById.FinishedNum.ToString();
            int num = oneyuanTaoInfoById.ReachNum - oneyuanTaoInfoById.FinishedNum;

            if (num < 0)
            {
                num = 0;
            }
            this.litMinNum.Text = num.ToString();
            float num2 = (float)(100 * oneyuanTaoInfoById.FinishedNum / oneyuanTaoInfoById.ReachNum);

            this.Prizeprogress.Attributes.Add("style", "width:" + num2.ToString("F0") + "%");
            this.ViewtReview.Attributes.Add("href", "ProductReview.aspx?ProductId=" + oneyuanTaoInfoById.ProductId.ToString());
            if (this.expandAttr != null)
            {
                this.expandAttr.ProductId = this.productId;
            }
            this.skuSelector.ProductId = this.productId;
            if (product != null)
            {
                if (this.rptProductImages != null)
                {
                    string       locationUrl = "javascript:;";
                    SlideImage[] source      = new SlideImage[]
                    {
                        new SlideImage(product.ImageUrl1, locationUrl),
                        new SlideImage(product.ImageUrl2, locationUrl),
                        new SlideImage(product.ImageUrl3, locationUrl),
                        new SlideImage(product.ImageUrl4, locationUrl),
                        new SlideImage(product.ImageUrl5, locationUrl)
                    };
                    this.rptProductImages.DataSource = from item in source
                                                       where !string.IsNullOrWhiteSpace(item.ImageUrl)
                                                       select item;
                    this.rptProductImages.DataBind();
                }
                this.litShortDescription.Text = product.ShortDescription;
            }
            int num3 = OneyuanTaoHelp.MermberCanbuyNum(oneyuanTaoInfoById.ActivityId, Globals.GetCurrentMemberUserId());

            this.buyNum.Attributes.Add("max", num3.ToString());
            this.litBuytxt.Text = string.Concat(new object[]
            {
                "限购",
                oneyuanTaoInfoById.EachCanBuyNum,
                "份,每份价格¥",
                oneyuanTaoInfoById.EachPrice.ToString("F2")
            });
            this.litMaxtxt.Text = "您已订购<di>" + (oneyuanTaoInfoById.EachCanBuyNum - num3).ToString() + "</di>份";
            if (num3 == 0 || oneTaoState != OneTaoState.进行中 || !MemberHelper.CheckCurrentMemberIsInRange(oneyuanTaoInfoById.FitMember, oneyuanTaoInfoById.DefualtGroup, oneyuanTaoInfoById.CustomGroup, this.CurrentMemberInfo.UserId))
            {
                this.buyNum.Attributes.Add("disabled", "disabled");
                this.SaveBtn.Visible = false;
            }
            string text;

            if (oneyuanTaoInfoById.FitMember == "0" || oneyuanTaoInfoById.CustomGroup == "0")
            {
                text = "全部会员";
            }
            else
            {
                text = "部分会员";
            }
            text = "适用会员:" + text;
            if (oneyuanTaoInfoById.FitMember != "0" && !MemberHelper.CheckCurrentMemberIsInRange(oneyuanTaoInfoById.FitMember, oneyuanTaoInfoById.DefualtGroup, oneyuanTaoInfoById.CustomGroup, this.CurrentMemberInfo.UserId))
            {
                text = "会员等级不符合活动要求";
                this.NomachMember.Attributes.Add("CanBuy", "false");
            }
            this.NomachMember.InnerHtml = text;
            string productName = product.ProductName;
            string text2       = product.Description;

            if (!string.IsNullOrEmpty(text2))
            {
                text2 = System.Text.RegularExpressions.Regex.Replace(text2, "<img[^>]*\\bsrc=('|\")([^'\">]*)\\1[^>]*>", "<img alt='" + System.Web.HttpContext.Current.Server.HtmlEncode(productName) + "' src='$2' />", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
            }
            if (this.litDescription != null)
            {
                this.litDescription.Text = text2;
            }
            this.litProdcutName.Text = productName;
            this.litSalePrice.Text   = product.MinSalePrice.ToString("F2");
            this.litActivityId.Text  = oneyuanTaoInfoById.ActivityId;
            if (oneyuanTaoInfoById.ReachType == 1)
            {
                this.litActivityId.Text = "活动结束前满足总需份数,自动开出" + oneyuanTaoInfoById.PrizeNumber + "个奖品";
            }
            else if (oneyuanTaoInfoById.ReachType == 2)
            {
                this.litActivityId.Text = "活动到期自动开出" + oneyuanTaoInfoById.PrizeNumber + "个奖品";
            }
            else if (oneyuanTaoInfoById.ReachType == 3)
            {
                this.litActivityId.Text = "到开奖时间并满足总需份数,自动开出" + oneyuanTaoInfoById.PrizeNumber + "个奖品";
            }
            this.PrizeTime.Attributes.Add("PrizeTime", oneyuanTaoInfoById.EndTime.ToString("G"));
            this.litState.Text = oneTaoState.ToString();
            if (oneTaoState == OneTaoState.已开奖)
            {
                IsoDateTimeConverter isoDateTimeConverter = new IsoDateTimeConverter();
                isoDateTimeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
                System.Web.UI.WebControls.Literal           literal            = (System.Web.UI.WebControls.Literal) this.FindControl("LitDataJson");
                System.Collections.Generic.IList <LuckInfo> winnerLuckInfoList = OneyuanTaoHelp.getWinnerLuckInfoList(oneyuanTaoInfoById.ActivityId, "");
                if (winnerLuckInfoList != null)
                {
                    literal.Text = "var LitDataJson=" + JsonConvert.SerializeObject(winnerLuckInfoList, new JsonConverter[]
                    {
                        isoDateTimeConverter
                    });
                }
                else
                {
                    literal.Text = "var LitDataJson=null";
                }
            }
            System.Web.UI.WebControls.Literal literal2 = (System.Web.UI.WebControls.Literal) this.FindControl("litJs");
            string title       = oneyuanTaoInfoById.Title;
            string activityDec = oneyuanTaoInfoById.ActivityDec;

            System.Uri url   = this.Context.Request.Url;
            string     text3 = url.Scheme + "://" + url.Host + ((url.Port == 80) ? "" : (":" + url.Port.ToString()));
            string     text4 = oneyuanTaoInfoById.ProductImg;

            if (text4 == "/utility/pics/none.gif")
            {
                text4 = oneyuanTaoInfoById.HeadImgage;
            }
            literal2.Text = string.Concat(new string[]
            {
                "<script>wxinshare_title=\"",
                this.Context.Server.HtmlEncode(title.Replace("\n", " ").Replace("\r", "")),
                "\";wxinshare_desc=\"",
                this.Context.Server.HtmlEncode(activityDec.Replace("\n", " ").Replace("\r", "")),
                "\";wxinshare_link=location.href;wxinshare_imgurl=\"",
                text3,
                text4,
                "\"</script>"
            });
            PageTitle.AddSiteNameTitle("一元夺宝商品详情");
        }
        protected override void AttachChildControls()
        {
            this.objRadio             = new HtmlInputRadioButton[3];
            this.objRadio[0]          = (HtmlInputRadioButton)this.FindControl("OS1");
            this.objRadio[1]          = (HtmlInputRadioButton)this.FindControl("OS2");
            this.objRadio[2]          = (HtmlInputRadioButton)this.FindControl("OS3");
            this.objRadio[1].Disabled = true;
            this.objRadio[2].Disabled = true;
            this.dtGeadeInfo          = MemberProcessor.dtGetGradeInfofromUserId();
            if (this.dtGeadeInfo.Rows.Count > 0)
            {
                if ((bool)this.dtGeadeInfo.Rows[0]["IsDaifa"] == false && (bool)this.dtGeadeInfo.Rows[0]["IsPifa"] == false)
                {
                    this.objRadio[0].Disabled = false;
                    this.objRadio[0].Checked  = true;
                    this.objRadio[1].Checked  = false;
                    this.objRadio[2].Checked  = false;
                }
                if ((bool)this.dtGeadeInfo.Rows[0]["IsDaifa"] == true)
                {
                    this.objRadio[0].Disabled = true;
                    this.objRadio[1].Disabled = false;
                    this.objRadio[0].Checked  = false;
                    this.objRadio[1].Checked  = true;
                    this.objRadio[2].Checked  = false;
                }
                else
                {
                    this.objRadio[1].Disabled = true;
                }
                if ((bool)this.dtGeadeInfo.Rows[0]["IsPifa"] == true)
                {
                    this.objRadio[0].Disabled = true;
                    this.objRadio[2].Disabled = false;
                    this.objRadio[0].Checked  = false;
                    this.objRadio[1].Checked  = false;
                    this.objRadio[2].Checked  = true;
                }
                else
                {
                    this.objRadio[2].Disabled = true;
                }
            }
            switch (this.Page.Request.QueryString["GSO"])
            {
            case "0":
                this.objRadio[0].Checked = true;
                this.objRadio[1].Checked = false;
                this.objRadio[2].Checked = false;
                break;

            case "1":
                this.objRadio[0].Checked = false;
                this.objRadio[1].Checked = true;
                this.objRadio[2].Checked = false;
                break;

            case "2":
                this.objRadio[0].Checked = false;
                this.objRadio[1].Checked = false;
                this.objRadio[2].Checked = true;
                break;
            }
            this.litShipTo       = (Literal)this.FindControl("litShipTo");
            this.litIsUseBalance = (Literal)this.FindControl("litIsUseBalance");
            this.litCellPhone    = (Literal)this.FindControl("litCellPhone");
            this.litAddress      = (Literal)this.FindControl("litAddress");
            this.litShowMes      = (Literal)this.FindControl("litShowMes");
            this.GetUserCoupons  = MemberProcessor.GetUserCoupons();
            this.rptCartProducts = (VshopTemplatedRepeater)this.FindControl("rptCartProducts");
            this.rptCartProducts.ItemDataBound += new RepeaterItemEventHandler(this.rptCartProducts_ItemDataBound);
            this.litOrderTotal          = (Literal)this.FindControl("litOrderTotal");
            this.litPointNumber         = (Literal)this.FindControl("litPointNumber");
            this.litUseMembersPointShow = (Literal)this.FindControl("litUseMembersPointShow");
            this.litDisplayPointNumber  = (Literal)this.FindControl("litDisplayPointNumber");
            this.litDisplayPoint        = (Literal)this.FindControl("litDisplayPoint");
            this.BalanceCanPayMoney     = (HtmlInputHidden)this.FindControl("BalanceCanPayMoney");
            this.groupbuyHiddenBox      = (HtmlInputControl)this.FindControl("groupbuyHiddenBox");
            this.rptAddress             = (VshopTemplatedRepeater)this.FindControl("rptAddress");
            this.selectShipTo           = (HtmlInputHidden)this.FindControl("selectShipTo");
            this.MembersPointMoney      = (HtmlInputHidden)this.FindControl("MembersPointMoney");
            this.regionId             = (HtmlInputHidden)this.FindControl("regionId");
            this.litAddAddress        = (Literal)this.FindControl("litAddAddress");
            this.litServiceMoney      = (Literal)this.FindControl("litServiceMoney");
            this.litServiceMoney.Text = "0.00";
            IList <ShippingAddressInfo> shippingAddresses = MemberProcessor.GetShippingAddresses();

            if (!this.objRadio[2].Checked == true)
            {
                this.rptAddress.DataSource = from item in shippingAddresses
                                             orderby item.IsDefault
                                             select item;
                this.rptAddress.DataBind();
                ShippingAddressInfo info = shippingAddresses.FirstOrDefault <ShippingAddressInfo>(item => item.IsDefault);
                if (info == null)
                {
                    info = (shippingAddresses.Count > 0) ? shippingAddresses[0] : null;
                }
                if (info != null)
                {
                    this.litShipTo.Text    = info.ShipTo;
                    this.litCellPhone.Text = info.CellPhone;
                    this.litAddress.Text   = info.Address;
                    this.selectShipTo.SetWhenIsNotNull(info.ShippingId.ToString());
                    this.regionId.SetWhenIsNotNull(info.RegionId.ToString());
                }
                this.litAddAddress.Text = "<li><a href='/Vshop/AddShippingAddress.aspx?returnUrl=" + Globals.UrlEncode(HttpContext.Current.Request.Url.ToString()) + "'>新增收货地址</a></li>";
            }
            else
            {
                MemberInfo          member = MemberHelper.GetMember(Globals.GetCurrentMemberUserId(false));
                ShippingAddressInfo sai    = new ShippingAddressInfo();
                sai.Address       = member.Address;
                sai.CellPhone     = member.CellPhone;
                sai.IsDefault     = true;
                sai.RegionId      = member.RegionId;
                sai.ShippingId    = 999;
                sai.ShipTo        = member.RealName;
                sai.TelPhone      = member.CellPhone;
                sai.UserId        = Globals.GetCurrentMemberUserId(false);
                sai.Zipcode       = "";
                shippingAddresses = new List <ShippingAddressInfo>();
                shippingAddresses.Add(sai);
                this.rptAddress.DataSource = from item in shippingAddresses
                                             orderby item.IsDefault
                                             select item;
                this.rptAddress.DataBind();
                ShippingAddressInfo info = shippingAddresses.FirstOrDefault <ShippingAddressInfo>(item => item.IsDefault);
                if (info == null)
                {
                    info = (shippingAddresses.Count > 0) ? shippingAddresses[0] : null;
                }
                if (info != null)
                {
                    this.litShipTo.Text    = info.ShipTo;
                    this.litCellPhone.Text = info.CellPhone;
                    this.litAddress.Text   = info.Address;
                    this.selectShipTo.SetWhenIsNotNull(info.ShippingId.ToString());
                    this.regionId.SetWhenIsNotNull(info.RegionId.ToString());
                }
                this.litAddAddress.Text = "<li><a href='" + this.Page.Request.Url.ToString() + "'>批发订单不能指定收货地址,如需修改批发订单收货地址,请与管理员联系</a></li>";
            }
            if (((shippingAddresses == null) || (shippingAddresses.Count == 0)) && !this.objRadio[2].Checked == true)
            {
                this.Page.Response.Redirect(Globals.ApplicationPath + "/Vshop/AddShippingAddress.aspx?returnUrl=" + Globals.UrlEncode(HttpContext.Current.Request.Url.ToString()));
            }
            else
            {
                List <ShoppingCartInfo> orderSummitCart = new List <ShoppingCartInfo>();
                if (((int.TryParse(this.Page.Request.QueryString["buyAmount"], out this.buyAmount) && !string.IsNullOrEmpty(this.Page.Request.QueryString["productSku"])) && !string.IsNullOrEmpty(this.Page.Request.QueryString["from"])) && ((this.Page.Request.QueryString["from"] == "signBuy") || (this.Page.Request.QueryString["from"] == "groupBuy")))
                {
                    this.productSku = this.Page.Request.QueryString["productSku"];
                    if (this.isbargain)
                    {
                        int bargainDetialId = Globals.RequestQueryNum("bargainDetialId");
                        orderSummitCart = ShoppingCartProcessor.GetListShoppingCart(this.productSku, this.buyAmount, bargainDetialId, 0);
                    }
                    else
                    {
                        int buyAmount = this.buyAmount;
                        int id        = Globals.RequestQueryNum("limitedTimeDiscountId");
                        if (id > 0)
                        {
                            bool flag = true;
                            LimitedTimeDiscountInfo discountInfo = LimitedTimeDiscountHelper.GetDiscountInfo(id);
                            if (discountInfo == null)
                            {
                                flag = false;
                            }
                            if (flag)
                            {
                                if (MemberHelper.CheckCurrentMemberIsInRange(discountInfo.ApplyMembers, discountInfo.DefualtGroup, discountInfo.CustomGroup, base.CurrentMemberInfo.UserId))
                                {
                                    if (discountInfo.LimitNumber != 0)
                                    {
                                        int num4 = ShoppingCartProcessor.GetLimitedTimeDiscountUsedNum(id, this.productSku, 0, base.CurrentMemberInfo.UserId, false);
                                        if (this.buyAmount > (discountInfo.LimitNumber - num4))
                                        {
                                            buyAmount = discountInfo.LimitNumber - num4;
                                        }
                                    }
                                }
                                else
                                {
                                    id = 0;
                                }
                            }
                            else
                            {
                                id = 0;
                            }
                        }
                        if (id > 0)
                        {
                            ShoppingCartProcessor.RemoveLineItem(this.productSku, 0, id);
                        }
                        if ((buyAmount == 0) && (id > 0))
                        {
                            buyAmount = this.buyAmount;
                            id        = 0;
                        }
                        orderSummitCart = ShoppingCartProcessor.GetListShoppingCart(this.productSku, buyAmount, 0, id);
                    }
                }
                else
                {
                    orderSummitCart = ShoppingCartProcessor.GetOrderSummitCart();
                }
                if (orderSummitCart == null)
                {
                    HttpContext.Current.Response.Write("<script>alert('商品已下架或没有需要结算的订单!');location.href='/Vshop/ShoppingCart.aspx'</script>");
                }
                else
                {
                    if (orderSummitCart.Count > 1)
                    {
                        this.litShowMes.Text = "<div style=\"color: #F60; \"><img  src=\"/Utility/pics/u77.png\">您所购买的商品不支持同一个物流规则发货,系统自动拆分成多个子订单处理</div>";
                    }
                    this.rptCartProducts.DataSource = orderSummitCart;
                    this.rptCartProducts.DataBind();
                    decimal num5        = 0M;
                    decimal num6        = 0M;
                    decimal num7        = 0M;
                    int     num8        = 0;
                    int     intOrderNum = 0;
                    foreach (ShoppingCartInfo info3 in orderSummitCart)
                    {
                        num8        += info3.GetPointNumber;
                        num5        += info3.Total;
                        num6        += info3.Exemption;
                        num7        += info3.ShipCost;
                        intOrderNum += info3.GetQuantity();
                    }
                    decimal num9 = num6;
                    decimal d    = num5 - num9;
                    if (d <= 0M)
                    {
                        d = 0M;
                    }
                    d = decimal.Round(d, 2);
                    if (this.objRadio[1].Checked == true)
                    {
                        this.litServiceMoney.Text = (intOrderNum * intPerServiceMoney).ToString("0.00");
                        d += decimal.Round(intOrderNum * intPerServiceMoney, 2);
                    }
                    else
                    {
                        this.litServiceMoney.Text = "0.00";
                    }
                    this.litOrderTotal.Text = d.ToString("F2");
                    if (num8 == 0)
                    {
                        this.litDisplayPointNumber.Text = "style=\"display:none;\"";
                    }
                    this.litPointNumber.Text = num8.ToString();
                    int          num11          = base.CurrentMemberInfo.Points - num8;
                    decimal      num12          = 0M;
                    SiteSettings masterSettings = SettingsManager.GetMasterSettings(false);
                    if ((d * masterSettings.PointToCashRate) > base.CurrentMemberInfo.Points)
                    {
                        if (num11 > (masterSettings.PonitToCash_MaxAmount * masterSettings.PointToCashRate))
                        {
                            num12 = masterSettings.PonitToCash_MaxAmount;
                            num11 = ((int)masterSettings.PonitToCash_MaxAmount) * masterSettings.PointToCashRate;
                        }
                        else
                        {
                            num12 = num11 / masterSettings.PointToCashRate;
                        }
                    }
                    else
                    {
                        num12 = masterSettings.PonitToCash_MaxAmount;
                        if (num12 > d)
                        {
                            num12 = d;
                        }
                        num12 = decimal.Round(num12, 2);
                        num11 = (int)(num12 * masterSettings.PointToCashRate);
                    }
                    if (num11 <= 0)
                    {
                        num11 = 0;
                        num12 = 0M;
                    }
                    this.MembersPointMoney.Value = num12.ToString("F2");
                    if (num11 > 0)
                    {
                        this.litUseMembersPointShow.Text = string.Concat(new object[] { "<input type='hidden' id='hdCanUsePoint' value='", num11, "'/><input type='hidden' id='hdCanUsePointMoney' value='", num12.ToString("F2"), "'/><div class=\"prompt-text pull-left\" id=\"divUseMembersPointShow\">可用<span  id=\"usepointnum\">", num11, "</span>积分抵 <span class=\"colorr\">\x00a5<span  id=\"usepointmoney\">", num12.ToString("F2"), "</span></span>元</div><div class=\"switch pull-right\" id=\"mySwitchUseMembersPoint\"><input  type=\"checkbox\" /></div>" });
                    }
                    else
                    {
                        this.litUseMembersPointShow.Text = "<input type='hidden' id='hdCanUsePoint' value='0'/><input type='hidden' id='hdCanUsePointMoney' value='0'/><div class=\"prompt-text pull-left\" id=\"divUseMembersPointShow\">可用<span  id=\"usepointnum\">0</span>积分 <span  id=\"usepointmoney\" style=\"display:none\">" + num12.ToString("F2") + "</span></div><div class=\"switch pull-right\" id=\"mySwitchUseMembersPoint\" style=\"display:none\"><input type=\"checkbox\" disabled /></div>";
                    }
                    decimal availableAmount = 0M;
                    if (d > base.CurrentMemberInfo.AvailableAmount)
                    {
                        availableAmount = base.CurrentMemberInfo.AvailableAmount;
                        this.BalanceCanPayMoney.Value = base.CurrentMemberInfo.AvailableAmount.ToString("F2");
                    }
                    else
                    {
                        availableAmount = d;
                        this.BalanceCanPayMoney.Value = d.ToString("F2");
                    }
                    if ((base.CurrentMemberInfo.AvailableAmount > 0M) && masterSettings.EnableBalancePayment)
                    {
                        this.litIsUseBalance.Text = "<div class=\"prompt-text pull-left\">余额支付 <span class=\"colorr\">\x00a5<span id=\"spCanpayMoney\">" + availableAmount.ToString("F2") + "</span></span>(可用 \x00a5<span id=\"spAvailableAmount\">" + base.CurrentMemberInfo.AvailableAmount.ToString("F2") + "</span>)</div><div class=\"switch pull-right\" id=\"mySwitchUseBalance\"><input type=\"checkbox\" " + ((availableAmount > 0M) ? "" : " disabled") + " /></div></div>";
                    }
                    else
                    {
                        this.litIsUseBalance.Text = "<div class=\"prompt-text pull-left\"" + (masterSettings.EnableBalancePayment ? "" : " style=\"display:none\"") + ">余额可用 <span class=\"colorr\">\x00a5<span id=\"spCanpayMoney\">0.00</span></span><span id=\"spAvailableAmount\" style=\"display:none\">0.00</span></div><div class=\"switch pull-right\" id=\"mySwitchUseBalance\" style=\"display:none\"><input type=\"checkbox\" disabled /></div></div>";
                    }
                    if (!masterSettings.PonitToCash_Enable)
                    {
                        this.litDisplayPoint.Text = " style=\"display:none;\"";
                    }
                    PageTitle.AddSiteNameTitle("订单确认");
                }
            }
        }
Beispiel #7
0
        private void rptCartProducts_ItemDataBound(object sender, System.Web.UI.WebControls.RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == System.Web.UI.WebControls.ListItemType.Item || e.Item.ItemType == System.Web.UI.WebControls.ListItemType.AlternatingItem)
            {
                System.Collections.Generic.List <ShoppingCartItemInfo> list = (System.Collections.Generic.List <ShoppingCartItemInfo>)System.Web.UI.DataBinder.Eval(e.Item.DataItem, "LineItems");
                System.Web.UI.WebControls.Literal literal  = (System.Web.UI.WebControls.Literal)e.Item.Controls[0].FindControl("LitCoupon");
                System.Web.UI.WebControls.Literal literal2 = (System.Web.UI.WebControls.Literal)e.Item.Controls[0].FindControl("litExemption");
                System.Web.UI.WebControls.Literal literal3 = (System.Web.UI.WebControls.Literal)e.Item.Controls[0].FindControl("litoldExemption");
                System.Web.UI.WebControls.Literal literal4 = (System.Web.UI.WebControls.Literal)e.Item.Controls[0].FindControl("litoldTotal");
                System.Web.UI.WebControls.Literal literal5 = (System.Web.UI.WebControls.Literal)e.Item.Controls[0].FindControl("litTotal");
                System.Web.UI.WebControls.Literal literal6 = (System.Web.UI.WebControls.Literal)e.Item.Controls[0].FindControl("litbFreeShipping");
                string text  = "";
                string text2 = " <div class=\"btn-group coupon\">";
                object obj   = text2;
                text2 = string.Concat(new object[]
                {
                    obj,
                    "<button type=\"button\" class=\"btn btn-default dropdown-toggle coupondropdown\" data-toggle=\"dropdown\"   id='coupondropdown",
                    System.Web.UI.DataBinder.Eval(e.Item.DataItem, "TemplateId"),
                    "'>选择优惠券<span class=\"caret\"></span></button>"
                });
                obj   = text2;
                text2 = string.Concat(new object[]
                {
                    obj,
                    "<ul id=\"coupon",
                    System.Web.UI.DataBinder.Eval(e.Item.DataItem, "TemplateId"),
                    "\" class=\"dropdown-menu\" role=\"menu\">"
                });
                if (this.GetUserCoupons.Rows.Count > 0 && !this.isbargain)
                {
                    obj  = text;
                    text = string.Concat(new object[]
                    {
                        obj,
                        "<li><a onclick=\"Couponasetselect('",
                        System.Web.UI.DataBinder.Eval(e.Item.DataItem, "TemplateId"),
                        "','不使用','0',0,'0')\"   value=\"0\">不使用</a></li>"
                    });
                }
                if (!this.isbargain)
                {
                    for (int i = 0; i < this.GetUserCoupons.Rows.Count; i++)
                    {
                        if (MemberProcessor.CheckCurrentMemberIsInRange(this.GetUserCoupons.Rows[i]["MemberGrades"].ToString(), this.GetUserCoupons.Rows[i]["DefualtGroup"].ToString(), this.GetUserCoupons.Rows[i]["CustomGroup"].ToString()) || this.GetUserCoupons.Rows[i]["MemberGrades"].ToString() == "0" || this.GetUserCoupons.Rows[i]["MemberGrades"].ToString() == this.CurrentMemberInfo.GradeId.ToString())
                        {
                            if (bool.Parse(this.GetUserCoupons.Rows[i]["IsAllProduct"].ToString()))
                            {
                                decimal num = 0m;
                                foreach (ShoppingCartItemInfo current in list)
                                {
                                    if (current.Type == 0)
                                    {
                                        num += current.SubTotal;
                                    }
                                }
                                if (decimal.Parse(this.GetUserCoupons.Rows[i]["ConditionValue"].ToString()) <= num)
                                {
                                    obj  = text;
                                    text = string.Concat(new object[]
                                    {
                                        obj,
                                        "<li><a onclick=\"Couponasetselect('",
                                        System.Web.UI.DataBinder.Eval(e.Item.DataItem, "TemplateId"),
                                        "','",
                                        this.GetUserCoupons.Rows[i]["CouponValue"],
                                        "元现金券','",
                                        this.GetUserCoupons.Rows[i]["CouponValue"],
                                        "',",
                                        this.GetUserCoupons.Rows[i]["Id"],
                                        ",'",
                                        this.GetUserCoupons.Rows[i]["CouponValue"],
                                        "元现金券|",
                                        this.GetUserCoupons.Rows[i]["Id"],
                                        "|",
                                        this.GetUserCoupons.Rows[i]["ConditionValue"],
                                        "|",
                                        this.GetUserCoupons.Rows[i]["CouponValue"],
                                        "')\" id=\"acoupon",
                                        System.Web.UI.DataBinder.Eval(e.Item.DataItem, "TemplateId"),
                                        this.GetUserCoupons.Rows[i]["Id"],
                                        "\" value=\"",
                                        this.GetUserCoupons.Rows[i]["Id"],
                                        "\">",
                                        this.GetUserCoupons.Rows[i]["CouponValue"],
                                        "元现金券</a></li>"
                                    });
                                }
                            }
                            else
                            {
                                decimal num  = 0m;
                                bool    flag = false;
                                foreach (ShoppingCartItemInfo current in list)
                                {
                                    if (current.Type == 0)
                                    {
                                        DataTable dataTable = MemberProcessor.GetCouponByProducts(int.Parse(this.GetUserCoupons.Rows[i]["CouponId"].ToString()), current.ProductId);
                                        if (dataTable.Rows.Count > 0)
                                        {
                                            num += current.SubTotal;
                                            flag = true;
                                        }
                                    }
                                }
                                if (flag && decimal.Parse(this.GetUserCoupons.Rows[i]["ConditionValue"].ToString()) <= num)
                                {
                                    obj  = text;
                                    text = string.Concat(new object[]
                                    {
                                        obj,
                                        "<li><a onclick=\"Couponasetselect('",
                                        System.Web.UI.DataBinder.Eval(e.Item.DataItem, "TemplateId"),
                                        "','",
                                        this.GetUserCoupons.Rows[i]["CouponValue"],
                                        "元现金券','",
                                        this.GetUserCoupons.Rows[i]["CouponValue"],
                                        "',",
                                        this.GetUserCoupons.Rows[i]["Id"],
                                        ",'",
                                        this.GetUserCoupons.Rows[i]["CouponValue"],
                                        "元现金券|",
                                        this.GetUserCoupons.Rows[i]["Id"],
                                        "|",
                                        this.GetUserCoupons.Rows[i]["ConditionValue"],
                                        "|",
                                        this.GetUserCoupons.Rows[i]["CouponValue"],
                                        "')\" id=\"acoupon",
                                        System.Web.UI.DataBinder.Eval(e.Item.DataItem, "TemplateId"),
                                        this.GetUserCoupons.Rows[i]["Id"],
                                        "\" value=\"",
                                        this.GetUserCoupons.Rows[i]["Id"],
                                        "\">",
                                        this.GetUserCoupons.Rows[i]["CouponValue"],
                                        "元现金券</a></li>"
                                    });
                                }
                            }
                        }
                    }
                }
                text2 += text;
                obj    = text2;
                text2  = string.Concat(new object[]
                {
                    obj,
                    "</ul></div><input type=\"hidden\"  class=\"ClassCoupon\"   id=\"selectCoupon",
                    System.Web.UI.DataBinder.Eval(e.Item.DataItem, "TemplateId"),
                    "\"/>  "
                });
                if (!string.IsNullOrEmpty(text))
                {
                    literal.Text = string.Concat(new object[]
                    {
                        text2,
                        "<input type=\"hidden\"   id='selectCouponValue",
                        System.Web.UI.DataBinder.Eval(e.Item.DataItem, "TemplateId"),
                        "' class=\"selectCouponValue\" />"
                    });
                }
                else
                {
                    literal.Text = "<input type=\"hidden\"   id='selectCouponValue" + System.Web.UI.DataBinder.Eval(e.Item.DataItem, "TemplateId") + "' class=\"selectCouponValue\" />";
                }
                decimal d    = 0m;
                decimal num2 = 0m;
                decimal num3 = 0m;
                decimal d2   = 0m;
                decimal num4 = 0m;
                int     num5 = 0;
                foreach (ShoppingCartItemInfo current2 in list)
                {
                    if (current2.Type == 0)
                    {
                        num4 += current2.MilkSubTotal;                         //牛奶配送总价
                        num5 += current2.Quantity;
                    }
                }
                d2 = num4;
                //如果选择了奶卡,并且奶卡属于当前用户,则订单总价为0
                string cardidstr = this.Page.Request.QueryString["cardid"];
                Guid   cardid    = new Guid();
                if (Guid.TryParse(cardidstr, out cardid))
                {
                    MilkCardInfo milkCard = VShopHelper.GetMilkCard(cardid);
                    if (milkCard != null)
                    {
                        d2 = 0m;
                    }
                }

                if (!this.isbargain)
                {
                    for (int j = 0; j < this.dtActivities.Rows.Count; j++)
                    {
                        if (int.Parse(this.dtActivities.Rows[j]["attendTime"].ToString()) == 0 || int.Parse(this.dtActivities.Rows[j]["attendTime"].ToString()) > ActivityHelper.GetActivitiesMember(this.CurrentMemberInfo.UserId, int.Parse(this.dtActivities.Rows[j]["ActivitiesId"].ToString())))
                        {
                            decimal   num  = 0m;
                            int       num6 = 0;
                            DataTable activities_Detail = ActivityHelper.GetActivities_Detail(int.Parse(this.dtActivities.Rows[j]["ActivitiesId"].ToString()));
                            foreach (ShoppingCartItemInfo current2 in list)
                            {
                                if (current2.Type == 0)
                                {
                                    DataTable dataTable = ActivityHelper.GetActivitiesProducts(int.Parse(this.dtActivities.Rows[j]["ActivitiesId"].ToString()), current2.ProductId);
                                    if (dataTable.Rows.Count > 0)
                                    {
                                        num  += current2.SubTotal;
                                        num6 += current2.Quantity;
                                    }
                                }
                            }
                            bool flag2 = false;
                            if (activities_Detail.Rows.Count > 0)
                            {
                                for (int i = 0; i < activities_Detail.Rows.Count; i++)
                                {
                                    if (MemberHelper.CheckCurrentMemberIsInRange(activities_Detail.Rows[i]["MemberGrades"].ToString(), activities_Detail.Rows[i]["DefualtGroup"].ToString(), activities_Detail.Rows[i]["CustomGroup"].ToString(), this.CurrentMemberInfo.UserId))
                                    {
                                        if (bool.Parse(this.dtActivities.Rows[j]["isAllProduct"].ToString()))
                                        {
                                            if (decimal.Parse(activities_Detail.Rows[i]["MeetMoney"].ToString()) > 0m)
                                            {
                                                if (num4 != 0m && num4 >= decimal.Parse(activities_Detail.Rows[activities_Detail.Rows.Count - 1]["MeetMoney"].ToString()))
                                                {
                                                    num2          = decimal.Parse(activities_Detail.Rows[activities_Detail.Rows.Count - 1]["MeetMoney"].ToString());
                                                    d             = decimal.Parse(activities_Detail.Rows[activities_Detail.Rows.Count - 1]["ReductionMoney"].ToString());
                                                    literal6.Text = activities_Detail.Rows[activities_Detail.Rows.Count - 1]["bFreeShipping"].ToString();
                                                    break;
                                                }
                                                if (num4 != 0m && num4 < decimal.Parse(activities_Detail.Rows[0]["MeetMoney"].ToString()))
                                                {
                                                    break;
                                                }
                                                if (num4 != 0m && num4 >= decimal.Parse(activities_Detail.Rows[i]["MeetMoney"].ToString()))
                                                {
                                                    num2          = decimal.Parse(activities_Detail.Rows[i]["MeetMoney"].ToString());
                                                    d             = decimal.Parse(activities_Detail.Rows[i]["ReductionMoney"].ToString());
                                                    literal6.Text = activities_Detail.Rows[i]["bFreeShipping"].ToString();
                                                }
                                            }
                                            else
                                            {
                                                if (num5 != 0 && num5 >= int.Parse(activities_Detail.Rows[activities_Detail.Rows.Count - 1]["MeetNumber"].ToString()))
                                                {
                                                    num2          = decimal.Parse(activities_Detail.Rows[activities_Detail.Rows.Count - 1]["MeetMoney"].ToString());
                                                    num3          = decimal.Parse(activities_Detail.Rows[activities_Detail.Rows.Count - 1]["ReductionMoney"].ToString());
                                                    flag2         = true;
                                                    literal6.Text = activities_Detail.Rows[activities_Detail.Rows.Count - 1]["bFreeShipping"].ToString();
                                                    break;
                                                }
                                                if (num5 != 0 && num5 < int.Parse(activities_Detail.Rows[0]["MeetNumber"].ToString()))
                                                {
                                                    break;
                                                }
                                                if (num5 != 0 && num5 >= int.Parse(activities_Detail.Rows[i]["MeetNumber"].ToString()))
                                                {
                                                    num2          = decimal.Parse(activities_Detail.Rows[i]["MeetMoney"].ToString());
                                                    num3          = decimal.Parse(activities_Detail.Rows[i]["ReductionMoney"].ToString());
                                                    flag2         = true;
                                                    literal6.Text = activities_Detail.Rows[i]["bFreeShipping"].ToString();
                                                }
                                            }
                                        }
                                        else
                                        {
                                            num4 = num;
                                            num5 = num6;
                                            if (decimal.Parse(activities_Detail.Rows[i]["MeetMoney"].ToString()) > 0m)
                                            {
                                                if (num4 != 0m && num4 >= decimal.Parse(activities_Detail.Rows[activities_Detail.Rows.Count - 1]["MeetMoney"].ToString()))
                                                {
                                                    num2          = decimal.Parse(activities_Detail.Rows[activities_Detail.Rows.Count - 1]["MeetMoney"].ToString());
                                                    d             = decimal.Parse(activities_Detail.Rows[activities_Detail.Rows.Count - 1]["ReductionMoney"].ToString());
                                                    literal6.Text = activities_Detail.Rows[activities_Detail.Rows.Count - 1]["bFreeShipping"].ToString();
                                                    break;
                                                }
                                                if (num4 != 0m && num4 < decimal.Parse(activities_Detail.Rows[0]["MeetMoney"].ToString()))
                                                {
                                                    break;
                                                }
                                                if (num4 != 0m && num4 >= decimal.Parse(activities_Detail.Rows[i]["MeetMoney"].ToString()))
                                                {
                                                    num2          = decimal.Parse(activities_Detail.Rows[i]["MeetMoney"].ToString());
                                                    d             = decimal.Parse(activities_Detail.Rows[i]["ReductionMoney"].ToString());
                                                    literal6.Text = activities_Detail.Rows[i]["bFreeShipping"].ToString();
                                                }
                                            }
                                            else
                                            {
                                                if (num5 != 0 && num5 >= int.Parse(activities_Detail.Rows[activities_Detail.Rows.Count - 1]["MeetNumber"].ToString()))
                                                {
                                                    num2          = decimal.Parse(activities_Detail.Rows[activities_Detail.Rows.Count - 1]["MeetMoney"].ToString());
                                                    d             = decimal.Parse(activities_Detail.Rows[activities_Detail.Rows.Count - 1]["ReductionMoney"].ToString());
                                                    flag2         = true;
                                                    literal6.Text = activities_Detail.Rows[activities_Detail.Rows.Count - 1]["bFreeShipping"].ToString();
                                                    break;
                                                }
                                                if (num5 != 0 && num5 < int.Parse(activities_Detail.Rows[0]["MeetNumber"].ToString()))
                                                {
                                                    break;
                                                }
                                                if (num5 != 0 && num5 >= int.Parse(activities_Detail.Rows[i]["MeetNumber"].ToString()))
                                                {
                                                    num2          = decimal.Parse(activities_Detail.Rows[i]["MeetMoney"].ToString());
                                                    d             = decimal.Parse(activities_Detail.Rows[i]["ReductionMoney"].ToString());
                                                    flag2         = true;
                                                    literal6.Text = activities_Detail.Rows[i]["bFreeShipping"].ToString();
                                                }
                                            }
                                        }
                                    }
                                }
                                if (flag2)
                                {
                                    if (num5 > 0)
                                    {
                                        num3 += d;
                                    }
                                }
                                else if (num4 != 0m && num2 != 0m && num4 >= num2)
                                {
                                    num3 += d;
                                }
                            }
                        }
                    }
                }
                literal2.Text = num3.ToString("F2");
                literal3.Text = num3.ToString("F2");
                literal5.Text = (d2 - num3).ToString("F2");
                literal4.Text = (d2 - num3).ToString("F2");
            }
        }
Beispiel #8
0
        protected override void AttachChildControls()
        {
            this.litShipTo       = (System.Web.UI.WebControls.Literal) this.FindControl("litShipTo");
            this.litIsUseBalance = (System.Web.UI.WebControls.Literal) this.FindControl("litIsUseBalance");
            this.litCellPhone    = (System.Web.UI.WebControls.Literal) this.FindControl("litCellPhone");
            this.litAddress      = (System.Web.UI.WebControls.Literal) this.FindControl("litAddress");
            this.litShowMes      = (System.Web.UI.WebControls.Literal) this.FindControl("litShowMes");
            this.GetUserCoupons  = MemberProcessor.GetUserCoupons();
            this.rptCartProducts = (VshopTemplatedRepeater)this.FindControl("rptCartProducts");
            this.rptCartProducts.ItemDataBound += new System.Web.UI.WebControls.RepeaterItemEventHandler(this.rptCartProducts_ItemDataBound);
            this.litOrderTotal          = (System.Web.UI.WebControls.Literal) this.FindControl("litOrderTotal");
            this.litPointNumber         = (System.Web.UI.WebControls.Literal) this.FindControl("litPointNumber");
            this.litUseMembersPointShow = (System.Web.UI.WebControls.Literal) this.FindControl("litUseMembersPointShow");
            this.litDisplayPointNumber  = (System.Web.UI.WebControls.Literal) this.FindControl("litDisplayPointNumber");
            this.litDisplayPoint        = (System.Web.UI.WebControls.Literal) this.FindControl("litDisplayPoint");
            this.BalanceCanPayMoney     = (System.Web.UI.HtmlControls.HtmlInputHidden) this.FindControl("BalanceCanPayMoney");
            this.groupbuyHiddenBox      = (System.Web.UI.HtmlControls.HtmlInputControl) this.FindControl("groupbuyHiddenBox");
            this.rptAddress             = (VshopTemplatedRepeater)this.FindControl("rptAddress");
            this.selectShipTo           = (System.Web.UI.HtmlControls.HtmlInputHidden) this.FindControl("selectShipTo");
            this.MembersPointMoney      = (System.Web.UI.HtmlControls.HtmlInputHidden) this.FindControl("MembersPointMoney");
            this.regionId      = (System.Web.UI.HtmlControls.HtmlInputHidden) this.FindControl("regionId");
            this.litAddAddress = (System.Web.UI.WebControls.Literal) this.FindControl("litAddAddress");

            if (Globals.GetCurrentDistributorId() == CurrentMemberInfo.UserId)
            {
                base.GotoResourceNotFound("站点管理员无法在自己店内购买!");
                return;
            }
            if (Globals.GetCurrentDistributorId() == 0)//CurrentMemberInfo.ReferralUserId ==0  &&
            {
                base.GotoResourceNotFound("请先扫码关注站点后再下单!");
                return;
            }


            System.Collections.Generic.IList <ShippingAddressInfo> shippingAddresses = MemberProcessor.GetShippingAddresses();
            this.rptAddress.DataSource = from item in shippingAddresses
                                         orderby item.IsDefault
                                         select item;

            this.rptAddress.DataBind();
            ShippingAddressInfo shippingAddressInfo = shippingAddresses.FirstOrDefault((ShippingAddressInfo item) => item.IsDefault);

            if (!string.IsNullOrEmpty(this.Page.Request.QueryString["startDate"]))
            {
                this.SendStartDate = DateTime.Parse(this.Page.Request.QueryString["startDate"]);
            }
            if (!string.IsNullOrEmpty(this.Page.Request.QueryString["quantityPerDay"]))
            {
                this.QuantityPerDay = Convert.ToInt32(this.Page.Request.QueryString["quantityPerDay"]);
            }
            if (!string.IsNullOrEmpty(this.Page.Request.QueryString["sendDays"]))
            {
                this.SendDays = Convert.ToInt32(this.Page.Request.QueryString["sendDays"]);
            }


            if (shippingAddressInfo == null)
            {
                shippingAddressInfo = ((shippingAddresses.Count > 0) ? shippingAddresses[0] : null);
            }
            if (shippingAddressInfo != null)
            {
                this.litShipTo.Text    = shippingAddressInfo.ShipTo;
                this.litCellPhone.Text = shippingAddressInfo.CellPhone;
                this.litAddress.Text   = shippingAddressInfo.Address;
                this.selectShipTo.SetWhenIsNotNull(shippingAddressInfo.ShippingId.ToString());
                this.regionId.SetWhenIsNotNull(shippingAddressInfo.RegionId.ToString());
            }
            this.litAddAddress.Text = "<li><a href='/Vshop/AddShippingAddress.aspx?returnUrl=" + Globals.UrlEncode(System.Web.HttpContext.Current.Request.Url.ToString()) + "'>新增收货地址</a></li>";
            if (shippingAddresses == null || shippingAddresses.Count == 0)
            {
                this.Page.Response.Redirect(Globals.ApplicationPath + "/Vshop/AddShippingAddress.aspx?returnUrl=" + Globals.UrlEncode(System.Web.HttpContext.Current.Request.Url.ToString()));
            }
            else
            {
                System.Collections.Generic.List <ShoppingCartInfo> list = new System.Collections.Generic.List <ShoppingCartInfo>();
                if (int.TryParse(this.Page.Request.QueryString["buyAmount"], out this.buyAmount) && !string.IsNullOrEmpty(this.Page.Request.QueryString["productSku"]) && !string.IsNullOrEmpty(this.Page.Request.QueryString["from"]) && (this.Page.Request.QueryString["from"] == "signBuy" || this.Page.Request.QueryString["from"] == "groupBuy"))
                {
                    this.productSku = this.Page.Request.QueryString["productSku"];
                    if (this.isbargain)
                    {
                        int bargainDetialId = Globals.RequestQueryNum("bargainDetialId");
                        list = ShoppingCartProcessor.GetListShoppingCart(this.productSku, this.buyAmount, bargainDetialId, 0);
                    }
                    else
                    {
                        int num  = this.buyAmount;
                        int num2 = Globals.RequestQueryNum("limitedTimeDiscountId");
                        if (num2 > 0)
                        {
                            bool flag = true;
                            LimitedTimeDiscountInfo discountInfo = LimitedTimeDiscountHelper.GetDiscountInfo(num2);
                            if (discountInfo == null)
                            {
                                flag = false;
                            }
                            if (flag)
                            {
                                if (MemberHelper.CheckCurrentMemberIsInRange(discountInfo.ApplyMembers, discountInfo.DefualtGroup, discountInfo.CustomGroup, this.CurrentMemberInfo.UserId))
                                {
                                    if (discountInfo.LimitNumber != 0)
                                    {
                                        int limitedTimeDiscountUsedNum = ShoppingCartProcessor.GetLimitedTimeDiscountUsedNum(num2, this.productSku, 0, this.CurrentMemberInfo.UserId, false);
                                        if (this.buyAmount > discountInfo.LimitNumber - limitedTimeDiscountUsedNum)
                                        {
                                            num = discountInfo.LimitNumber - limitedTimeDiscountUsedNum;
                                        }
                                    }
                                }
                                else
                                {
                                    num2 = 0;
                                }
                            }
                            else
                            {
                                num2 = 0;
                            }
                        }
                        if (num2 > 0)
                        {
                            ShoppingCartProcessor.RemoveLineItem(this.productSku, 0, num2);
                        }
                        if (num == 0 && num2 > 0)
                        {
                            num  = this.buyAmount;
                            num2 = 0;
                        }
                        list = ShoppingCartProcessor.GetListShoppingCart(SendStartDate, QuantityPerDay, SendDays, this.productSku, num, 0, num2);
                    }
                }
                else
                {
                    list = ShoppingCartProcessor.GetOrderSummitCart();
                }
                if (list == null)
                {
                    System.Web.HttpContext.Current.Response.Write("<script>alert('商品已下架或没有需要结算的订单!');location.href='/Vshop/ShoppingCart.aspx'</script>");
                }
                else
                {
                    if (list.Count > 1)
                    {
                        this.litShowMes.Text = "<div style=\"color: #F60; \"><img  src=\"/Utility/pics/u77.png\">您所购买的商品不支持同一个物流规则发货,系统自动拆分成多个子订单处理</div>";
                    }
                    this.rptCartProducts.DataSource = list;
                    this.rptCartProducts.DataBind();
                    decimal d    = 0m;
                    decimal num3 = 0m;
                    decimal d2   = 0m;
                    int     num4 = 0;
                    foreach (ShoppingCartInfo current in list)
                    {
                        num4 += current.GetPointNumber;
                        d    += current.Total;
                        num3 += current.Exemption;
                        d2   += current.ShipCost;
                    }
                    decimal d3   = num3;
                    decimal num5 = d - d3;
                    if (num5 <= 0m)
                    {
                        num5 = 0m;
                    }
                    num5 = decimal.Round(num5, 2);
                    this.litOrderTotal.Text = num5.ToString("F2");
                    if (num4 == 0)
                    {
                        this.litDisplayPointNumber.Text = "style=\"display:none;\"";
                    }
                    this.litPointNumber.Text = num4.ToString();
                    int          num6           = this.CurrentMemberInfo.Points - num4;
                    SiteSettings masterSettings = SettingsManager.GetMasterSettings(false);
                    decimal      num7;
                    if (num5 * masterSettings.PointToCashRate > this.CurrentMemberInfo.Points)
                    {
                        if (num6 > masterSettings.PonitToCash_MaxAmount * masterSettings.PointToCashRate)
                        {
                            num7 = masterSettings.PonitToCash_MaxAmount;
                            num6 = (int)masterSettings.PonitToCash_MaxAmount * masterSettings.PointToCashRate;
                        }
                        else
                        {
                            num7 = num6 / masterSettings.PointToCashRate;
                        }
                    }
                    else
                    {
                        num7 = masterSettings.PonitToCash_MaxAmount;
                        if (num7 > num5)
                        {
                            num7 = num5;
                        }
                        num7 = decimal.Round(num7, 2);
                        num6 = (int)(num7 * masterSettings.PointToCashRate);
                    }
                    if (num6 <= 0)
                    {
                        num6 = 0;
                        num7 = 0m;
                    }
                    this.MembersPointMoney.Value = num7.ToString("F2");
                    if (num6 > 0)
                    {
                        this.litUseMembersPointShow.Text = string.Concat(new object[]
                        {
                            "<input type='hidden' id='hdCanUsePoint' value='",
                            num6,
                            "'/><input type='hidden' id='hdCanUsePointMoney' value='",
                            num7.ToString("F2"),
                            "'/><div class=\"prompt-text pull-left\" id=\"divUseMembersPointShow\">可用<span  id=\"usepointnum\">",
                            num6,
                            "</span>积分抵 <span class=\"colorr\">¥<span  id=\"usepointmoney\">",
                            num7.ToString("F2"),
                            "</span></span>元</div><div class=\"switch pull-right\" id=\"mySwitchUseMembersPoint\"><input  type=\"checkbox\" /></div>"
                        });
                    }
                    else
                    {
                        this.litUseMembersPointShow.Text = "<input type='hidden' id='hdCanUsePoint' value='0'/><input type='hidden' id='hdCanUsePointMoney' value='0'/><div class=\"prompt-text pull-left\" id=\"divUseMembersPointShow\">可用<span  id=\"usepointnum\">0</span>积分 <span  id=\"usepointmoney\" style=\"display:none\">" + num7.ToString("F2") + "</span></div><div class=\"switch pull-right\" id=\"mySwitchUseMembersPoint\" style=\"display:none\"><input type=\"checkbox\" disabled /></div>";
                    }
                    decimal d4;
                    if (num5 > this.CurrentMemberInfo.AvailableAmount)
                    {
                        d4 = this.CurrentMemberInfo.AvailableAmount;
                        this.BalanceCanPayMoney.Value = this.CurrentMemberInfo.AvailableAmount.ToString("F2");
                    }
                    else
                    {
                        d4 = num5;
                        this.BalanceCanPayMoney.Value = num5.ToString("F2");
                    }
                    if (this.CurrentMemberInfo.AvailableAmount > 0m && masterSettings.EnableBalancePayment)
                    {
                        this.litIsUseBalance.Text = string.Concat(new string[]
                        {
                            "<div class=\"prompt-text pull-left\">余额支付 <span class=\"colorr\">¥<span id=\"spCanpayMoney\">",
                            d4.ToString("F2"),
                            "</span></span>(可用 ¥<span id=\"spAvailableAmount\">",
                            this.CurrentMemberInfo.AvailableAmount.ToString("F2"),
                            "</span>)</div><div class=\"switch pull-right\" id=\"mySwitchUseBalance\"><input type=\"checkbox\" ",
                            (d4 > 0m) ? "" : " disabled",
                            " /></div></div>"
                        });
                    }
                    else
                    {
                        this.litIsUseBalance.Text = "<div class=\"prompt-text pull-left\"" + (masterSettings.EnableBalancePayment ? "" : " style=\"display:none\"") + ">余额可用 <span class=\"colorr\">¥<span id=\"spCanpayMoney\">0.00</span></span><span id=\"spAvailableAmount\" style=\"display:none\">0.00</span></div><div class=\"switch pull-right\" id=\"mySwitchUseBalance\" style=\"display:none\"><input type=\"checkbox\" disabled /></div></div>";
                    }
                    if (!masterSettings.PonitToCash_Enable)
                    {
                        this.litDisplayPoint.Text = " style=\"display:none;\"";
                    }
                    PageTitle.AddSiteNameTitle("订单确认");
                }
            }
        }
Beispiel #9
0
        protected override void AttachChildControls()
        {
            this.litShipTo       = (System.Web.UI.WebControls.Literal) this.FindControl("litShipTo");
            this.litCellPhone    = (System.Web.UI.WebControls.Literal) this.FindControl("litCellPhone");
            this.litAddress      = (System.Web.UI.WebControls.Literal) this.FindControl("litAddress");
            this.litShowMes      = (System.Web.UI.WebControls.Literal) this.FindControl("litShowMes");
            this.GetUserCoupons  = MemberProcessor.GetUserCoupons();
            this.rptCartProducts = (VshopTemplatedRepeater)this.FindControl("rptCartProducts");
            this.rptCartProducts.ItemDataBound += new System.Web.UI.WebControls.RepeaterItemEventHandler(this.rptCartProducts_ItemDataBound);
            this.litOrderTotal         = (System.Web.UI.WebControls.Literal) this.FindControl("litOrderTotal");
            this.litPointNumber        = (System.Web.UI.WebControls.Literal) this.FindControl("litPointNumber");
            this.litDisplayPointNumber = (System.Web.UI.WebControls.Literal) this.FindControl("litDisplayPointNumber");
            this.aLinkToShipping       = (System.Web.UI.HtmlControls.HtmlAnchor) this.FindControl("aLinkToShipping");
            this.groupbuyHiddenBox     = (System.Web.UI.HtmlControls.HtmlInputControl) this.FindControl("groupbuyHiddenBox");
            this.rptAddress            = (VshopTemplatedRepeater)this.FindControl("rptAddress");
            this.selectShipTo          = (System.Web.UI.HtmlControls.HtmlInputHidden) this.FindControl("selectShipTo");
            this.regionId      = (System.Web.UI.HtmlControls.HtmlInputHidden) this.FindControl("regionId");
            this.litAddAddress = (System.Web.UI.WebControls.Literal) this.FindControl("litAddAddress");
            System.Collections.Generic.IList <ShippingAddressInfo> shippingAddresses = MemberProcessor.GetShippingAddresses();
            this.rptAddress.DataSource = from item in shippingAddresses
                                         orderby item.IsDefault
                                         select item;

            this.rptAddress.DataBind();
            ShippingAddressInfo shippingAddressInfo = shippingAddresses.FirstOrDefault((ShippingAddressInfo item) => item.IsDefault);

            if (shippingAddressInfo == null)
            {
                shippingAddressInfo = ((shippingAddresses.Count > 0) ? shippingAddresses[0] : null);
            }
            if (shippingAddressInfo != null)
            {
                this.litShipTo.Text    = shippingAddressInfo.ShipTo;
                this.litCellPhone.Text = shippingAddressInfo.CellPhone;
                this.litAddress.Text   = shippingAddressInfo.Address;
                this.selectShipTo.SetWhenIsNotNull(shippingAddressInfo.ShippingId.ToString());
                this.regionId.SetWhenIsNotNull(shippingAddressInfo.RegionId.ToString());
            }
            this.litAddAddress.Text = " href='/Vshop/AddShippingAddress.aspx?returnUrl=" + Globals.UrlEncode(System.Web.HttpContext.Current.Request.Url.ToString()) + "'";
            if (shippingAddresses == null || shippingAddresses.Count == 0)
            {
                this.Page.Response.Redirect(Globals.ApplicationPath + "/Vshop/AddShippingAddress.aspx?returnUrl=" + Globals.UrlEncode(System.Web.HttpContext.Current.Request.Url.ToString()));
            }
            else
            {
                this.aLinkToShipping.HRef = Globals.ApplicationPath + "/Vshop/ShippingAddresses.aspx?returnUrl=" + Globals.UrlEncode(System.Web.HttpContext.Current.Request.Url.ToString());
                System.Collections.Generic.List <ShoppingCartInfo> list = new System.Collections.Generic.List <ShoppingCartInfo>();
                if (int.TryParse(this.Page.Request.QueryString["buyAmount"], out this.buyAmount) && !string.IsNullOrEmpty(this.Page.Request.QueryString["productSku"]) && !string.IsNullOrEmpty(this.Page.Request.QueryString["from"]) && (this.Page.Request.QueryString["from"] == "signBuy" || this.Page.Request.QueryString["from"] == "groupBuy"))
                {
                    this.productSku = this.Page.Request.QueryString["productSku"];
                    if (this.isbargain)
                    {
                        int bargainDetialId = Globals.RequestQueryNum("bargainDetialId");
                        list = ShoppingCartProcessor.GetListShoppingCart(this.productSku, this.buyAmount, bargainDetialId, 0);
                    }
                    else
                    {
                        int num  = this.buyAmount;
                        int num2 = Globals.RequestQueryNum("limitedTimeDiscountId");
                        if (num2 > 0)
                        {
                            bool flag = true;
                            LimitedTimeDiscountInfo discountInfo = LimitedTimeDiscountHelper.GetDiscountInfo(num2);
                            if (discountInfo == null)
                            {
                                flag = false;
                            }
                            if (flag)
                            {
                                if (MemberHelper.CheckCurrentMemberIsInRange(discountInfo.ApplyMembers, discountInfo.DefualtGroup, discountInfo.CustomGroup, this.CurrentMemberInfo.UserId))
                                {
                                    if (discountInfo.LimitNumber != 0)
                                    {
                                        int limitedTimeDiscountUsedNum = ShoppingCartProcessor.GetLimitedTimeDiscountUsedNum(num2, this.productSku, 0, this.CurrentMemberInfo.UserId, false);
                                        if (this.buyAmount > discountInfo.LimitNumber - limitedTimeDiscountUsedNum)
                                        {
                                            num = discountInfo.LimitNumber - limitedTimeDiscountUsedNum;
                                        }
                                    }
                                }
                                else
                                {
                                    num2 = 0;
                                }
                            }
                            else
                            {
                                num2 = 0;
                            }
                        }
                        if (num2 > 0)
                        {
                            ShoppingCartProcessor.RemoveLineItem(this.productSku, 0, num2);
                        }
                        if (num == 0 && num2 > 0)
                        {
                            num  = this.buyAmount;
                            num2 = 0;
                        }
                        list = ShoppingCartProcessor.GetListShoppingCart(this.productSku, num, 0, num2);
                    }
                }
                else
                {
                    list = ShoppingCartProcessor.GetOrderSummitCart();
                }
                if (list == null)
                {
                    System.Web.HttpContext.Current.Response.Write("<script>alert('商品已下架或没有需要结算的订单!');location.href='/Vshop/ShoppingCart.aspx'</script>");
                }
                else
                {
                    if (list.Count > 1)
                    {
                        this.litShowMes.Text = "<div style=\"color: #F60; \"><img  src=\"/Utility/pics/u77.png\">您所购买的商品不支持同一个物流规则发货,系统自动拆分成多个子订单处理</div>";
                    }
                    this.rptCartProducts.DataSource = list;
                    this.rptCartProducts.DataBind();
                    decimal d    = 0m;
                    decimal num3 = 0m;
                    decimal d2   = 0m;
                    int     num4 = 0;
                    foreach (ShoppingCartInfo current in list)
                    {
                        num4 += current.GetPointNumber;
                        d    += current.Total;
                        num3 += current.Exemption;
                        d2   += current.ShipCost;
                    }
                    decimal d3 = num3;
                    this.litOrderTotal.Text = (d - d3).ToString("F2");
                    if (num4 == 0)
                    {
                        this.litDisplayPointNumber.Text = "style=\"display:none;\"";
                    }
                    this.litPointNumber.Text = num4.ToString();
                    PageTitle.AddSiteNameTitle("订单确认");
                }
            }
        }