public override bool UpLoad(IEnumerable <SaleDetail> datas, string storeId) { //删除重复数据 { if (datas == null) { return(false); } var paySNs = CurrentRepository.Entities.Select(o => o.PaySN).Distinct().ToList(); datas = datas.Where(o => !paySNs.Exists(p => p == o.PaySN)); } //更新库存 { foreach (var item in datas) { var orders = JsonConvert.DeserializeObject <IEnumerable <SaleOrders> >(JsonConvert.SerializeObject(UpdateFormDatas.Datas["Pharos.Logic.LocalEntity.SaleOrders"])); var order = orders.FirstOrDefault(o => o.PaySN == item.PaySN); if (order == null) { return(false); } //更新捆绑商品库存 if (BundlingService.IsExist(o => o.NewBarcode == item.Barcode)) { var query = (from a in BundlingService.CurrentRepository.Entities from b in BundlingListService.CurrentRepository.Entities where a.CommodityId == b.CommodityId && a.NewBarcode == item.Barcode select b); var items = query.ToList(); foreach (var i in items) { if (!UpdateProduct(item.PurchaseNumber, i.Barcode, storeId, item.PaySN, item.Barcode, order.CreateUID)) { return(false); } } } else//更新产品档案库存 { if (!UpdateProduct(item.PurchaseNumber, item.Barcode, storeId, item.PaySN, item.Barcode, order.CreateUID)) { return(false); } } } } //更新销售清单 { var serverRepository = CurrentRepository; var tempDatas = datas.Select(o => Pharos.Logic.Entity.BaseEntityExtension.InitEntity <SaleDetail>(o)); serverRepository.AddRange(tempDatas.ToList()); } return(true); }
public DataGridPagingResult <IEnumerable <ProductDto> > GetProducts(ProductRequestDto theParams) { var result = ProductService.GetProducts(theParams.KeyWord, theParams.Store, theParams.ProductBrand, theParams.Categories); if (theParams.Categories.Contains(-10)) { var bundlingResult = BundlingService.GetBundings(theParams.Store, theParams.KeyWord, theParams.ProductBrand); if (bundlingResult != null && bundlingResult.Count() > 0) { result = result.Concat(bundlingResult); } } return(new DataGridPagingResult <IEnumerable <ProductDto> >() { Result = result.Skip((theParams.PageIndex - 1) * theParams.PageSize).Take(theParams.PageSize), Total = result.Count() }); }
public override bool UpLoad(IEnumerable <SaleOrders> datas, string storeId) { try { var serverRepository = CurrentRepository; if (datas == null) { return(false); } var paySNs = CurrentRepository.Entities.ToDictionary(o => o.PaySN, o => o.State).ToList(); //整单退出记录 var removeDatas = datas.Where(o => o.State == 1 && paySNs.Exists(p => p.Key == o.PaySN && p.Value != 1)).ToList(); foreach (var item in removeDatas) { var order = SaleOrdersDataSyncService.CurrentRepository.Find(o => o.PaySN == item.PaySN); order.ReturnId = item.ReturnId; order.State = item.State; SaleOrdersDataSyncService.Update(order); var ReturnsDetails = JsonConvert.DeserializeObject <IEnumerable <SalesReturnsDetailed> >(JsonConvert.SerializeObject(UpdateFormDatas.Datas["Pharos.Logic.LocalEntity.SalesReturnsDetailed"])); var details = ReturnsDetails.Where(o => o.ReturnId == item.ReturnId); //var details = SaleDetailDataSyncService.CurrentRepository.Entities.Where(o => o.PaySN == item.PaySN).ToList(); foreach (var i in details) { if (BundlingService.IsExist(o => o.NewBarcode == i.Barcode)) { var query = (from a in BundlingService.CurrentRepository.Entities from b in BundlingListService.CurrentRepository.Entities where a.CommodityId == b.CommodityId && a.NewBarcode == i.Barcode select b); var items = query.ToList(); foreach (var p in items) { var info = ProductRecordDataSyncService.CurrentRepository.Entities.FirstOrDefault(o => o.Barcode == p.Barcode); UpdateProduct(p.Barcode, i.Number * p.Number, item.PaySN, i.Barcode, storeId, order.CreateUID); } } else { UpdateProduct(i.Barcode, i.Number, item.PaySN, i.Barcode, storeId, order.CreateUID); } } } //删除重复数据 datas = datas.Where(o => !paySNs.Exists(p => p.Key == o.PaySN)); var tempDatas = datas.Select(o => Pharos.Logic.Entity.BaseEntityExtension.InitEntity <SaleOrders>(o)); serverRepository.AddRange(tempDatas.ToList()); return(true); } catch { return(false); } }
public ProductInfo GetProductInfoFromBundlingByBarcode(string barcode) { return(BundlingService.GetProductInfoFromBundlingByBarcode(StoreId, barcode, CompanyId)); }
public ActionResult Delete(string[] ids) { var re = BundlingService.DeleteById(ids); return(new JsonNetResult(re)); }