Ejemplo n.º 1
0
        public int Insert(SaleGiftInfo oParam)
        {
            string sql = @"INSERT INTO Sale_Gift
                           (
                           ProductSysNo, GiftSysNo, ListOrder, 
                           CreateUserSysNo)
                           VALUES (
                           @ProductSysNo, @GiftSysNo, @ListOrder, 
                           @CreateUserSysNo)";

            SqlCommand cmd = new SqlCommand(sql);

            SqlParameter paramProductSysNo    = new SqlParameter("@ProductSysNo", SqlDbType.Int, 4);
            SqlParameter paramGiftSysNo       = new SqlParameter("@GiftSysNo", SqlDbType.Int, 4);
            SqlParameter paramListOrder       = new SqlParameter("@ListOrder", SqlDbType.NVarChar, 10);
            SqlParameter paramCreateUserSysNo = new SqlParameter("@CreateUserSysNo", SqlDbType.Int, 4);

            if (oParam.ProductSysNo != AppConst.IntNull)
            {
                paramProductSysNo.Value = oParam.ProductSysNo;
            }
            else
            {
                paramProductSysNo.Value = System.DBNull.Value;
            }
            if (oParam.GiftSysNo != AppConst.IntNull)
            {
                paramGiftSysNo.Value = oParam.GiftSysNo;
            }
            else
            {
                paramGiftSysNo.Value = System.DBNull.Value;
            }
            if (oParam.ListOrder != AppConst.StringNull)
            {
                paramListOrder.Value = oParam.ListOrder;
            }
            else
            {
                paramListOrder.Value = System.DBNull.Value;
            }
            if (oParam.CreateUserSysNo != AppConst.IntNull)
            {
                paramCreateUserSysNo.Value = oParam.CreateUserSysNo;
            }
            else
            {
                paramCreateUserSysNo.Value = System.DBNull.Value;
            }

            cmd.Parameters.Add(paramProductSysNo);
            cmd.Parameters.Add(paramGiftSysNo);
            cmd.Parameters.Add(paramListOrder);
            cmd.Parameters.Add(paramCreateUserSysNo);

            return(SqlHelper.ExecuteNonQuery(cmd));
        }
Ejemplo n.º 2
0
        public int Update(SaleGiftInfo oParam)
        {
            string     sql = @"UPDATE Sale_Gift SET 
                           Status=@Status,AbandonUserSysNo=@AbandonUserSysNo, 
                           AbandonTime=@AbandonTime
                           WHERE SysNo=@SysNo";
            SqlCommand cmd = new SqlCommand(sql);

            SqlParameter paramSysNo            = new SqlParameter("@SysNo", SqlDbType.Int, 4);
            SqlParameter paramStatus           = new SqlParameter("@Status", SqlDbType.Int, 4);
            SqlParameter paramAbandonUserSysNo = new SqlParameter("@AbandonUserSysNo", SqlDbType.Int, 4);
            SqlParameter paramAbandonTime      = new SqlParameter("@AbandonTime", SqlDbType.DateTime);

            if (oParam.SysNo != AppConst.IntNull)
            {
                paramSysNo.Value = oParam.SysNo;
            }
            else
            {
                paramSysNo.Value = System.DBNull.Value;
            }
            if (oParam.Status != AppConst.IntNull)
            {
                paramStatus.Value = oParam.Status;
            }
            else
            {
                paramStatus.Value = System.DBNull.Value;
            }
            if (oParam.AbandonUserSysNo != AppConst.IntNull)
            {
                paramAbandonUserSysNo.Value = oParam.AbandonUserSysNo;
            }
            else
            {
                paramAbandonUserSysNo.Value = System.DBNull.Value;
            }
            if (oParam.AbandonTime != AppConst.DateTimeNull)
            {
                paramAbandonTime.Value = oParam.AbandonTime;
            }
            else
            {
                paramAbandonTime.Value = System.DBNull.Value;
            }

            cmd.Parameters.Add(paramSysNo);
            cmd.Parameters.Add(paramStatus);
            cmd.Parameters.Add(paramAbandonUserSysNo);
            cmd.Parameters.Add(paramAbandonTime);

            return(SqlHelper.ExecuteNonQuery(cmd));
        }
