Example #1
0
        /// <summary>
        /// 确认订单信息
        /// </summary>
        /// <param name="id"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        public GiftOrderConfirmPageModel ConfirmOrder(GiftConfirmOrder value)
        {
            if (value.Count < 1)
            {
                value.Count = 1;
            }
            var id       = value.ID;
            var regionId = value.RegionId;
            var count    = value.Count;
            //Checkout
            GiftOrderConfirmPageModel    data         = new GiftOrderConfirmPageModel();
            List <GiftOrderItemDtoModel> gorditemlist = new List <GiftOrderItemDtoModel>();
            GiftOrderItemDtoModel        gorditem; //订单项

            #region 礼品信息判断
            //礼品信息
            GiftInfo giftdata = _iGiftService.GetById(id);
            if (giftdata == null)
            {
                throw new Exception("错误的礼品编号!");
            }
            #endregion

            gorditem              = new GiftOrderItemDtoModel(); //补充订单项
            gorditem.GiftId       = giftdata.Id;
            gorditem.GiftName     = giftdata.GiftName;
            gorditem.GiftValue    = giftdata.GiftValue;
            gorditem.ImagePath    = giftdata.ImagePath;
            gorditem.OrderId      = 0;
            gorditem.Quantity     = count;
            gorditem.SaleIntegral = giftdata.NeedIntegral;
            if (!string.IsNullOrWhiteSpace(gorditem.ImagePath))
            {
                gorditem.DefaultImage = HimallIO.GetRomoteProductSizeImage(gorditem.ImagePath, 1, ImageSize.Size_100.GetHashCode());
            }
            gorditemlist.Add(gorditem);

            data.GiftList = gorditemlist;

            data.GiftValueTotal = (decimal)data.GiftList.Sum(d => d.Quantity * d.GiftValue);
            data.TotalAmount    = (int)data.GiftList.Sum(d => d.SaleIntegral * d.Quantity);

            //用户地址
            Entities.ShippingAddressInfo shipdata = GetShippingAddress(regionId);
            if (shipdata != null)
            {
                Mapper.CreateMap <Entities.ShippingAddressInfo, ShippingAddressDtoModel>();
                ShippingAddressDtoModel shipobj = Mapper.Map <ShippingAddressDtoModel>(shipdata);
                shipobj.Address  = shipobj.Address + " " + shipdata.AddressDetail;
                data.ShipAddress = shipobj;
            }
            data.success = true;
            return(data);
        }
Example #2
0
        public ActionResult SubmitOrder(long id, long?regionId, int count = 1)
        {
            GiftOrderConfirmPageModel giftOrderConfirmPageModel = new GiftOrderConfirmPageModel();
            List <GiftOrderItemInfo>  giftOrderItemInfos        = new List <GiftOrderItemInfo>();
            GiftInfo byId = giftser.GetById(id);

            if (byId == null)
            {
                throw new HimallException("错误的礼品编号!");
            }
            GiftOrderItemInfo giftOrderItemInfo = new GiftOrderItemInfo()
            {
                GiftId       = byId.Id,
                GiftName     = byId.GiftName,
                GiftValue    = byId.GiftValue,
                ImagePath    = byId.ImagePath,
                OrderId      = new long?(0),
                Quantity     = count,
                SaleIntegral = new int?(byId.NeedIntegral)
            };

            giftOrderItemInfos.Add(giftOrderItemInfo);
            giftOrderConfirmPageModel.GiftList = giftOrderItemInfos;
            GiftOrderConfirmPageModel value = giftOrderConfirmPageModel;
            decimal?nullable = giftOrderConfirmPageModel.GiftList.Sum <GiftOrderItemInfo>((GiftOrderItemInfo d) => {
                decimal quantity  = d.Quantity;
                decimal?giftValue = d.GiftValue;
                if (!giftValue.HasValue)
                {
                    return(null);
                }
                return(new decimal?(quantity * giftValue.GetValueOrDefault()));
            });

            value.GiftValueTotal = nullable.Value;
            GiftOrderConfirmPageModel value1 = giftOrderConfirmPageModel;
            int?nullable1 = giftOrderConfirmPageModel.GiftList.Sum <GiftOrderItemInfo>((GiftOrderItemInfo d) => {
                int?saleIntegral = d.SaleIntegral;
                int quantity     = d.Quantity;
                if (!saleIntegral.HasValue)
                {
                    return(null);
                }
                return(new int?(saleIntegral.GetValueOrDefault() * quantity));
            });

            value1.TotalAmount = nullable1.Value;
            giftOrderConfirmPageModel.ShipAddress = GetShippingAddress(regionId);
            ViewBag.Logo = ServiceHelper.Create <ISiteSettingService>().GetSiteSettings().Logo;
            ViewBag.Step = 2;
            return(View(giftOrderConfirmPageModel));
        }
Example #3
0
        /// <summary>
        /// 确认订单信息并提交
        /// </summary>
        /// <param name="id"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        public ActionResult SubmitOrder(long id, long?regionId, int count = 1)
        {
            #region 礼品信息判断
            //礼品信息
            var giftdata = GiftApplication.GetGift(id);
            if (giftdata == null)
            {
                throw new HimallException("错误的礼品编号!");
            }
            #endregion
            var data         = new GiftOrderConfirmPageModel();
            var gorditemlist = new List <GiftOrderItemInfo>();
            var gorditem     = new GiftOrderItemInfo(); //补充订单项
            gorditem.GiftId       = giftdata.Id;
            gorditem.GiftName     = giftdata.GiftName;
            gorditem.GiftValue    = giftdata.GiftValue;
            gorditem.ImagePath    = giftdata.ImagePath;
            gorditem.OrderId      = 0;
            gorditem.Quantity     = count;
            gorditem.SaleIntegral = giftdata.NeedIntegral;
            gorditemlist.Add(gorditem);

            data.GiftList = gorditemlist;

            data.GiftValueTotal = (decimal)data.GiftList.Sum(d => d.Quantity * d.GiftValue);
            data.TotalAmount    = (int)data.GiftList.Sum(d => d.SaleIntegral * d.Quantity);

            //用户地址
            data.ShipAddress = GetShippingAddress(regionId);

            //顶部信息 Logo
            ViewBag.Logo = SiteSettingApplication.SiteSettings.Logo;//获取Logo
            ViewBag.Step = 2;

            ViewBag.Keyword = SiteSettings.Keyword;
            return(View(data));
        }