public OnlineOrdersResultDto <PageInfo <Ppc_StockInfoOutputPageListDto> > GetPageStock(Ppc_StockInfoInputPageListDto input) { OnlineOrdersResultDto <PageInfo <Ppc_StockInfoOutputPageListDto> > res = new OnlineOrdersResultDto <PageInfo <Ppc_StockInfoOutputPageListDto> >() { StatusCode = 0, Message = "获取分页信息失败", Ext1 = new PageInfo <Ppc_StockInfoOutputPageListDto>() }; res = _service.GetPageStock(input); return(res); }
/// <summary> /// /// </summary> /// <returns></returns> public Expression <Func <Ppc_StockInfo, bool> > GetCommonWhere(Expression <Func <Ppc_StockInfo, bool> > where, Ppc_StockInfoInputPageListDto input) { if (!string.IsNullOrWhiteSpace(input.Model)) { where = where.And(m => m.Model == input.Model); } if (!string.IsNullOrWhiteSpace(input.Brand)) { where = where.And(m => m.Brand == input.Brand); } if (input.MinProfitBegin.GetValueOrDefault(0) > 0) { where = where.And(m => m.MinProfit >= input.MinProfitBegin); } if (input.MinProfitEnd.GetValueOrDefault(0) > 0) { where = where.And(m => m.MinProfit <= input.MinProfitEnd); } if (input.ProfitRateBegin.GetValueOrDefault(0) > 0) { decimal?beginrate = input.ProfitRateBegin / 100; where = where.And(m => m.ProfitRate >= beginrate); } if (input.ProfitRateEnd.GetValueOrDefault(0) > 0) { decimal?endrate = input.ProfitRateEnd / 100; where = where.And(m => m.ProfitRate <= endrate); } if (input.NegativeStockType.GetValueOrDefault(0) > 0) { where = where.And(m => m.NegativeStockType == input.NegativeStockType); } if (input.PricePlatCount.GetValueOrDefault(0) > 0) { where = where.And(m => m.PricePlatCount == input.PricePlatCount); } if (input.HeadNegativeStockType.GetValueOrDefault(0) > 0) { where = where.And(m => m.NegativeStockType == 1); } if (input.HeadPricePlatCount.GetValueOrDefault(0) > 0) { where = where.And(m => m.PricePlatCount > 0); } return(where); }
/// <summary> /// 统一设置价格策略 /// </summary> /// <param name="input"></param> /// <returns></returns> public OnlineOrdersResultDto AddPriceConfig(Ppc_PriceConfigInputDto input) { OnlineOrdersResultDto result = new OnlineOrdersResultDto() { StatusCode = 0, Message = "统一设置价格策略失败" }; if (string.IsNullOrWhiteSpace(input.UploadNo)) { result.Message = "比价单号不能为空"; return(result); } var updatetor = _iRepository.FindEntity <Ppc_UploadInfo>(m => m.UploadNO == input.UploadNo); if (updatetor == null) { result.Message = "上传记录未找到"; return(result); } if (updatetor.Status != 0) { result.Message = "物料正在比对中,请等程序运行完成后再设置价格策略"; return(result); } if (input.AdjustType == 1) { //自动调价过滤 if (input.MaxProfitRate.GetValueOrDefault(0) <= 0) { result.Message = "最高毛利率不能为空"; return(result); } if (input.MinProfitRate.GetValueOrDefault(0) <= 0) { result.Message = "最低毛利率不能为空"; return(result); } if (input.PriceRatio.GetValueOrDefault(0) <= 0) { result.Message = "跟价系数不能为空"; return(result); } if (input.PlatformIDArray == null || input.PlatformIDArray.Length == 0) { result.Message = "对标平台必须选择"; return(result); } if (input.IsUnpacking == 1) { if (input.IsPriceLadder == 1) { //不使用对标平台梯度价格 if (input.CustermerCongigList == null || input.CustermerCongigList.Count == 0) { result.Message = "未提交有效的价格梯度"; return(result); } } //可拆包 } else if (input.IsUnpacking == 2) { if (input.CustomerSupplierList == null || input.CustomerSupplierList.Count == 0) { result.Message = "未提交有效的SPQ价格梯度"; return(result); } } } else if (input.AdjustType == 2) { //手动条件过滤 if (input.CurrentProfitRate.GetValueOrDefault(0) < 0) { result.Message = "调整的当前利率不能为空"; return(result); } } if (input.AdjustArange.GetValueOrDefault(0) == 1) { if (input.StockIDArray == null || input.StockIDArray.Length == 0) { result.Message = "未勾选任何有效的物料"; return(result); } _iRepository.UpdateEntity <Ppc_StockInfo>(m => input.StockIDArray.Contains(m.PID), t => new Ppc_StockInfo { Status = 2 }); } else if (input.AdjustArange.GetValueOrDefault(0) == 2) { Ppc_StockInfoInputPageListDto inputwhere = new Ppc_StockInfoInputPageListDto() { UploadNo = input.UploadNo, Model = input.Model, Brand = input.Brand, MinProfitBegin = input.MinProfitBegin, MinProfitEnd = input.MinProfitEnd, ProfitRateBegin = input.ProfitRateBegin, ProfitRateEnd = input.ProfitRateEnd, NegativeStockType = input.NegativeStockType, PricePlatCount = input.PricePlatCount, HeadNegativeStockType = input.HeadNegativeStockType, HeadPricePlatCount = input.HeadPricePlatCount, }; var where = GetCommonWhere(m => 1 == 1, inputwhere); _iRepository.UpdateEntity <Ppc_StockInfo>(where, t => new Ppc_StockInfo { Status = 2 }); } #region 更新上传记录的操作次数,将上传信息更新为待对比 _iRepository.UpdateEntity <Ppc_UploadInfo>(m => m.UploadNO == input.UploadNo, t => new Ppc_UploadInfo { Status = 1 }); #endregion #region 存在未删除的价格配置数据,就把它置为删除 var configExs = _iRepository.FindEntity <Ppc_PriceConfig>(m => m.UploadNo == input.UploadNo && m.IsDelete == 1); if (configExs != null && configExs.ID.GetValueOrDefault(0) > 0) { _iRepository.UpdateEntity <Ppc_PriceConfig>(m => m.UploadNo == input.UploadNo && m.IsDelete == 1, t => new Ppc_PriceConfig { IsDelete = 0 }); } #endregion List <Ppc_PlatformPriceConfig> itemList = new List <Ppc_PlatformPriceConfig>(); Ppc_PriceConfig config = new Ppc_PriceConfig(); config.UploadNo = input.UploadNo; if (input.AdjustType == 1) { config.AdjustType = 1; config.MaxProfitRate = input.MaxProfitRate / 100; config.MinProfitRate = input.MinProfitRate / 100; config.PriceRatio = input.PriceRatio; #region 获取所有的对标平台信息 List <Ppc_PlatformConfig> platList = _iRepository.GetEntitiesListByConditions <Ppc_PlatformConfig>(m => input.PlatformIDArray.Contains(m.ID), null); if (platList == null || platList.Count == 0) { result.Message = "平台信息未找到"; return(result); } #endregion config.ComparePlatform = string.Join(",", platList.Select(m => m.PlatformType).Distinct().ToArray()); config.IsUnpacking = input.IsUnpacking; if (input.IsUnpacking == 1) { //自动调价 if (input.IsPriceLadder == 0) { //使用对标平台价格策略 config.IsPriceLadder = 1; } else if (input.IsPriceLadder == 1) { config.IsPriceLadder = 0; foreach (var item in input.CustermerCongigList) { Ppc_PlatformPriceConfig model = new Ppc_PlatformPriceConfig(); model.MaxVal = item.Qty; model.ProfitRate = item.ProfitRate / 100M; itemList.Add(model); } } } else if (input.IsUnpacking == 2) { //写入ppc_platformpriceconfig foreach (var item in input.CustomerSupplierList) { Ppc_PlatformPriceConfig model = new Ppc_PlatformPriceConfig(); model.MaxVal = item.Qty; model.ProfitRate = item.ProfitRate / 100M; itemList.Add(model); } } } else if (input.AdjustType == 2) { //手动条件 config.AdjustType = 2; config.ChangeProfitRate = input.CurrentProfitRate / 100M; } var rowCount = _iRepository.InsertIdentity <Ppc_PriceConfig>(config); if (rowCount > 0) { if (itemList != null && itemList.Count > 0) { itemList.ForEach(m => { m.PriceConfigID = rowCount; }); var ccCount = _iRepository.InsertEntityList <Ppc_PlatformPriceConfig>(itemList); if (ccCount < 0) { result.Message = "平台价格配置写入失败"; return(result); } } result.StatusCode = 1; result.Message = "设置价格策略成功"; } else { result.Message = "价格策略设置失败"; } return(result); }
/// <summary> /// 根据比价单号获取物料上传信息的详情 /// </summary> /// <param name="input"></param> /// <returns></returns> public OnlineOrdersResultDto <PageInfo <Ppc_StockInfoOutputPageListDto> > GetPageStock(Ppc_StockInfoInputPageListDto input) { OnlineOrdersResultDto <PageInfo <Ppc_StockInfoOutputPageListDto> > result = new OnlineOrdersResultDto <PageInfo <Ppc_StockInfoOutputPageListDto> >() { StatusCode = 0, Message = "获取信息失败", Ext1 = new PageInfo <Ppc_StockInfoOutputPageListDto>() }; if (string.IsNullOrWhiteSpace(input.UploadNo)) { result.Message = "上传比价单号不能为空"; return(result); } var updatetor = _iRepository.FindEntity <Ppc_UploadInfo>(m => m.UploadNO == input.UploadNo); if (updatetor == null) { result.Message = "上传记录未找到"; return(result); } if (updatetor.Status != 0) { result.StatusCode = 1; result.Message = "物料正在比对中"; return(result); } Expression <Func <Ppc_StockInfo, bool> > where = m => m.UploadNo == input.UploadNo; where = GetCommonWhere(where, input); var selector = ExpExtension.GetSelector <Ppc_StockInfo, Ppc_StockInfoOutputPageListDto>(); var pageEntity = _iRepository.GetConditionPageList <Ppc_StockInfo, Ppc_StockInfoOutputPageListDto>(where, input.PageIndex, input.PageSize, null, selector); var resultList = pageEntity.GetCommonPageEntityies <Ppc_StockInfoOutputPageListDto>(); if (resultList != null && resultList.ResultList != null && resultList.ResultList.Count > 0) { var list = GetExtendPropertities(resultList.ResultList); resultList.ResultList = list; } return(result); }