Ejemplo n.º 3
0
        public void CreateGloableSaleRules(int promotionSysNo, SaleGiftInfo info)
        {
            DataCommand cmd = DataCommandManager.GetDataCommand("SaleGift_CreateSaleRules");

            cmd.SetParameterValue("@PromotionSysNo", promotionSysNo);
            //cmd.SetParameterValue("@Type", info.Type);
            cmd.SetParameterValue("@Type", SaleGiftSaleRuleType.Brand);
            cmd.SetParameterValue("@C3SysNo", null);
            cmd.SetParameterValue("@BrandSysNo", null);
            cmd.SetParameterValue("@ProductSysNo", null);
            cmd.SetParameterValue("@BuyCount", null);
            cmd.SetParameterValue("@ComboType", info.GiftComboType);
            cmd.ExecuteNonQuery();
        }
Ejemplo n.º 4
0
        public void UpdateMaster(SaleGiftInfo info)
        {
            DataCommand cmd = DataCommandManager.GetDataCommand("SaleGift_UpdateSaleGiftMaster");

            cmd.SetParameterValue("@SysNo", info.SysNo);
            cmd.SetParameterValue("@PromotionName", info.Title.Content);
            cmd.SetParameterValue("@PromotionDesc", info.Description.Content);
            cmd.SetParameterValue("@BeginDate", info.BeginDate);
            cmd.SetParameterValue("@Enddate", info.EndDate);
            cmd.SetParameterValue("@AmountLimit", info.OrderCondition.OrderMinAmount);
            cmd.SetParameterValue("@PromotionLink", info.PromotionLink);
            cmd.SetParameterValue("@Memo", info.Memo);
            cmd.SetParameterValue("@EditUser", info.EditUser);
            cmd.SetParameterValue("@DisCountType", info.DisCountType);
            cmd.SetParameterValue("@VendorSysNo", info.VendorSysNo);
            cmd.ExecuteNonQuery();
        }
Ejemplo n.º 5
0
        //针对单品买赠这种情况:单品、厂商赠品
        private void ProcessSingleGift(ref OrderInfo order, SaleGiftInfo saleGift)
        {
            List <GiftSaleRule> saleRuleList = saleGift.GiftSaleRuleList;

            //轮询处理每个商品是否满足单品买赠这类活动
            foreach (OrderItemGroup orderItemGroup in order.OrderItemGroupList)
            {
                foreach (OrderProductItem orderProductItem in orderItemGroup.ProductItemList)
                {
                    if (saleRuleList.Exists(f => f.RelProductSysNo == orderProductItem.ProductSysNo))
                    {
                        foreach (GiftItem giftItem in saleGift.GiftItemList)
                        {
                            OrderGiftItem orderGiftItem = new OrderGiftItem()
                            {
                                ActivityNo         = saleGift.SysNo.Value,
                                ActivityName       = saleGift.PromotionName,
                                IsGiftPool         = saleGift.IsGiftPool,
                                IsSelect           = false,
                                ParentCount        = orderProductItem.UnitQuantity * orderItemGroup.Quantity,
                                ParentPackageNo    = orderItemGroup.PackageNo,
                                ParentProductSysNo = orderProductItem.ProductSysNo,
                                ProductID          = giftItem.ProductID,
                                ProductName        = giftItem.ProductName,
                                DefaultImage       = giftItem.DefaultImage,
                                ProductSysNo       = giftItem.ProductSysNo,
                                SaleGiftType       = saleGift.SaleGiftType,
                                UnitQuantity       = saleGift.IsGiftPool ? 1 : giftItem.UnitQuantity,
                                PoolLimitCount     = saleGift.IsGiftPool && saleGift.ItemGiftCount.HasValue && saleGift.ItemGiftCount.Value > 0 ? saleGift.ItemGiftCount.Value : 1,
                                UnitSalePrice      = giftItem.PlusPrice,
                                UnitCostPrice      = giftItem.UnitCost,
                                MerchantSysNo      = giftItem.MerchantSysNo,
                                Weight             = giftItem.Weight,
                                UnitRewardedPoint  = giftItem.UnitRewardedPoint,
                            };
                            orderGiftItem["Warranty"] = giftItem.Warranty;
                            order.GiftItemList.Add(orderGiftItem);
                        }
                    }
                }
            }
        }
