Example #1
0
        public OnlineOrdersResultDto AddPriceConfig(Ppc_PriceConfigInputDto input)
        {
            OnlineOrdersResultDto res = new OnlineOrdersResultDto()
            {
                StatusCode = 0,
                Message    = "统一定价配置失败"
            };

            res = _service.AddPriceConfig(input);
            return(res);
        }
Example #2
0
        public OnlineOrdersResultDto <string> ExportStock(Ppc_PriceConfigInputDto input)
        {
            OnlineOrdersResultDto <string> res = new OnlineOrdersResultDto <string>()
            {
                StatusCode = 0,
                Message    = "excel导出失败",
            };
            var updatetor = _iRepository.FindEntity <Ppc_UploadInfo>(m => m.UploadNO == input.UploadNo);

            if (updatetor == null)
            {
                res.Message = "上传记录未找到";
                return(res);
            }
            if (updatetor.Status != 0)
            {
                res.Message = "物料正在比对中,请等程序运行完成后再导出上传的库存";
                return(res);
            }
            res.StatusCode = 1;
            res.Message    = "excel导出进行中";
            res.Ext1       = "/Export/ExportStockUpload?UploadNo=" + input.UploadNo;
            return(res);
        }
Example #3
0
        /// <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);
        }