Example #1
0
        public CustomBarcode(string storeId, string machineSn, int companyId, string barcodeString, SaleStatus saleStatus = SaleStatus.Normal, string marketingRuleId = "")
        {
            BarcodeType = Barcodes.BarcodeType.CustomBarcode;

            RecordId = Guid.NewGuid().ToString();
            //处理条码字符串的空格及移除所有前导空白字符和尾部空白字符
            if (string.IsNullOrWhiteSpace(barcodeString))
            {
                throw new BarcodeException("条码不能为空!");
            }
            var dataAdapter = DataAdapterFactory.Factory(MachinesSettings.Mode, storeId, machineSn, companyId, DataAdapterFactory.DEFUALT);

            CurrentString = barcodeString;
            Count         = CurrentString.Length;
            if (dataAdapter == null)
            {
                throw new Exception("数据适配器不能为null,请实现IDataAdapter,并实例化!");
            }
            var productInfo = dataAdapter.GetProductInfoByBarcode(CurrentString);

            if (productInfo == null)
            {
                throw new SaleException("602", "未找到商品信息,请确认商品是否已经入库销售!");
            }
            if (productInfo.ProductType == ProductType.Weigh)
            {
                throw new PosException("604", "散称商品请过称!", productInfo);
            }
            MultiCode   = productInfo.MultiCode;
            MainBarcode = productInfo.MainBarcode;
            ProductType = productInfo.ProductType;
            SaleNumber  = 1;
            ProductCode = productInfo.ProductCode;
            SalePrice   = productInfo.SystemPrice;
            Details     = new ProductDetails()
            {
                Brand           = productInfo.Brand,
                Category        = productInfo.Category,
                EnableEditNum   = productInfo.EnableEditNum,
                EnableEditPrice = productInfo.EnableEditPrice,
                //  GiftId = giftId,
                MarketingRuleId = marketingRuleId,
                SaleStatus      = saleStatus,
                Size            = productInfo.Size,
                SystemPrice     = productInfo.SystemPrice,
                Title           = productInfo.Title,
                Unit            = productInfo.Unit,
                Total           = SalePrice * SaleNumber,
                BuyPrice        = productInfo.BuyPrice
            };
            IsMultiCode = MultiCode.Contains(CurrentString);
        }
Example #2
0
 public bool VerfyEnableCombine(string barcode, SaleStatus status, bool hasEditPrice = false, string recordId = "")
 {
     if (this == null)
     {
         return(false);
     }
     if (string.IsNullOrEmpty(CurrentString) || string.IsNullOrEmpty(barcode) || Details == null)
     {
         return(false);
     }
     if (SameProduct(barcode) && Details.SaleStatus == status && (recordId == RecordId || (string.IsNullOrEmpty(recordId) && !HasEditPrice)))
     {
         if (MultiCode.Contains(barcode))
         {
             IsMultiCode = true;
         }
         return(true);
     }
     return(false);
 }
Example #3
0
 public bool VerfyEnableCombine(string barcode, SaleStatus status, string giftId, string giftPromotionId)
 {
     if (this == null)
     {
         return(false);
     }
     if (string.IsNullOrEmpty(CurrentString) || string.IsNullOrEmpty(barcode) || Details == null)
     {
         return(false);
     }
     if ((CurrentString == barcode || MainBarcode == barcode || MultiCode.Contains(barcode)) && Details.SaleStatus == status && Details.MarketingRuleId == giftPromotionId)
     {
         if (MultiCode.Contains(barcode))
         {
             IsMultiCode = true;
         }
         return(true);
     }
     return(false);
 }
Example #4
0
 public bool SameProduct(string barcode)
 {
     return(CurrentString == barcode || MainBarcode == barcode || MultiCode.Contains(barcode));
 }