Ejemplo n.º 6
0
        private SaleGiftInfo VtoE(SaleGiftInfoViewModel viewModel)
        {
            viewModel.ProductCondition = new ObservableCollection <SaleGift_RuleSettingViewModel>();
            if (viewModel.ProductOnlyList != null)
            {
                viewModel.ProductOnlyList.ForEach(p =>
                {
                    viewModel.ProductCondition.Add(p);
                });
            }
            if (viewModel.BrandC3ScopeList != null)
            {
                viewModel.BrandC3ScopeList.ForEach(p =>
                {
                    viewModel.ProductCondition.Add(p);
                });
            }
            if (viewModel.ProductScopeList != null)
            {
                viewModel.ProductScopeList.ForEach(p =>
                {
                    viewModel.ProductCondition.Add(p);
                });
            }
            if (viewModel.GiftItemList != null)
            {
                if (viewModel.GiftComboType == SaleGiftGiftItemType.GiftPool)
                {
                    foreach (SaleGift_GiftItemViewModel giftitem in viewModel.GiftItemList)
                    {
                        giftitem.Count = null;
                    }
                }
            }

            SaleGiftInfo entity = viewModel.ConvertVM <SaleGiftInfoViewModel, SaleGiftInfo>();

            entity.Title       = new BizEntity.LanguageContent(viewModel.Title);
            entity.Description = new BizEntity.LanguageContent(viewModel.Description);

            return(entity);
        }
Ejemplo n.º 7
0
        public SaleGiftInfo Load(int?sysNo)
        {
            SaleGiftInfo info = null;
            DataCommand  cmd  = DataCommandManager.GetDataCommand("SaleGift_LoadSaleGift");

            cmd.SetParameterValue("@SysNo", sysNo);
            DataSet   ds       = cmd.ExecuteDataSet();
            DataTable dtMaster = ds.Tables[0];

            if (dtMaster.Rows.Count == 0)
            {
                return(info);
            }
            info = DataMapper.GetEntity <SaleGiftInfo>(dtMaster.Rows[0], (row, entity) =>
            {
                entity.Title          = new LanguageContent(row["PromotionName"].ToString().Trim());
                entity.Description    = new LanguageContent(row["PromotionDesc"] != null ? row["PromotionDesc"].ToString().Trim() : "");
                entity.OrderCondition = new PSOrderCondition();
                if (row["AmountLimit"] != null && !string.IsNullOrEmpty(row["AmountLimit"].ToString().Trim()))
                {
                    entity.OrderCondition.OrderMinAmount = Math.Round(decimal.Parse(row["AmountLimit"].ToString()), 2);
                }
                entity.IsGlobalProduct = row["IsGlobal"] != null ? (row["IsGlobal"].ToString().Trim() == "Y" ? true : false) : false;
            });

            info.ProductCondition = new List <SaleGift_RuleSetting>();
            DataTable dt2 = ds.Tables[1];

            if (dt2 != null && dt2.Rows.Count > 0)
            {
                info.ProductCondition = DataMapper.GetEntityList <SaleGift_RuleSetting, List <SaleGift_RuleSetting> >(dt2.Rows);
            }

            DataTable dt3 = ds.Tables[2];

            if (dt3 != null && dt3.Rows.Count > 0)
            {
                info.GiftItemList = DataMapper.GetEntityList <RelProductAndQty, List <RelProductAndQty> >(dt3.Rows);
            }
            return(info);
        }
