Exemplo n.º 1
0
 private void QueryFreeGoods()
 {
     try
     {
         //查询买赠
         StoreEventMoneyOffRule storeEventMoneyOffRule = Marketing.GetWholeDiscountFreeGoodsEventRules(DiscountType.FreeGoodsDiscount);
         if (storeEventMoneyOffRule == null)
         {
             return;
         }
         if (!string.IsNullOrEmpty(storeEventMoneyOffRule.ConditionValue) && !string.IsNullOrEmpty(storeEventMoneyOffRule.ConditionName))
         {
             BuyGoodsIds  = storeEventMoneyOffRule.ConditionName.Trim().Replace("\n", "").Replace("\r", "").Split(new char[] { '|' }).ToList();
             SendGoodsIds = storeEventMoneyOffRule.ConditionValue.Trim().Replace("\n", "").Replace("\r", "").Split(new char[] { '|' }).ToList();
         }
     }
     catch
     {
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// 根据条码或商品名查找并添加合并到商品列表
        /// </summary>
        /// <param name="goodsCodeOrName">条码</param>
        /// <param name="act">会掉函数</param>
        /// <param name="isSendGoods">是否赠品</param>
        /// <param name="exchangeGoods">换购商品信息</param>
        private void FindAddGoods(string goodsCodeOrName = "", Action act = null, bool isSendGoods = false, GoodsGrantExt exchangeGoods = null)
        {
            if (string.IsNullOrEmpty(goodsCodeOrName))
            {
                return;
            }
            //库存充足
            var entity = GoodsBLL.instance.GetGoodsListByCodeOrName(goodsCodeOrName, UserInfo.Instance.StoreID.ToString());

            if (entity != null)
            {
                if (entity.Count > 1)
                {
                    txtSearchGoods.Properties.Items.Clear();
                    txtSearchGoods.Properties.Items.AddRange(entity.Select(item => item.Name).ToArray());
                    txtSearchGoods.ShowPopup();
                }
                else
                {
                    if (entity[0].StockQuantity <= 0)
                    {
                        XtraMessageBox.Show("商品库存不足!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                    Mapper.Initialize(m => m.CreateMap <GoodsEntity, PosExt>());
                    var mapGoodsExt = Mapper.Map <PosExt>(entity[0]);
                    var realPrice   = 0.0m;
                    if (isSendGoods)
                    {
                        realPrice = 0.0m;
                        mapGoodsExt.PosDiscountPrice = 0.00m;
                        mapGoodsExt.RetailPrice      = 0.00m;
                    }
                    else if (exchangeGoods != null)
                    {
                        //换购价作为折扣销售价格
                        mapGoodsExt.PosDiscountPrice = exchangeGoods.ExchangePrice;
                        realPrice = mapGoodsExt.PosDiscountPrice;
                    }
                    else
                    {
                        //单品折扣
                        GoodsGrantEntity goodsGrant = Marketing.DiscountGoodsItem(mapGoodsExt);
                        realPrice = goodsGrant == null ? 0 : goodsGrant.DiscountPrice;
                        mapGoodsExt.PosDiscountPrice = realPrice > 0 ? realPrice : mapGoodsExt.PosDiscountPrice;
                    }
                    if (PosGoodsList.Count > 0)
                    {
                        //var fitGoods = PosGoodsList.Find(item => item.BarID == mapGoodsExt.BarID&&item.RetailPrice== mapGoodsExt.RetailPrice);
                        var fitGoods = PosGoodsList.Find(item => item.BarID == mapGoodsExt.BarID && item.RetailPrice == mapGoodsExt.RetailPrice && item.PosDiscountPrice == mapGoodsExt.PosDiscountPrice);
                        if (fitGoods != null)
                        {
                            fitGoods.PosSalesCount += 1;
                            fitGoods.PosSalesAmount = fitGoods.PosSalesCount * (realPrice > 0 ? realPrice : mapGoodsExt.RetailPrice);;
                        }
                        else
                        {
                            mapGoodsExt.PosSalesCount  = 1;
                            mapGoodsExt.PosSalesAmount = mapGoodsExt.PosSalesCount * (realPrice > 0 ? realPrice : mapGoodsExt.RetailPrice);
                            PosGoodsList.Add(mapGoodsExt);
                        }
                    }
                    else
                    {
                        //单品折扣价格生效则按照单品折扣价格计算
                        mapGoodsExt.PosSalesCount  = 1;
                        mapGoodsExt.PosSalesAmount = mapGoodsExt.PosSalesCount * (realPrice > 0 ? realPrice : mapGoodsExt.RetailPrice);
                        var existData = grdGoods.DataSource as List <PosExt>;
                        if (existData != null && existData.Any())
                        {
                            PosGoodsList = existData;
                        }
                        PosGoodsList.Add(mapGoodsExt);
                    }
                }
            }
            act?.Invoke();
        }