Ejemplo n.º 1
0
        /// <summary>
        /// 立即购买使用
        /// </summary>
        /// <param name="sku"></param>
        /// <returns></returns>
        public CartViewModel GetBuyVirtualCart(ProductSkuEntity entity, int ping, int proid, decimal?exchangeRate = null)
        {
            IList <PromotionEntity> promotions = null;

            if (entity != null)
            {
                if (ping == 1)
                {
                    promotions = itemBll.GetPromotionEntitiesTeam(proid);
                }
                else
                {
                    promotions = itemBll.GetPromotionEntities(new[] { entity.Sku });
                }
            }

            var item = entity.AsProdcutItem(promotions, base.ExchangeRate);

            CartViewModel model = new CartViewModel(base.ExchangeRate)
            {
                Items = new ProductItem[] { item }
            };

            return(model);
        }
Ejemplo n.º 2
0
        public static ProductItem AsProdcutItem(this ProductSkuEntity entity, IList <PromotionEntity> promotions, decimal exchangeRate)
        {
            var rtnList = new List <ProductItem>();

            if (entity != null)
            {
                return(new ProductItem(exchangeRate)
                {
                    ProductId = entity.Id,

                    ForOrderQty = entity.Qty,

                    IsDutyOnSeller = entity.IsDutyOnSeller,
                    MainDicValue = entity.MainDicValue,
                    MainValue = entity.MainValue,
                    SubDicValue = entity.SubDicValue,
                    SubValue = entity.SubValue,
                    Sku = entity.Sku,
                    Spu = entity.Spu,
                    SupplierId = entity.SupplierId,
                    Price = entity.Price,                         //原价
                    PriceExchanged = entity.Price * exchangeRate, //Math.Round(, 2),//汇后原价
                    Name = entity.Name,
                    IsOnSaled = entity.Status == 3 && (entity.MinForOrder - entity.AlarmStockQty) >= 0,
                    TaxRate = entity.TaxRate,
                    Promotion = GetPromotionItem(promotions.FirstOrDefault(m => m.Sku == entity.Sku), exchangeRate),
                    CreateTime = entity.CreateTime,
                });
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 编辑产品SKU
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public int EditSku(ProductSkuEntity entity)
        {
            entity.Include(b => new { b.Size, b.Color, b.NetWeight, b.GrossWeight, b.InPrice, b.AvgPrice, b.OutPrice });
            entity.Where(b => b.SnNum == entity.SnNum).And(b => b.CompanyID == this.CompanyID);
            int line = this.ProductSku.Update(entity);

            return(line);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 根据产品的唯一编号查询SKU
        /// </summary>
        /// <param name="ProductNum"></param>
        /// <returns></returns>
        public List <ProductSkuEntity> GetSkuList(string ProductNum)
        {
            ProductSkuEntity skuEntity = new ProductSkuEntity();

            skuEntity.IncludeAll();
            skuEntity.Where(item => item.ProductNum == ProductNum)
            .And(item => item.CompanyID == this.CompanyID)
            ;
            List <ProductSkuEntity> listResult = this.ProductSku.GetList(skuEntity);

            return(listResult);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 根据产品的唯一编号查询SKU
        /// </summary>
        /// <param name="SnNum"></param>
        /// <returns></returns>
        public ProductSkuEntity GetSku(string SnNum)
        {
            ProductSkuEntity skuEntity = new ProductSkuEntity();

            skuEntity.IncludeAll();
            skuEntity.Where(item => item.SnNum == SnNum)
            .And(item => item.CompanyID == this.CompanyID)
            ;
            skuEntity = this.ProductSku.GetSingle(skuEntity);

            return(skuEntity);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 根据SKU唯一编号删除SKU
        /// </summary>
        /// <param name="SnNum"></param>
        /// <returns></returns>
        public int DeleteSku(string SnNum)
        {
            ProductSkuEntity skuEntity = new ProductSkuEntity();

            skuEntity.IsDelete = (int)EIsDelete.Deleted;
            skuEntity.IncludeIsDelete(true);
            skuEntity.Where(item => item.SnNum == SnNum)
            .And(item => item.CompanyID == this.CompanyID)
            ;
            int line = this.ProductSku.Update(skuEntity);

            return(line);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 立即购买时检查商品
        /// </summary>
        /// <param name="sku"></param>
        /// <param name="qty"></param>
        /// <returns></returns>
        public JsonResult CheckSku(string sku, int qty)
        {
            ProductSkuEntity entity = new ProductSkuEntity();

            ViewBag.BuyQty = qty;
            if (string.IsNullOrWhiteSpace(sku))
            {
                return(Json(new { Type = 0, Content = "参数错误:缺少商品号。" }, JsonRequestBehavior.AllowGet));
            }
            if (qty < 1)
            {
                return(Json(new { Type = 0, Content = "最少购买一件选定的商品。" }, JsonRequestBehavior.AllowGet));
            }
            try
            {
                entity = productBll.GetProductBySku(sku, language);
                if (entity == null)
                {
                    return(Json(new { Type = 0, Content = "该商品不存在或已下架。" }, JsonRequestBehavior.AllowGet));
                }
                if (entity.Qty < qty)
                {
                    return(Json(new { Type = 0, Content = "您要订购的商品库存量不足。" }, JsonRequestBehavior.AllowGet));
                }
                if (entity.SalesTerritory != base.DeliveryRegion && entity.SalesTerritory != 3)
                {
                    return(Json(new { Type = 0, Content = "您要订购的商品无法在当前区域配送。" }, JsonRequestBehavior.AllowGet));
                }
                var promotionsku = itemBll.GetPromotionInfoBySku(sku);
                var price        = entity.DiscountPrice;
                if (entity.DiscountPrice == 0 || (promotionsku.Count > 0 && promotionsku.FirstOrDefault().PromotionType == 2))
                {
                    price = entity.MinPrice;
                }
                int realTaxType = Utility.Uitl.TotalTaxHelper.GetRealTaxType(entity.ReportStatus, entity.IsCrossBorderEBTax, price * base.ExchangeRate);
                if (qty > 1 && realTaxType == 2 && (qty * price * base.ExchangeRate > base.OrderLimitValue))
                {
                    return(Json(new { Type = 0, Content = "单笔订单金额不能超过" + base.OrderLimitValue + "元。" }, JsonRequestBehavior.AllowGet));
                }
                if (realTaxType == 1 && (qty * price * base.ExchangeRate > base.ConsolidatedPrice))
                {
                    return(Json(new { Type = 0, Content = "单笔订单金额不能超过" + base.ConsolidatedPrice + "元。" }, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex);
            }
            return(Json(new { Type = 1, Content = "", LinkUrl = "/buy/buynow?sku=" + sku + "&qty=" + qty }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 根据产品SKU唯一编号查询SKU
        /// </summary>
        /// <returns></returns>
        public ActionResult GetSku()
        {
            string             CompanyID = WebUtil.GetFormValue <string>("CompanyID");
            string             SnNum     = WebUtil.GetFormValue <string>("SnNum");
            ProductSkuProvider provider  = new ProductSkuProvider(CompanyID);

            ProductSkuEntity entity = provider.GetSku(SnNum);

            DataResult <ProductSkuEntity> dataResult = new DataResult <ProductSkuEntity>();

            dataResult.Code    = (int)EResponseCode.Success;
            dataResult.Message = "响应成功";
            dataResult.Result  = entity;

            return(Content(JsonHelper.SerializeObject(dataResult)));
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 商品进口商品税页面
        /// </summary>
        /// <param name="sku"></param>
        /// <param name="qty"></param>
        /// <returns></returns>
        public ActionResult ImportTariff(string sku, int qty, int pid, string teamcode)
        {
            ProductSkuEntity entity = new ProductSkuEntity();

            ViewBag.BuyQty = qty;
            if (string.IsNullOrWhiteSpace(sku))
            {
                return(Redirect("/home/error"));
            }
            if (qty < 1)
            {
                return(Redirect("/home/error"));
            }
            try
            {
                entity = productBll.GetProductBySku(sku, base.language);
                if (entity == null)
                {
                    return(Redirect("/home/error"));
                }
                if (entity.Qty < qty)
                {
                    return(Redirect("/home/error"));
                }
                var promotionsku = itemBll.GetPromotionInfoBySku(sku);
                var price        = entity.DiscountPrice;
                if (entity.DiscountPrice == 0 || (pid == 0 && promotionsku.Count > 0 && promotionsku.FirstOrDefault().PromotionType == 2 && string.IsNullOrEmpty(teamcode)))
                {
                    price = entity.ProductPrice;
                }
                entity.ProductPrice = price * base.ExchangeRate;
                entity.MinPrice     = entity.MinPrice * base.ExchangeRate;
                entity.Price        = entity.Price * base.ExchangeRate;
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex);
                return(Redirect("/home/error"));
            }
            return(View(entity));
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 编辑产品SKU
        /// </summary>
        /// <returns></returns>
        public ActionResult EditSku()
        {
            string           CompanyID = WebUtil.GetFormValue <string>("CompanyID");
            ProductSkuEntity entity    = WebUtil.GetFormObject <ProductSkuEntity>("Entity");

            ProductSkuProvider provider = new ProductSkuProvider(CompanyID);
            int line = provider.EditSku(entity);

            DataResult dataResult = new DataResult();

            if (line > 0)
            {
                dataResult.Code    = (int)EResponseCode.Success;
                dataResult.Message = "编辑成功";
            }
            else
            {
                dataResult.Code    = (int)EResponseCode.Exception;
                dataResult.Message = "编辑失败";
            }
            return(Content(JsonHelper.SerializeObject(dataResult)));
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 批量删除产品SKU
        /// </summary>
        /// <param name="list"></param>
        /// <returns></returns>
        public int DeleteSku(List <string> list)
        {
            string[] items = null;
            if (!list.IsNullOrEmpty())
            {
                items = list.ToArray();
            }
            if (items.IsNullOrEmpty())
            {
                items = new string[] { "" };
            }
            ProductSkuEntity skuEntity = new ProductSkuEntity();

            skuEntity.IsDelete = (int)EIsDelete.Deleted;
            skuEntity.IncludeIsDelete(true);
            skuEntity.Where("SnNum", ECondition.In, items);
            skuEntity.And(item => item.CompanyID == this.CompanyID);

            int line = this.ProductSku.Update(skuEntity);

            return(line);
        }
Ejemplo n.º 12
0
        public ActionResult BuyNow(string sku, int qty, int?aid, string teamcode, int pid = 0)
        {
            ProductSkuEntity entity = new ProductSkuEntity();

            ViewBag.BuyQty   = qty;
            ViewBag.Pid      = pid;
            ViewBag.TeamCode = teamcode;
            if (aid.HasValue)
            {
                ViewBag.ChooseAddressId = aid.AsInt32();
            }
            else
            {
                ViewBag.ChooseAddressId = 0;
            }
            if (string.IsNullOrWhiteSpace(sku))
            {
                return(Redirect("/home/error"));
            }
            if (qty < 1)
            {
                return(Redirect("/home/error"));
            }
            try
            {
                entity = new ProductSkuEntity();
                entity = productBll.GetProductBySku(sku, language);
                if (pid != 0)
                {
                    var proList = itemBll.GetPromotionInfoByPid(pid);
                    if (proList.Count() == 0 || proList.FirstOrDefault().Sku != sku)
                    {
                        return(Redirect("/product/FightIndex"));
                    }
                }
                if (entity == null)
                {
                    return(Redirect("/home/error"));
                }
                if (entity.Qty < qty)
                {
                    return(Redirect("/home/error"));
                }
                if (entity.SalesTerritory != base.DeliveryRegion && entity.SalesTerritory != 3)
                {
                    return(Redirect("/home/error"));
                }
                var ping  = 0;
                int proid = 0;
                if (!string.IsNullOrEmpty(teamcode))
                {
                    var teaminfo = teamBll.GetTeamInfoByTeamCode(teamcode);
                    ping  = teaminfo.TeamStatus;
                    proid = teaminfo.PromotionId;
                    if (teaminfo.UserID == this.LoginUser.UserID || teaminfo.TeamStatus != 1)
                    {
                        return(Redirect("/Team/teamDetail?TeamCode=" + teamcode + "&Flag=1"));
                    }
                }
                var cart = base.GetBuyVirtualCart(entity, ping, proid);//计算促销信息
                var item = cart.Items.FirstOrDefault();
                if (item == null)
                {
                    return(Redirect("/home/error"));
                }


                entity.ProductPrice = item.SalePriceExchanged;
                var promotionsku = itemBll.GetPromotionInfoBySku(item.Sku);
                if (pid == 0 && (promotionsku.Count > 0 && promotionsku.FirstOrDefault().PromotionType == 2) && string.IsNullOrEmpty(teamcode))
                {
                    entity.ProductPrice = item.PriceExchanged;
                }

                ViewBag.IsShowHuoli = false;
                var HuoliEntity = accountBll.GetHuoliEntityByUerId(this.LoginUser.UserID);
                if (HuoliEntity == null)
                {
                    ViewBag.IsShowHuoli = true;
                }
                else
                {
                    if (HuoliEntity.HuoLiCurrent <= 0 || !string.IsNullOrEmpty(teamcode))
                    {
                        ViewBag.IsShowHuoli = true;
                    }
                }
                //========================优惠券===========================
                //如果使用酒豆,则首先检查一下是否有默认可用的优惠券,如果有,则得减掉默认优惠券面值之后再*90%得到可用优惠券
                int quanType = Convert.ToInt32(PromotionType.None);
                if (promotionsku.Count > 0)
                {
                    if (promotionsku.FirstOrDefault().PromotionType == 1)
                    {
                        quanType = Convert.ToInt32(PromotionType.Promotion);//1.打折 2.拼团   对应的枚举-->  打折:0x02 拼团0x04
                    }
                    else if (promotionsku.FirstOrDefault().PromotionType == 2)
                    {
                        if (pid != 0 || !string.IsNullOrEmpty(teamcode))
                        {
                            quanType = Convert.ToInt32(PromotionType.GroupBuy);
                        }
                    }
                }
                //获取默认优惠券
                decimal totleAmount = entity.ProductPrice * qty;

                var GiftCardNotUsedList = giftCardBll.GetCanUseGiftCardList(base.LoginUser.UserID, totleAmount, quanType);
                //转换成 ViewModel集合,并进行酒豆操作
                List <CanUseGiftCardViewModel> vmlist = new List <CanUseGiftCardViewModel>();
                //如果有酒豆
                if (!ViewBag.IsShowHuoli)
                {
                    if (GiftCardNotUsedList != null)
                    {
                        ViewBag.HuoliNoUseGiftCard      = BuyOrderManager.GetCanUseHuoli(totleAmount, HuoliEntity.HuoLiCurrent, 0M);
                        ViewBag.HuoliMoneyNoUseGiftCard = (BuyOrderManager.GetCanUseHuoli(totleAmount, HuoliEntity.HuoLiCurrent, 0M) / 100).ToNumberRoundStringWithPoint();
                        var     GiftCardEntityDefault = GiftCardNotUsedList.FirstOrDefault();
                        decimal cardValue             = 0M;
                        if (GiftCardEntityDefault != null)
                        {
                            cardValue = GiftCardEntityDefault.CardSum;
                        }
                        foreach (var model in GiftCardNotUsedList)
                        {
                            var vm = giftCardBll.EntityToViewModel(model);
                            vm.Huoli = BuyOrderManager.GetCanUseHuoli(totleAmount, HuoliEntity.HuoLiCurrent, model.CardSum);
                            vm.Money = (BuyOrderManager.GetCanUseHuoli(totleAmount, HuoliEntity.HuoLiCurrent, model.CardSum) / 100).ToNumberRoundStringWithPoint();
                            vmlist.Add(vm);
                        }
                        decimal huoli = BuyOrderManager.GetCanUseHuoli(totleAmount, HuoliEntity.HuoLiCurrent, cardValue);
                        ViewBag.Huoli = huoli;
                    }
                    else
                    {
                        ViewBag.Huoli = BuyOrderManager.GetCanUseHuoli(totleAmount, HuoliEntity.HuoLiCurrent, 0M);
                    }
                }
                else//没有酒豆,直接返回可用的优惠券即可
                {
                    if (GiftCardNotUsedList != null)
                    {
                        foreach (var model in GiftCardNotUsedList)
                        {
                            var vm = giftCardBll.EntityToViewModel(model);
                            vmlist.Add(vm);
                        }
                    }
                }
                ViewBag.GiftCardList = vmlist;

                //========================时令美食 获得限购数量 开始===========================
                // 判断是否是节日食品
                bool IsHolidayFoods = productBll.isHolidayGoods(entity.Spu);
                if (IsHolidayFoods)
                {
                    // 根据sku获取时令美食spu信息
                    ProductExpandEntity HolidaySpuInfo = productBll.GetHolidaySpuInfoBySku(sku, language);

                    if (HolidaySpuInfo == null)
                    {
                        return(Redirect("/home/error"));
                    }

                    // 时令美食 月饼
                    if (Convert.ToString(HolidaySpuInfo.CategoryId).Equals(System.Web.Configuration.WebConfigurationManager.AppSettings["MoonCakeKey"].ToString()))
                    {
                        if (HolidaySpuInfo.Weight <= 0)
                        {
                            return(Redirect("/home/error"));
                        }

                        // 只根据重量进行限量判断:1、不能超过两件 2、不能超过3Kg
                        decimal MaxNum = holidayBll.GetCanBuyNumberByWeight(HolidaySpuInfo.Weight);

                        ViewBag.HolidayMaxNum = MaxNum;
                    }
                }

                //========================时令美食 获得限购数量 结束===========================

                //entity.ProductPrice * base.ExchangeRate;
                //entity.MinPrice = entity.MinPrice * base.ExchangeRate;
                //entity.Price = entity.Price * base.ExchangeRate;
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex);
                return(Redirect("/home/error"));
            }
            return(View(entity));
        }
Ejemplo n.º 13
0
        public JsonResult BuyNowUpdateQty(string sku, int qty)
        {
            ProductSkuEntity entity = new ProductSkuEntity();

            if (string.IsNullOrWhiteSpace(sku))
            {
                return(Json(new { Type = 0, Content = "参数错误:缺少商品号。" }, JsonRequestBehavior.AllowGet));
            }
            if (qty < 1)
            {
                return(Json(new { Type = 0, Content = "最少购买一件选定的商品。" }, JsonRequestBehavior.AllowGet));
            }

            try
            {
                entity = productBll.GetProductBySku(sku, language);
                if (entity == null)
                {
                    return(Json(new { Type = 0, Content = "该商品不存在或已下架。" }, JsonRequestBehavior.AllowGet));
                }
                if (entity.Qty < qty)
                {
                    return(Json(new { Type = 0, Content = "您要订购的商品库存量不足。" }, JsonRequestBehavior.AllowGet));
                }
                if (entity.SalesTerritory != base.DeliveryRegion && entity.SalesTerritory != 3)
                {
                    return(Json(new { Type = 0, Content = "您要订购的商品无法在当前区域配送。" }, JsonRequestBehavior.AllowGet));
                }

                var promotionsku = itemBll.GetPromotionInfoBySku(sku);
                var price        = entity.DiscountPrice;
                if (entity.DiscountPrice == 0 || (promotionsku.Count > 0 && promotionsku.FirstOrDefault().PromotionType == 2))
                {
                    price = entity.MinPrice;
                }

                //--------------------------------------------时令美食相关购买条件验证 开始---------------------------------------------------------------
                // 时令美食购买条件验证
                Dictionary <int, string> ResultMap = productBll.CheckSkuHolidaySpuValidate(
                    sku, qty, entity.Spu, base.language, base.ExchangeRate, false, price);

                Dictionary <int, string> .KeyCollection types = ResultMap.Keys;

                int    HolidaySpuType    = -1;
                string HolidaySpuContent = string.Empty;

                foreach (int type in types)
                {
                    HolidaySpuType    = type;
                    HolidaySpuContent = ResultMap[type].ToString();
                }

                // 不符合购买条件
                if (HolidaySpuType == 0)
                {
                    return(Json(new { Type = 0, Content = HolidaySpuContent }, JsonRequestBehavior.AllowGet));
                }
                //--------------------------------------------时令美食相关购买条件验证 结束---------------------------------------------------------------

                int     realTaxType = Utility.Uitl.TotalTaxHelper.GetRealTaxType(entity.ReportStatus, entity.IsCrossBorderEBTax, price * base.ExchangeRate);
                decimal taxPrice    = Utility.Uitl.TotalTaxHelper.GetTotalTaxAmount(realTaxType, price * base.ExchangeRate, entity.CBEBTaxRate / 100, entity.ConsumerTaxRate / 100, entity.VATTaxRate / 100, entity.PPATaxRate / 100);
                if (qty > 1 && realTaxType == 2 && (qty * price * base.ExchangeRate > base.OrderLimitValue))
                {
                    return(Json(new { Type = 0, Content = "单笔订单金额不能超过" + base.OrderLimitValue + "元。" }, JsonRequestBehavior.AllowGet));
                }
                if (realTaxType == 1 && (qty * price * base.ExchangeRate > base.ConsolidatedPrice))
                {
                    return(Json(new { Type = 0, Content = "单笔订单金额不能超过" + Math.Round(base.ConsolidatedPrice, 2, MidpointRounding.AwayFromZero) + "元。" }, JsonRequestBehavior.AllowGet));
                }
                if (entity.IsDutyOnSeller == 1)
                {
                    taxPrice = 0;
                }
                else
                {
                    if (realTaxType == 2 && taxPrice * qty < 50)
                    {
                        taxPrice = 0;
                    }
                }
                var taxTemp = Math.Round(taxPrice, 2, MidpointRounding.AwayFromZero);

                //-------------------------------------------------------------------优惠券---------------------------------------------------------------
                //2016.06.3添加:可用优惠券, 默认是1:原价商品 0x01
                int quanType = Convert.ToInt32(PromotionType.None);
                if (promotionsku.Count > 0)
                {
                    if (promotionsku.FirstOrDefault().PromotionType == 1)
                    {
                        quanType = Convert.ToInt32(PromotionType.Promotion);//1.打折 2.拼团   对应的枚举-->  打折:0x02 拼团0x04
                    }
                }
                //获取选中的优惠券
                decimal totleAmount        = price * qty * base.ExchangeRate;
                var     CanUseGiftCardList = giftCardBll.GetCanUseGiftCardList(base.LoginUser.UserID, totleAmount, quanType);
                var     HuoliEntity        = accountBll.GetHuoliEntityByUerId(this.LoginUser.UserID);

                decimal huoli      = 0M;
                string  huoLiMoney = "0";
                List <CanUseGiftCardViewModel> clist = new List <CanUseGiftCardViewModel>();
                if (CanUseGiftCardList != null)
                {
                    if (HuoliEntity != null)
                    {
                        //任性可用酒豆
                        huoli      = BuyOrderManager.GetCanUseHuoli(totleAmount, HuoliEntity.HuoLiCurrent, 0M);
                        huoLiMoney = (huoli / 100).ToNumberRoundStringWithPoint();
                        foreach (var card in CanUseGiftCardList)
                        {
                            var vm = giftCardBll.EntityToViewModel(card);
                            vm.Huoli = BuyOrderManager.GetCanUseHuoli(totleAmount, HuoliEntity.HuoLiCurrent, card.CardSum);
                            vm.Money = (BuyOrderManager.GetCanUseHuoli(totleAmount, HuoliEntity.HuoLiCurrent, card.CardSum) / 100).ToNumberRoundStringWithPoint();
                            clist.Add(vm);
                        }
                    }
                    else
                    {
                        foreach (var card in CanUseGiftCardList)
                        {
                            var vm = giftCardBll.EntityToViewModel(card);
                            clist.Add(vm);
                        }
                    }
                }
                else
                {
                    if (HuoliEntity != null)
                    {
                        //任性可用酒豆
                        huoli      = BuyOrderManager.GetCanUseHuoli(totleAmount, HuoliEntity.HuoLiCurrent, 0M);
                        huoLiMoney = (huoli / 100).ToNumberRoundStringWithPoint();
                    }
                }

                return(Json(new { Type = 1, Content = (taxTemp * qty) == 0 ? "0.00" : (taxTemp * qty).ToString(), Huoli = huoli, Money = huoLiMoney, disList = clist }, JsonRequestBehavior.AllowGet));
                //return Json(new { Type = 1, Content = (taxTemp * qty) == 0 ? "0.00" : (taxTemp * qty).ToString(), Huoli = huoli, Monney = (huoli / 100).ToNumberRoundStringWithPoint() }, JsonRequestBehavior.AllowGet);
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex);
                return(Json(new { Type = 0, Content = "系统错误,请稍后再试。" }, JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 14
0
        /// <summary>
        /// 编辑带有SKU的产品
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="listSku"></param>
        /// <returns></returns>
        public int Edit(ProductEntity entity, List <ProductSkuEntity> listSku)
        {
            using (TransactionScope ts = new TransactionScope())
            {
                if (!entity.CateNum.IsEmpty())
                {
                    ProductCategoryEntity category = new ProductCategoryProvider(this.CompanyID).GetSingle(entity.CateNum);
                    entity.CateName = category != null ? category.CateName : "";
                }
                if (!entity.UnitNum.IsEmpty())
                {
                    MeasureEntity meaure = new MeasureProvider(this.CompanyID).GetMeasure(entity.UnitNum);
                    entity.UnitName = meaure != null ? meaure.MeasureName : "";
                }
                entity.Include(a => new { a.ProductName, a.BarCode, a.FactoryNum, a.InCode, a.UnitNum, a.UnitName, a.CateNum, a.CateName, a.StorageNum, a.DefaultLocal, a.CusNum, a.CusName, a.SupNum, a.SupName, a.Description, a.Display, a.Remark });
                entity.Where(a => a.SnNum == entity.SnNum)
                .And(a => a.CompanyID == this.CompanyID);

                int line = this.Product.Update(entity);

                if (!listSku.IsNullOrEmpty())
                {
                    ProductSkuEntity SkuEntity = new ProductSkuEntity();
                    SkuEntity.IncludeAll();
                    SkuEntity.Where(a => a.ProductNum == entity.SnNum)
                    .And(a => a.IsDelete == (int)EIsDelete.NotDelete)
                    .And(a => a.CompanyID == this.CompanyID)
                    ;
                    List <ProductSkuEntity> listSource = this.ProductSku.GetList(SkuEntity);
                    listSource = listSource.IsNull() ? new List <ProductSkuEntity>() : listSource;

                    listSku = listSku.IsNull() ? new List <ProductSkuEntity>() : listSku;

                    foreach (ProductSkuEntity item in listSku)
                    {
                        item.SnNum = item.SnNum.IsEmpty() ? ConvertHelper.NewGuid() : item.SnNum;
                        if (listSource.Exists(a => a.SnNum == item.SnNum))
                        {
                            item.Include(b => new { b.Size, b.Color, b.NetWeight, b.GrossWeight, b.InPrice, b.AvgPrice, b.OutPrice });
                            item.Where(b => b.SnNum == item.SnNum).And(b => b.CompanyID == this.CompanyID);
                            line += this.ProductSku.Update(item);
                        }
                        else
                        {
                            item.IsDelete   = (int)EIsDelete.NotDelete;
                            item.CreateTime = DateTime.Now;
                            item.CompanyID  = this.CompanyID;
                            item.IncludeAll();
                            line += this.ProductSku.Add(item);
                        }
                    }

                    foreach (ProductSkuEntity item in listSource)
                    {
                        if (!listSku.Exists(a => a.SnNum == item.SnNum))
                        {
                            item.IsDelete = (int)EIsDelete.Deleted;
                            item.IncludeIsDelete(true);
                            item.Where(b => b.SnNum == item.SnNum).And(b => b.CompanyID == this.CompanyID);
                            line += this.ProductSku.Update(item);
                        }
                    }
                }
                ts.Complete();
                return(line);
            }
        }