Ejemplo n.º 8
0
        public void Load(int?sysNo, SaleGiftInfoViewModel viewModel, EventHandler <RestClientEventArgs <SaleGiftInfoViewModel> > callback)
        {
            if (!sysNo.HasValue)
            {
                callback(new Object(), new RestClientEventArgs <SaleGiftInfoViewModel>(viewModel, restClient.Page));
                return;
            }
            string relativeUrl = string.Format("/MKTService/SaleGift/{0}", sysNo.Value);

            restClient.Query <SaleGiftInfo>(relativeUrl, (obj, args) =>
            {
                if (args.FaultsHandle())
                {
                    return;
                }

                SaleGiftInfo entity = args.Result;
                viewModel           = EtoV(entity);

                callback(obj, new RestClientEventArgs <SaleGiftInfoViewModel>(viewModel, restClient.Page));
            });
        }
Ejemplo n.º 9
0
        public int?CreateMaster(SaleGiftInfo info)
        {
            DataCommand cmd = DataCommandManager.GetDataCommand("SaleGift_CreateSaleGiftMaster");

            cmd.SetParameterValue("@PromotionName", info.Title.Content);
            cmd.SetParameterValue("@PromotionDesc", info.Description.Content);
            cmd.SetParameterValue("@Type", info.Type);
            cmd.SetParameterValue("@Status", SaleGiftStatus.Init);
            cmd.SetParameterValue("@BeginDate", info.BeginDate);
            cmd.SetParameterValue("@Enddate", info.EndDate);
            cmd.SetParameterValue("@AmountLimit", info.OrderCondition.OrderMinAmount == null ? 0 : info.OrderCondition.OrderMinAmount.Value);
            cmd.SetParameterValue("@PromotionLink", info.PromotionLink);
            cmd.SetParameterValue("@Memo", info.Memo);
            cmd.SetParameterValue("@InUser", info.InUser ?? "");
            cmd.SetParameterValue("@DisCountType", info.DisCountType);
            cmd.SetParameterValue("@IsGlobal", info.IsGlobalProduct.HasValue && info.IsGlobalProduct.Value ? "Y" : "N");
            cmd.SetParameterValue("@CompanyCode", info.CompanyCode);
            cmd.SetParameterValue("@VendorSysNo", info.VendorSysNo);
            cmd.ExecuteNonQuery();
            info.SysNo = (int)cmd.GetParameterValue("@SysNo");
            return(info.SysNo);
        }
Ejemplo n.º 10
0
        private SaleGiftInfoViewModel EtoV(SaleGiftInfo entity)
        {
            SaleGiftInfoViewModel viewmodel = entity.Convert <SaleGiftInfo, SaleGiftInfoViewModel>((en, vm) =>
            {
                vm.Title       = entity.Title.Content;
                vm.Description = entity.Description.Content;
            });

            if (entity.WebChannel != null)
            {
                viewmodel.WebChannel = new Basic.Components.Models.WebChannelVM()
                {
                    ChannelID = entity.WebChannel.ChannelID, ChannelName = entity.WebChannel.ChannelName
                };
            }
            else
            {
                viewmodel.WebChannel = viewmodel.WebChennelList[0];
            }
            //目前只有买满即送才有复杂的主商品范围规则
            viewmodel.BrandC3ScopeList = new ObservableCollection <SaleGift_RuleSettingViewModel>();
            viewmodel.ProductScopeList = new ObservableCollection <SaleGift_RuleSettingViewModel>();
            viewmodel.ProductOnlyList  = new ObservableCollection <SaleGift_RuleSettingViewModel>();

            //modified by poseidon.y.tong at 2013-08-22 10:36:48
            //新增赠品类型:首次下单、满额加购都有复杂的商品范围规则
            if (viewmodel.Type.Value == SaleGiftType.Full)
            //||  viewmodel.Type.Value == SaleGiftType.FirstOrder  || viewmodel.Type.Value == SaleGiftType.Additional)
            {
                foreach (SaleGift_RuleSettingViewModel rule in viewmodel.ProductCondition)
                {
                    if (rule.Type.Value != SaleGiftSaleRuleType.Item)
                    {
                        viewmodel.BrandC3ScopeList.Add(rule);
                    }
                    else
                    {
                        viewmodel.ProductScopeList.Add(rule);
                    }
                }
            }
            else
            {
                viewmodel.ProductOnlyList = viewmodel.ProductCondition;
            }

            if (viewmodel.GiftItemList == null)
            {
                viewmodel.GiftItemList = new List <SaleGift_GiftItemViewModel>();
            }
            else
            {
                if (viewmodel.GiftComboType == SaleGiftGiftItemType.GiftPool)
                {
                    foreach (SaleGift_GiftItemViewModel giftitem in viewmodel.GiftItemList)
                    {
                        giftitem.Count = "0";
                    }
                }
            }

            return(viewmodel);
        }
