public static IEnumerable <dynamic> GetOrderApproveNewList(string userCode) { if (userCode.IsNullOrEmpty()) { throw new MessageException("员工编号为空!"); } var user = UserInfoService.Find(o => o.CompanyId == Sys.SysCommonRules.CompanyId && o.UserCode == userCode); if (user == null) { throw new MessageException("用户不存在!"); } var query = from x in BaseService <VwOrder> .CurrentRepository.QueryEntity let o = from y in BaseService <Reader> .CurrentRepository.QueryEntity where x.Id == y.MainId && y.Type == 2 && y.ReadCode == user.UID select y orderby x.CreateDT descending where x.State == 0 && !o.Any() select x; var list = query.ToList(); var orders = list.Select(o => new { o.StoreTitle, o.OrderTotal, OrderId = o.IndentOrderId, o.IndentNums, Time = o.CreateDT.ToString("yyyy-MM-dd HH:mm") }).ToList(); return(orders); }
public static void ReSaveStock(string storeId, string checkBatch, string checkUID, string barcode, decimal?number, short sure) { if (string.IsNullOrWhiteSpace(storeId)) { throw new MessageException("门店号为空!"); } if (string.IsNullOrWhiteSpace(checkBatch)) { throw new MessageException("盘点批次为空!"); } if (string.IsNullOrWhiteSpace(checkUID)) { throw new MessageException("盘点员为空!"); } if (string.IsNullOrWhiteSpace(barcode)) { throw new MessageException("条码为空!"); } if (!number.HasValue) { throw new MessageException("实盘数量为空!"); } var query = from a in BaseService <StockTaking> .CurrentRepository.QueryEntity join b in BaseService <TreasuryLocks> .CurrentRepository.QueryEntity on new { a.CheckBatch, a.CompanyId } equals new { b.CheckBatch, b.CompanyId } where a.CompanyId == Sys.SysCommonRules.CompanyId && b.LockStoreID == storeId && a.CheckBatch == checkBatch && a.Barcode == barcode select new { a, a.Barcode, a.ActualNumber, a.CheckBatch, b.State, a.CompanyId, SysPrice = ProductService.CurrentRepository.QueryEntity.Where(o => o.CompanyId == a.CompanyId && (o.Barcode == a.Barcode || ("," + o.Barcodes + ",").Contains("," + a.Barcode + ","))).Select(o => o.SysPrice).FirstOrDefault() }; var stock = query.FirstOrDefault(); if (stock == null) { throw new MessageException("批次或条码不存在!"); } if (stock.State == 1) { throw new MessageException("该批次已通过审核,不能再盘点!"); } var user = UserInfoService.Find(o => o.CompanyId == Sys.SysCommonRules.CompanyId && o.UserCode == checkUID); if (user == null) { throw new MessageException("用户编码不存在!"); } stock.a.Sure = (short)(sure == 0?0:1); //var st= BaseService<StockTaking>.Find(o => o.CompanyId == stock.CompanyId && o.CheckBatch == stock.CheckBatch && o.Barcode == stock.Barcode); var log = new StockTakingLog() { Barcode = stock.Barcode, CheckBatch = stock.CheckBatch, CheckUID = user.UID, CreateUID = user.UID, CreateDT = DateTime.Now, ActualDate = DateTime.Now, SysPrice = stock.SysPrice, Number = number.GetValueOrDefault(), State = 1, Source = 2, CompanyId = Sys.SysCommonRules.CompanyId }; BaseService <StockTakingLog> .Add(log); }
public static object GetOrderDetail(string orderId, string userCode, short type) { if (string.IsNullOrWhiteSpace(orderId)) { throw new MessageException("订单号为空!"); } if (string.IsNullOrWhiteSpace(userCode)) { throw new MessageException("用户编号为空!"); } var query = from a in BaseService <VwOrder> .CurrentRepository.QueryEntity join b in BaseService <IndentOrderList> .CurrentRepository.QueryEntity on a.IndentOrderId equals b.IndentOrderId join c in BaseService <VwProduct> .CurrentRepository.QueryEntity on new { a.CompanyId, b.Barcode } equals new { c.CompanyId, c.Barcode } where a.CompanyId == Sys.SysCommonRules.CompanyId && a.IndentOrderId == orderId select new { a, c.ProductCode, c.Barcode, c.Title, SysPrice = b.SysPrice ?? c.SysPrice, c.SubUnit, b.IndentNum, b.DeliveryNum, b.Subtotal, b.Nature }; var list = query.ToList(); if (!list.Any()) { return(null); } var order = list.Select(o => o.a).FirstOrDefault(); var details = list.Where(o => o.Nature == 0).Select(o => new Detail() { ProductCode = o.ProductCode, Barcode = o.Barcode, Title = o.Title, IndentNum = o.IndentNum, DeliveryNum = o.DeliveryNum, SysPrice = o.SysPrice, SubUnit = o.SubUnit, Subtotal = o.Subtotal, Nature = "" }).ToList(); foreach (var gift in list.Where(o => o.Nature == 1)) { var gt = details.FirstOrDefault(o => o.Barcode == gift.Barcode && o.Nature == "赠品"); if (gt == null) { details.Add(new Detail() { ProductCode = gift.ProductCode, Barcode = gift.Barcode, Title = gift.Title, IndentNum = gift.IndentNum, DeliveryNum = gift.DeliveryNum, SysPrice = gift.SysPrice, SubUnit = gift.SubUnit, Subtotal = gift.Subtotal, Nature = "赠品" }); } else { gt.IndentNum += gift.IndentNum; gt.Subtotal += gift.Subtotal; } } var obj = new { OrderId = order.IndentOrderId, order.StoreTitle, order.RecipientsTitle, order.SupplierTitle, order.OrderTotal, order.ShippingAddress, order.DeliveryDate, StateTitle = GetStateTitle(order.State, type), Details = details }; var user = UserInfoService.Find(o => o.CompanyId == Sys.SysCommonRules.CompanyId && o.UserCode == userCode); if (user == null) { throw new MessageException("用户编码不存在!"); } ReaderService.Add(type, user.UID, new List <int>() { order.Id }); return(obj); }
public static void SaveStock(string storeId, string checkBatch, string checkUID, Dictionary <string, decimal?> barnums) { if (string.IsNullOrWhiteSpace(storeId)) { throw new MessageException("门店号为空!"); } if (string.IsNullOrWhiteSpace(checkBatch)) { throw new MessageException("盘点批次为空!"); } if (string.IsNullOrWhiteSpace(checkUID)) { throw new MessageException("盘点员为空!"); } if (!barnums.Any()) { throw new MessageException("盘点内容为空!"); } var barcodes = barnums.Keys.ToList(); var query = from a in BaseService <StockTaking> .CurrentRepository.QueryEntity join b in BaseService <TreasuryLocks> .CurrentRepository.QueryEntity on new { a.CheckBatch, a.CompanyId } equals new { b.CheckBatch, b.CompanyId } where a.CompanyId == Sys.SysCommonRules.CompanyId && b.LockStoreID == storeId && a.CheckBatch == checkBatch && barcodes.Contains(a.Barcode) select new { a.Barcode, a.ActualNumber, a.CheckBatch, b.State, SysPrice = ProductService.CurrentRepository.QueryEntity.Where(o => o.CompanyId == a.CompanyId && (o.Barcode == a.Barcode || ("," + o.Barcodes + ",").Contains("," + a.Barcode + ","))).Select(o => o.SysPrice).FirstOrDefault() }; var stocks = query.ToList(); if (!stocks.Any()) { throw new MessageException("批次或条码不存在!"); } if (stocks.Any(o => o.State == 1)) { throw new MessageException("该批次已通过审核,不能再盘点!"); } var user = UserInfoService.Find(o => o.CompanyId == Sys.SysCommonRules.CompanyId && o.UserCode == checkUID); if (user == null) { throw new MessageException("用户编码不存在!"); } var stocklogs = BaseService <StockTakingLog> .FindList(o => o.CompanyId == Sys.SysCommonRules.CompanyId && barcodes.Contains(o.Barcode) && o.CheckBatch == checkBatch && o.State == 1); var insertLog = new List <StockTakingLog>(); var date = DateTime.Now; foreach (var de in barnums) { var sk = stocks.FirstOrDefault(o => o.Barcode == de.Key); if (sk == null) { throw new MessageException("条码[" + de.Key + "]不存在!"); } if (stocklogs.Any(o => o.Barcode == de.Key)) { throw new MessageException("条码[" + de.Key + "]条码已复盘!"); } if (!de.Value.HasValue) { continue; } insertLog.Add(new StockTakingLog() { Barcode = sk.Barcode, CheckBatch = sk.CheckBatch, CheckUID = user.UID, CreateDT = date, CreateUID = user.UID, ActualDate = date, Number = de.Value.Value, SysPrice = sk.SysPrice, Source = 2, CompanyId = Sys.SysCommonRules.CompanyId }); } if (insertLog.Any()) { BaseService <StockTakingLog> .AddRange(insertLog); } }