/// <summary> /// 获取统计数据 /// </summary> /// <returns></returns> public System.Collections.Generic.List <Jinher.AMP.BTP.Deploy.CustomDTO.totalNum> GetTotalListExt(Jinher.AMP.BTP.Deploy.CustomDTO.CommodityChangeDTO Search) { LogHelper.Debug("CommodityChangeBP.GetTotalListExt,入参:" + JsonHelper.JsonSerializer(Search)); try { var query = from m in Commodity.ObjectSet() join n in CommodityStock.ObjectSet() on m.Id equals n.CommodityId into CommodityList from com in CommodityList.DefaultIfEmpty() where Search.Appids.Contains(m.AppId) select new Jinher.AMP.BTP.Deploy.CustomDTO.CommodityChangeDTO { Id = com.Id, CommodityId = com.CommodityId, AppId = m.AppId, Barcode = com.Barcode, No_Code = com.No_Code, JDCode = com.JDCode, //备注编码 Name = m.Name, SubId = m.SubId, SubOn = com.SubTime, ModifiedId = m.ModifieId, ModifiedOn = com.ModifiedOn, State = m.State, IsDel = m.IsDel }; #region 查询条件 //根据供应商 if (Search.AppidsList.Count > 0) { query = query.Where(p => Search.AppidsList.Contains(p.AppId)); } //商铺名称 if (Search.AppId != Guid.Empty) { query = query.Where(p => p.AppId == Search.AppId); } //商品名称 if (!string.IsNullOrEmpty(Search.Name)) { query = query.Where(p => Search.Name.Contains(p.Name) || p.Name.Contains(Search.Name)); } //备注编码 if (!string.IsNullOrEmpty(Search.JDCode)) { query = query.Where(p => p.JDCode == Search.JDCode); } //商品条形码 if (!string.IsNullOrEmpty(Search.Barcode)) { query = query.Where(p => p.Barcode == Search.Barcode); } //发布人 if (Search.SubId != Guid.Empty) { query = query.Where(p => p.SubId == Search.SubId); } if (!string.IsNullOrEmpty(Search.SubStarTime)) { var StartTime = System.Data.SqlTypes.SqlDateTime.MinValue.Value; StartTime = DateTime.Parse(Search.SubStarTime); query = query.Where(p => p.SubOn >= StartTime); } if (!string.IsNullOrEmpty(Search.SubEndTime)) { var EndTime = System.Data.SqlTypes.SqlDateTime.MinValue.Value; EndTime = DateTime.Parse(Search.SubEndTime).AddDays(1); query = query.Where(p => p.SubOn <= EndTime); } if (Search.ModifiedId != Guid.Empty) { query = query.Where(p => p.ModifiedId == Search.ModifiedId); } if (!string.IsNullOrEmpty(Search.ModStarTime)) { var StartTime = System.Data.SqlTypes.SqlDateTime.MinValue.Value; StartTime = DateTime.Parse(Search.ModStarTime); query = query.Where(p => p.ModifiedOn >= StartTime); } if (!string.IsNullOrEmpty(Search.ModEndTime)) { var EndTime = System.Data.SqlTypes.SqlDateTime.MinValue.Value; EndTime = DateTime.Parse(Search.ModEndTime).AddDays(1); query = query.Where(p => p.ModifiedOn <= EndTime); } if (Search.State != -1) { if (Search.State == 3) { //已删除的数据 query = query.Where(p => p.IsDel == true); } else { query = query.Where(p => p.State == Search.State && p.IsDel == false); } } #endregion totalNum num = new totalNum(); num.totalGoods = query.Count(); num.selling = query.Where(p => p.State == 0 && p.IsDel == false).Count(); num.soldout = query.Where(p => p.State == 1 && p.IsDel == false).Count(); num.isdel = query.Where(p => p.IsDel == true).Count(); List <totalNum> list = new List <totalNum>(); list.Add(num); return(list); } catch (Exception ex) { LogHelper.Error("CommodityChangeBP.GetTotalListExt异常", ex); } return(new List <totalNum>()); }
/// <summary> /// 获取商品信息变更信息 /// </summary> /// <param name="Search"></param> /// <returns></returns> public System.Collections.Generic.List <Jinher.AMP.BTP.Deploy.CustomDTO.CommodityChangeDTO> GetCommodityChangeList(Jinher.AMP.BTP.Deploy.CustomDTO.CommodityChangeDTO Search) { try { var query = CommodityChange.ObjectSet().Where(p => Search.Appids.Contains(p.AppId)).AsQueryable(); #region 查询条件 //根据供应商 if (Search.AppidsList.Count > 0) { query = query.Where(p => Search.AppidsList.Contains(p.AppId)); } //商铺名称 if (Search.AppId != Guid.Empty) { query = query.Where(p => p.AppId == Search.AppId); } //商品名称 if (!string.IsNullOrEmpty(Search.Name)) { query = query.Where(p => Search.Name.Contains(p.Name) || p.Name.Contains(Search.Name)); } //备注编码 if (!string.IsNullOrEmpty(Search.JDCode)) { query = query.Where(p => p.JDCode == Search.JDCode); } //商品条形码 if (!string.IsNullOrEmpty(Search.Barcode)) { query = query.Where(p => p.Barcode == Search.Barcode); } //发布人 if (Search.SubId != Guid.Empty) { query = query.Where(p => p.SubId == Search.SubId); } if (!string.IsNullOrEmpty(Search.SubStarTime)) { var StartTime = System.Data.SqlTypes.SqlDateTime.MinValue.Value; StartTime = DateTime.Parse(Search.SubStarTime); query = query.Where(p => p.SubOn >= StartTime); } if (!string.IsNullOrEmpty(Search.SubEndTime)) { var EndTime = System.Data.SqlTypes.SqlDateTime.MinValue.Value; EndTime = DateTime.Parse(Search.SubEndTime).AddDays(1); query = query.Where(p => p.SubOn <= EndTime); } if (Search.ModifiedId != Guid.Empty) { query = query.Where(p => p.ModifiedId == Search.ModifiedId); } if (!string.IsNullOrEmpty(Search.ModStarTime)) { var StartTime = System.Data.SqlTypes.SqlDateTime.MinValue.Value; StartTime = DateTime.Parse(Search.ModStarTime); query = query.Where(p => p.ModifiedOn >= StartTime); } if (!string.IsNullOrEmpty(Search.ModEndTime)) { var EndTime = System.Data.SqlTypes.SqlDateTime.MinValue.Value; EndTime = DateTime.Parse(Search.ModEndTime).AddDays(1); query = query.Where(p => p.ModifiedOn <= EndTime); } if (Search.State != -1) { if (Search.State == 3) { //已删除的数据 query = query.Where(p => p.IsDel == true); } else { query = query.Where(p => p.State == Search.State && p.IsDel == false); } } #endregion List <Jinher.AMP.BTP.Deploy.CustomDTO.CommodityChangeDTO> result = (from n in query select new Jinher.AMP.BTP.Deploy.CustomDTO.CommodityChangeDTO { Id = n.Id, CommodityId = n.CommodityId, AppId = n.AppId, Barcode = n.Barcode, Type = n.Type, YJCouponActivityId = n.YJCouponActivityId, YJCouponType = n.YJCouponType, No_Code = n.No_Code, JDCode = n.JDCode, //备注编码 Name = n.Name, MarketPrice = n.MarketPrice, Price = n.Price, CostPrice = n.CostPrice, TaxClassCode = n.TaxClassCode, InputRax = n.InputRax, TaxRate = n.TaxRate, ComAttribute = n.ComAttribute, Unit = n.Unit, SubId = n.SubId, SubOn = n.SubOn, ModifiedId = n.ModifiedId, ModifiedOn = n.ModifiedOn, State = n.State, IsDel = n.IsDel }).OrderByDescending(p => p.ModifiedOn).ToList(); if (result.Count() > 0) { if (result.Count() > 0) { //获取商铺名称 List <Guid> appIds = (from it in result select it.AppId).Distinct().ToList(); Dictionary <Guid, string> listApps = APPSV.GetAppNameListByIds(appIds); //获取商铺名称 //获取供应商名称 var SupplierList = Supplier.ObjectSet().Where(p => appIds.Contains(p.AppId)).Select(s => new { s.AppId, s.SupplierName }).Distinct().ToList(); //获取提交人名称 List <Guid> SubId = (from n in query where n.SubId != null select n.SubId).Distinct().ToList(); List <Guid> ModId = (from n in query where n.ModifiedId != null select n.ModifiedId).Distinct().ToList(); List <Guid> userid = SubId.Union(ModId).Distinct().ToList(); var Userinfo = CBCSV.GetUserNameAndCodes(userid); foreach (var item in result) { //获取提交人名称 var NameAndCodes = Userinfo[item.SubId]; item.SubName = NameAndCodes.Item1; item.SubCode = NameAndCodes.Item2; //获取供应商名称 var SupplierName = SupplierList.Where(p => p.AppId == item.AppId).Select(s => s.SupplierName).FirstOrDefault(); if (!string.IsNullOrEmpty(SupplierName)) { item.SupplierName = SupplierName; } //获取商铺名称 if (listApps.ContainsKey(item.AppId)) { var listAppName = listApps[item.AppId]; if (!String.IsNullOrEmpty(listAppName)) { item.AppName = listAppName; } } //获取修改人名称 if (item.ModifiedId != new Guid("72EF9DC4-2615-4649-92A9-9A4C71D1AFF9") && item.ModifiedId != null) { Guid MId = item.ModifiedId ?? new Guid("00000000-0000-0000-0000-000000000000"); NameAndCodes = Userinfo[MId]; item.ModifiedName = NameAndCodes.Item1; item.ModifiedCode = NameAndCodes.Item2; } else if (item.ModifiedId == new Guid("72EF9DC4-2615-4649-92A9-9A4C71D1AFF9")) { item.ModifiedName = "系统自动"; item.ModifiedCode = "京东同步"; } else { item.ModifiedName = ""; item.ModifiedCode = ""; } //格式化状态 if (!item.IsDel) { if (item.State == 0) { item.StateName = "在售中"; } else { item.StateName = "已下架"; } } else { item.StateName = "已删除"; } } } } return(result); } catch (Exception ex) { Jinher.JAP.Common.Loging.LogHelper.Error(string.Format("根据搜索条件获取变动商品表异常。"), ex); return(null); } }
/// <summary> /// 导出商品信息变更信息 /// </summary> /// <param name="Search"></param> /// <returns></returns> public System.Collections.Generic.List <Jinher.AMP.BTP.Deploy.CustomDTO.CommodityChangeDTO> GetCommodityChangeExportExt(Jinher.AMP.BTP.Deploy.CustomDTO.CommodityChangeDTO Search) { try { List <Jinher.AMP.BTP.Deploy.CustomDTO.CommodityChangeDTO> result = GetCommodityChangeList(Search); return(result); } catch (Exception ex) { Jinher.JAP.Common.Loging.LogHelper.Error(string.Format("根据搜索条件获取变动商品表异常。"), ex); return(null); } }