Ejemplo n.º 11
0
 /// <summary>
 /// 更新主信息
 /// </summary>
 /// <param name="info"></param>
 public virtual void UpdateMaster(SaleGiftInfo info)
 {
     _processor.UpdateMaster(info);
 }
Ejemplo n.º 12
0
        private void UpdateSaleRules(BatchCreateSaleGiftSaleRuleInfo info)
        {
            using (TransactionScope ts = new TransactionScope())
            {
                try
                {
                    bool isCheckRule            = false;//是否验证,至少有一条包含规则
                    List <ProductItemInfo> list = _SaleGiftQueryDA.GetSaleRules(info.PromotionSysNo, info.CompanyCode);
                    if (list.Count != 0)
                    {
                        isCheckRule = true;
                    }

                    SaleGiftInfo tempEntity  = _da.Load(info.PromotionSysNo);
                    int          vendorsysno = tempEntity.VendorSysNo.Value;
                    if (tempEntity.VendorType == 0)
                    {
                        vendorsysno = 1;
                    }


                    //先清空数据
                    _BatchCreateSaleGiftDA.DeleteSaleRules(info.PromotionSysNo.ToString());
                    string msg = string.Empty;
                    //再添加
                    if (info.ProductList != null && info.ProductList.Count > 0)
                    {
                        foreach (ProductItemInfo entity in info.ProductList)
                        {
                            //只有状态为1(上架)的商品才允许插入
                            if (entity.ProductStatus != ProductStatus.Active)
                            {
                                //msg += string.Format("商品{0}[#:{1}]必须为上架状态 ", entity.ProductName, entity.ProductID);
                                msg += string.Format(ResouceManager.GetMessageString("MKT.Promotion.SaleGift", "SaleGift_ProductNeedOnline"), entity.ProductName, entity.ProductID);
                            }
                            //如果是厂商赠品必须是排重的
                            SaleGiftInfo gift = _SaleGiftDA.Load(info.PromotionSysNo);
                            if (gift.Type == SaleGiftType.Vendor)
                            {
                                if (_BatchCreateSaleGiftDA.CheckIsVendorGift(entity.ProductSysNo.Value, info.CompanyCode) > 0)
                                {
                                    //msg += string.Format("厂商主商品{0}[#:{1}]存在有效的重复的记录 ", entity.ProductName, entity.ProductID);
                                    msg += string.Format(ResouceManager.GetMessageString("MKT.Promotion.SaleGift", "SaleGift_PrimaryProductExsisit"), entity.ProductName, entity.ProductID);
                                }
                            }
                            //检查不能添加其他商家的商品
                            if (entity.ProductSysNo.HasValue)
                            {
                                int productvendorsysno = _da.GetVendorSysNoByProductSysNo(entity.ProductSysNo.Value);
                                if (productvendorsysno != vendorsysno)
                                {
                                    //msg +=string.Format("规则信息中{0}不能添加其他商家的商品【{1}】 ", tempEntity.VendorName, entity.ProductID);
                                    msg += string.Format(ResouceManager.GetMessageString("MKT.Promotion.SaleGift", "SaleGift_CanntAddOtherMerchantProduct"), entity.ProductName, entity.ProductID);
                                }
                            }
                            _BatchCreateSaleGiftDA.CreateSaleRules(info, entity);
                            isCheckRule = true;
                        }
                    }

                    if (msg != string.Empty)
                    {
                        throw new BizException(msg);
                    }
                    //更新是否全网
                    _BatchCreateSaleGiftDA.UpdateGiftIsGlobal(info.PromotionSysNo, "N", info.CompanyCode, info.InUser);
                    //是否有包含商品
                    if (isCheckRule)
                    {
                        CheckIsHaveInclude(false, info.PromotionSysNo);
                    }
                }
                catch (Exception ex)
                {
                    throw new BizException(ex.Message);
                }
                ts.Complete();
            }
        }
Ejemplo n.º 13
0
        private BatchCreateGiftRuleInfo CreateGiftRules(BatchCreateGiftRuleInfo info)
        {
            string       msg         = string.Empty;
            int          special     = 0;//是否特殊规则1是0否
            SaleGiftInfo g           = _SaleGiftDA.Load(info.PromotionSysNo);
            int          vendorsysno = g.VendorSysNo.Value;

            if (g.VendorType == 0)
            {
                vendorsysno = 1;
            }
            CheckGiftRules(info);

            foreach (ProductItemInfo entity in info.ProductList)
            {
                //只有状态为2(不展示)的赠品才允许插入
                if (entity.ProductStatus == ProductStatus.InActive_UnShow)
                {
                    int count = _BatchCreateSaleGiftDA.CheckGiftRulesForVendor(entity.ProductSysNo, g.Type == SaleGiftType.Vendor?true:false, info.CompanyCode);

                    if (count > 0)
                    {
                        //msg += string.Format("赠品{0}[#:{1}]存在有效记录 ", entity.ProductName, entity.ProductID);
                        msg += string.Format(ResouceManager.GetMessageString("MKT.Promotion.SaleGift", "SaleGift_AlreadyExsistActiceRecord"), entity.ProductName, entity.ProductID);
                        continue;
                    }

                    //判断是否为附件
                    bool isAttachment = ExternalDomainBroker.CheckIsAttachment(entity.ProductSysNo.Value);
                    if (isAttachment)
                    {
                        //msg += string.Format("商品{0}[#:{1}]已经设置成附件,不能设置为赠品 ", entity.ProductName,entity.ProductID);
                        msg += string.Format(ResouceManager.GetMessageString("MKT.Promotion.SaleGift", "SaleGift_AccessoryCannotBeGift"), entity.ProductName, entity.ProductID);
                        continue;
                    }


                    //如果是赠品池,把赠送数量置为NULL
                    if (info.GiftComboType == SaleGiftGiftItemType.GiftPool)
                    {
                        entity.HandselQty = null;
                    }
                    _BatchCreateSaleGiftDA.CreateGiftRules(entity, info);
                }
                else
                {
                    //msg += string.Format("赠品{0}[#:{1}]必须为不展示状态 ", entity.ProductName, entity.ProductID);
                    msg += string.Format(ResouceManager.GetMessageString("MKT.Promotion.SaleGift", "SaleGift_AccessoryCannotBeGift"), entity.ProductName, entity.ProductID);
                }
                //检查不能添加其他商家的商品
                if (entity.ProductSysNo.HasValue)
                {
                    int productvendorsysno = _da.GetVendorSysNoByProductSysNo(entity.ProductSysNo.Value);
                    if (productvendorsysno != vendorsysno)
                    {
                        //msg += string.Format("赠品信息中{0}不能添加其他商家的商品【{1}】 ", g.VendorName, entity.ProductID);
                        msg += string.Format(ResouceManager.GetMessageString("MKT.Promotion.SaleGift", "SaleGift_AccessoryCannotBeGift"), entity.ProductName, entity.ProductID);
                    }
                }
            }
            if (msg != string.Empty)
            {
                throw new BizException(msg);
            }
            else
            {
                _BatchCreateSaleGiftDA.UpdateItemGiftCouontGiftRules(info.PromotionSysNo, (info.GiftComboType == SaleGiftGiftItemType.AssignGift ? null : info.SumCount), info.GiftComboType.Value, info.CompanyCode, info.InUser, special);
            }
            return(info);
        }
Ejemplo n.º 14
0
 public string CheckGiftStockResult(SaleGiftInfo info)
 {
     return(ObjectFactory <SaleGiftAppService> .Instance.CheckGiftStockResult(info));
 }
Ejemplo n.º 15
0
        /// <summary>
        /// 赠品活动中获取销售商品的毛利率:
        /// </summary>
        /// <param name="product"></param>
        /// <param name="minBuyQty"></param>
        /// <param name="giftSaleSysNo"></param>
        /// <returns></returns>
        public virtual decimal GetSaleGift_SaleItemGrossMarginRate(ProductInfo product, int minBuyQty, int giftSaleSysNo, SaleGiftInfo info)
        {
            ProductMarginer productMarginer = new ProductMarginer();

            productMarginer.ProductSysNo = product.SysNo;
            productMarginer.Point        = Convert.ToDecimal(product.ProductPriceInfo.Point);
            productMarginer.UnitCost     = product.ProductPriceInfo.UnitCost;
            productMarginer.CurrentPrice = product.ProductPriceInfo.CurrentPrice.Value;
            productMarginer.CouponAmount = Math.Round(ObjectFactory <GrossMarginProcessor> .Instance.GetCouponCurrentAmountForPM(product) / minBuyQty, 2);
            if (info.GiftComboType == SaleGiftGiftItemType.AssignGift)
            {
                productMarginer.GiftAmount = Math.Round(ObjectFactory <GrossMarginProcessor> .Instance.GetSaleGiftAmountForNotFull(product.SysNo, giftSaleSysNo) / minBuyQty, 2);
            }
            else
            {
                var count = info.ItemGiftCount == null ? 0 : info.ItemGiftCount.Value;
                productMarginer.GiftAmount = Math.Round(ObjectFactory <GrossMarginProcessor> .Instance.GetSaleGiftAmountForFull(product.SysNo, giftSaleSysNo, count) / minBuyQty, 2);
            }

            if (info.Type == SaleGiftType.Multiple && info.DisCountType == SaleGiftDiscountBelongType.BelongMasterItem)
            {
                decimal?salePriceTotalTmp = info.ProductCondition.Where(ps => ps.Type == SaleGiftSaleRuleType.Item)
                                            .Sum(ps => ps.RelProduct.CurrentPrice);
                productMarginer.GiftAmount = productMarginer.GiftAmount * productMarginer.CurrentPrice / salePriceTotalTmp.Value;
            }

            productMarginer.SalePrice = productMarginer.CurrentPrice;
            return(CalcGrossMarginRate(productMarginer));
        }
Ejemplo n.º 16
0
        /// <summary>
        /// 获取赠品所有信息
        /// </summary>
        /// <param name="sysNo"></param>
        /// <returns></returns>
        public virtual SaleGiftInfo Load(int?sysNo)
        {
            SaleGiftInfo info = _processor.Load(sysNo);

            if (info.ProductCondition != null)
            {
                foreach (SaleGift_RuleSetting setting in info.ProductCondition)
                {
                    if (setting.RelBrand != null && setting.RelBrand.SysNo.HasValue)
                    {
                        var brandName = ExternalDomainBroker.GetBrandInfoBySysNo(setting.RelBrand.SysNo.Value);
                        if (brandName != null && brandName.BrandNameLocal != null)
                        {
                            setting.RelBrand.Name = brandName.BrandNameLocal.Content;
                        }
                    }
                    if (setting.RelC3 != null && setting.RelC3.SysNo.HasValue)
                    {
                        var categoryName = ExternalDomainBroker.GetCategory3Info(setting.RelC3.SysNo.Value);
                        if (categoryName != null && categoryName.CategoryName != null)
                        {
                            setting.RelC3.Name = categoryName.CategoryName.Content;
                        }
                    }
                    if (setting.RelProduct != null && setting.RelProduct.ProductSysNo.HasValue)
                    {
                        ProductInfo product = ExternalDomainBroker.GetProductInfo(setting.RelProduct.ProductSysNo.Value);
                        if (product != null)
                        {
                            setting.RelProduct.ProductName = product.ProductName;
                            setting.RelProduct.ProductID   = product.ProductID;
                            //获取商品可用库存,代销库存,毛利率等接口
                            ProductInventoryInfo inventory = ExternalDomainBroker.GetProductTotalInventoryInfo(product.SysNo);
                            setting.RelProduct.AvailableQty = inventory.AvailableQty;
                            setting.RelProduct.ConsignQty   = inventory.ConsignQty;
                            setting.RelProduct.VirtualQty   = inventory.VirtualQty;

                            setting.RelProduct.UnitCost     = product.ProductPriceInfo.UnitCost;
                            setting.RelProduct.CurrentPrice = product.ProductPriceInfo.CurrentPrice;
                        }
                    }
                }

                foreach (SaleGift_RuleSetting setting in info.ProductCondition)
                {
                    if (setting.RelProduct.ProductSysNo.HasValue)
                    {
                        ProductInfo product = ExternalDomainBroker.GetProductInfo(setting.RelProduct.ProductSysNo.Value);
                        if (product != null)
                        {
                            int minBuyQty = setting.RelProduct.MinQty.HasValue ? (setting.RelProduct.MinQty.Value == 0 ? 1 : setting.RelProduct.MinQty.Value) : 1;
                            setting.RelProduct.GrossMarginRate = ObjectFactory <GrossMarginProcessor> .Instance.GetSaleGift_SaleItemGrossMarginRate(product,
                                                                                                                                                    minBuyQty, sysNo.Value, info);
                        }
                    }
                }
            }

            if (info.GiftItemList != null)
            {
                foreach (RelProductAndQty giftItem in info.GiftItemList)
                {
                    ProductInfo product = ExternalDomainBroker.GetProductInfo(giftItem.ProductSysNo.Value);
                    if (product == null)
                    {
                        continue;
                    }
                    giftItem.ProductName = product.ProductName;;
                    giftItem.ProductID   = product.ProductID;
                    //获取商品可用库存,代销库存,毛利率等接口
                    ProductInventoryInfo inventory = ExternalDomainBroker.GetProductTotalInventoryInfo(product.SysNo);
                    if (inventory == null)
                    {
                        continue;
                    }
                    giftItem.AvailableQty    = inventory.AvailableQty;
                    giftItem.ConsignQty      = inventory.ConsignQty;
                    giftItem.VirtualQty      = inventory.VirtualQty;
                    giftItem.GrossMarginRate = ObjectFactory <GrossMarginProcessor> .Instance.GetSaleGift_GiftItemGrossMarginRate(product, info.DisCountType.Value);

                    giftItem.UnitCost     = product.ProductPriceInfo.UnitCost;
                    giftItem.CurrentPrice = product.ProductPriceInfo.CurrentPrice;
                }
            }
            return(info);
        }
Ejemplo n.º 17
0
 public virtual int?CreateSaleGiftMaster(SaleGiftInfo info)
 {
     return(ObjectFactory <SaleGiftAppService> .Instance.CreateMaster(info));
 }
Ejemplo n.º 18
0
 /// <summary>
 ///检查主商品和赠品库存后返回结果
 /// </summary>
 /// <param name="info"></param>
 /// <returns></returns>
 public string CheckGiftStockResult(SaleGiftInfo info)
 {
     return(_processor.CheckGiftStockResult(info));
 }
Ejemplo n.º 19
0
 /// <summary>
 /// 赠品设置
 /// </summary>
 /// <param name="info"></param>
 public virtual void SetGiftItemRules(SaleGiftInfo info)
 {
     _processor.SetGiftItemRules(info);
 }
Ejemplo n.º 20
0
 public void UpdateSaleGiftMaster(SaleGiftInfo info)
 {
     ObjectFactory <SaleGiftAppService> .Instance.UpdateMaster(info);
 }
Ejemplo n.º 21
0
 /// <summary>
 /// 创建赠主信息
 /// </summary>
 /// <param name="info"></param>
 /// <returns></returns>
 public virtual int?CreateMaster(SaleGiftInfo info)
 {
     return(_processor.CreateMaster(info));
 }
Ejemplo n.º 22
0
 public void SetSaleGiftGiftItemRules(SaleGiftInfo info)
 {
     ObjectFactory <SaleGiftAppService> .Instance.SetGiftItemRules(info);
 }