// 获取最低报价 public LadderLowestPrice GetLowestPrice(string price) { LadderLowestPrice model = new LadderLowestPrice(); if (!string.IsNullOrEmpty(price)) { string[] arrGroup = price.Split('^'); string[] arrItem; if (arrGroup.Length > 0) { arrItem = arrGroup[0].Split('&'); model.ProductId = arrItem[0]; if (!string.IsNullOrEmpty(arrItem[1])) { model.LowestPrice = Convert.ToDecimal(arrItem[1]); } if (!string.IsNullOrEmpty(arrItem[2])) { model.AddPrice = Convert.ToDecimal(arrItem[2]); } if (!string.IsNullOrEmpty(arrItem[3])) { model.SupplierId = Convert.ToInt32(arrItem[3]); } model.CreateTime = DateTime.Now; model.CreateUserID = LoginInfo.UserID; model.CreateUserName = LoginInfo.RealName; model.BranchID = LoginInfo.BranchID; model.Status = Common.Status.启用.ToString(); } } return(model); }
/// <summary> /// 启用 /// </summary> /// <param name="id"></param> /// <returns></returns> public Common.ClientResult.Result Start(string id) { Common.ClientResult.Result result = new Common.ClientResult.Result(); if (ModelState.IsValid) { //数据校验 LadderPrice item = m_BLL.GetById(id); IBLL.ILadderLowestPriceBLL bll = new BLL.LadderLowestPriceBLL(); LadderLowestPrice chk = bll.GetById(item.LadderLowestPriceId); if (chk.Status == Common.Status.停用.ToString()) { result.Code = Common.ClientCode.Fail; result.Message = "该阶梯价格的最低价格处于停用状态!"; return(result); } if (!m_BLL.CheckRange(item.LadderLowestPriceId, Convert.ToInt32(item.BeginLadder), Convert.ToInt32(item.EndLadder), item.Id)) { LogClassModels.WriteServiceLog(Suggestion.UpdateFail + ",阶梯报价信息的Id为" + id, "阶梯报价信息_启用" );//写入日志 result.Code = Common.ClientCode.Fail; result.Message = "请检查阶梯报价范围!"; return(result); //提示更新失败 } item.Status = Common.Status.启用.ToString();//启用 string returnValue = string.Empty; if (m_BLL.Edit(ref validationErrors, item)) { LogClassModels.WriteServiceLog(Suggestion.UpdateSucceed + ",阶梯报价信息的Id为" + id, "阶梯报价信息_启用" );//写入日志 result.Code = Common.ClientCode.Succeed; result.Message = Suggestion.UpdateSucceed; return(result); //提示更新成功 } else { if (validationErrors != null && validationErrors.Count > 0) { validationErrors.All(a => { returnValue += a.ErrorMessage; return(true); }); } LogClassModels.WriteServiceLog(Suggestion.UpdateFail + ",阶梯报价信息的Id为" + id + "," + returnValue, "阶梯报价信息_启用" );//写入日志 result.Code = Common.ClientCode.Fail; result.Message = Suggestion.UpdateFail + returnValue; return(result); //提示更新失败 } } result.Code = Common.ClientCode.FindNull; result.Message = Suggestion.UpdateFail + "请核对输入的数据的格式"; return(result); //提示输入的数据的格式不对 }
public Common.ClientResult.Result PostPrice([FromBody] SupplierInfo entity) { Common.ClientResult.Result result = new Common.ClientResult.Result(); if (entity != null && ModelState.IsValid) { //entity.CRM_Company_ID = entity.CRM_Company_Audit_ID; //最低报价 LadderLowestPrice LowestPrice = new LadderLowestPrice(); string price = entity.Price; if (!string.IsNullOrEmpty(price)) { LowestPrice = GetLowestPrice(price); LowestPrice.Id = Common.Result.GetNewId(); } //阶梯报价 List <LadderPrice> listLadderPrice = new List <LadderPrice>(); string ladderPrice = entity.LadderPrice; if (!string.IsNullOrEmpty(ladderPrice)) { listLadderPrice = GetLadderPriceList(ladderPrice, LowestPrice.Id); } string returnValue = string.Empty; if (m_BLL.CreatePrice(LowestPrice, listLadderPrice)) { LogClassModels.WriteServiceLog(Suggestion.InsertSucceed + ",报价信息的Id为" + LowestPrice.Id, "报价信息" );//写入日志 result.Code = Common.ClientCode.Succeed; result.Message = Suggestion.InsertSucceed; return(result); //提示创建成功 } else { if (validationErrors != null && validationErrors.Count > 0) { validationErrors.All(a => { returnValue += a.ErrorMessage; return(true); }); } LogClassModels.WriteServiceLog(Suggestion.InsertFail + ",报价信息," + returnValue, "报价信息" );//写入日志 result.Code = Common.ClientCode.Fail; result.Message = Suggestion.InsertFail + returnValue; return(result); //提示插入失败 } } result.Code = Common.ClientCode.FindNull; result.Message = Suggestion.InsertFail + ",请核对输入的数据的格式"; //提示输入的数据的格式不对 return(result); }
/// <summary> /// 根据ID获取数据模型 /// </summary> /// <param name="id">编号</param> /// <returns></returns> public dynamic Get(string id) { LadderLowestPrice item = m_BLL.GetById(id); var rstItem = new { ID = item.Id, SupplierID = item.SupplierId, LowestPrice = item.LowestPrice, ProductID = item.ProductId, AddPrice = item.AddPrice }; return(rstItem); }
/// <summary> /// 创建一个客户_企业报价 /// </summary> /// <param name="validationErrors">返回的错误信息</param> /// <param name="db">数据库上下文</param> /// <param name="entity">一个客户_企业报价</param> /// <returns></returns> public bool Create(ref ValidationErrors validationErrors, LadderLowestPrice entity) { try { repository.Create(entity); return(true); } catch (Exception ex) { validationErrors.Add(ex.Message); ExceptionsHander.WriteExceptions(ex); } return(false); }
/// <summary> /// 启用 /// </summary> /// <param name="id"></param> /// <returns></returns> public Common.ClientResult.Result Start(string id) { Common.ClientResult.Result result = new Common.ClientResult.Result(); if (ModelState.IsValid) { //数据校验 LadderLowestPrice item = m_BLL.GetById(id); //List<LadderLowestPrice> list = m_BLL.GetByParam("", "ASC", "ID", "SupplierIdDDL_Int&" + item.SupplierId + "^StatusDDL_String&" + Common.Status.启用.ToString()); int ckh = m_BLL.CheckLowestPrice(Convert.ToInt32(item.SupplierId)); if (ckh != 0) { result.Code = Common.ClientCode.Fail; result.Message = "供应商只能有一条启用中的最低报价信息!"; return(result); } item.Status = Common.Status.启用.ToString();//启用 string returnValue = string.Empty; if (m_BLL.Edit(ref validationErrors, item)) { LogClassModels.WriteServiceLog(Suggestion.UpdateSucceed + ",最低报价信息的Id为" + id, "最低报价信息_启用" );//写入日志 result.Code = Common.ClientCode.Succeed; result.Message = Suggestion.UpdateSucceed; return(result); //提示更新成功 } else { if (validationErrors != null && validationErrors.Count > 0) { validationErrors.All(a => { returnValue += a.ErrorMessage; return(true); }); } LogClassModels.WriteServiceLog(Suggestion.UpdateFail + ",客户_企业阶梯报价信息的Id为" + id + "," + returnValue, "客户_企业阶梯报价信息_启用" );//写入日志 result.Code = Common.ClientCode.Fail; result.Message = Suggestion.UpdateFail + returnValue; return(result); //提示更新失败 } } result.Code = Common.ClientCode.FindNull; result.Message = Suggestion.UpdateFail + "请核对输入的数据的格式"; return(result); //提示输入的数据的格式不对 }
/// <summary> /// 编辑 /// </summary> /// <param name="entity"></param> /// <returns></returns> public Common.ClientResult.Result Put([FromBody] LadderLowestPrice entity) { Common.ClientResult.Result result = new Common.ClientResult.Result(); if (entity != null && ModelState.IsValid) { LadderLowestPrice model = m_BLL.GetById(entity.Id); model.ProductId = entity.ProductId; model.LowestPrice = entity.LowestPrice; model.AddPrice = entity.AddPrice; string returnValue = string.Empty; if (m_BLL.Edit(ref validationErrors, model)) { LogClassModels.WriteServiceLog(Suggestion.UpdateSucceed + ",最低报价信息的Id为" + entity.Id, "最低报价" );//写入日志 result.Code = Common.ClientCode.Succeed; result.Message = Suggestion.UpdateSucceed; return(result); //提示更新成功 } else { if (validationErrors != null && validationErrors.Count > 0) { validationErrors.All(a => { returnValue += a.ErrorMessage; return(true); }); } LogClassModels.WriteServiceLog(Suggestion.UpdateFail + ",最低报价信息的Id为" + entity.Id + "," + returnValue, "最低报价" );//写入日志 result.Code = Common.ClientCode.Fail; result.Message = Suggestion.UpdateFail + returnValue; return(result); //提示更新失败 } } result.Code = Common.ClientCode.FindNull; result.Message = Suggestion.UpdateFail + "请核对输入的数据的格式"; return(result); //提示输入的数据的格式不对 }
//获得报价信息 private List <LadderLowestPrice> GetPriceList(string price) { List <LadderLowestPrice> list = new List <LadderLowestPrice>(); if (!string.IsNullOrEmpty(price)) { var jsonData = Newtonsoft.Json.JsonConvert.DeserializeObject <List <LadderLowestPrice> >(price); for (int i = 0; i < jsonData.Count; i++) { LadderLowestPrice model = new LadderLowestPrice(); model.ProductId = jsonData[i].ProductId; model.LowestPrice = jsonData[i].LowestPrice; model.AddPrice = jsonData[i].AddPrice; model.CreateTime = DateTime.Now; model.CreateUserID = LoginInfo.UserID; model.CreateUserName = LoginInfo.RealName; model.Status = Common.Status.启用.ToString(); list.Add(model); } } return(list); }
/// <summary> /// 添加报价信息 /// </summary> /// <param name="lowestPrice">最低报价</param> /// <param name="listLadderPrice">阶梯报价</param> /// <returns></returns> public bool CreatePrice(LadderLowestPrice lowestPrice, List <LadderPrice> listLadderPrice) { return(repository.CreatePrice(lowestPrice, listLadderPrice)); }
/// <summary> /// 创建 /// </summary> /// <param name="entity">实体对象</param> /// <returns></returns> public Common.ClientResult.Result Post([FromBody] LadderPrice entity, int id) { Common.ClientResult.Result result = new Common.ClientResult.Result(); //IBLL.ILadderPriceBLL bll = new LadderPriceBLL(); if (entity != null && ModelState.IsValid) { int currentPerson = LoginInfo.UserID; string currentPersonName = LoginInfo.RealName; int intBranchID = LoginInfo.BranchID; entity.CreateTime = DateTime.Now; entity.CreateUserID = currentPerson; entity.CreateUserName = currentPersonName; entity.BranchID = intBranchID; entity.Id = Common.Result.GetNewId(); entity.Status = Common.Status.启用.ToString(); IBLL.ILadderLowestPriceBLL l_BLL = new BLL.LadderLowestPriceBLL(); LadderLowestPrice lowest = l_BLL.GetByParam("", "ASC", "ID", "SupplierIdDDL_Int&" + id + "^StatusDDL_String&" + entity.Status).FirstOrDefault(); if (!string.IsNullOrEmpty(lowest.Id)) { entity.LadderLowestPriceId = lowest.Id; } else { LogClassModels.WriteServiceLog(Suggestion.UpdateFail + ",创建阶梯报价信息", "阶梯报价信息" );//写入日志 result.Code = Common.ClientCode.Fail; result.Message = "请检查阶梯报价范围!"; return(result); //提示更新失败 } if (!m_BLL.CheckRange(entity.LadderLowestPriceId, Convert.ToInt32(entity.BeginLadder), Convert.ToInt32(entity.EndLadder), "")) { LogClassModels.WriteServiceLog(Suggestion.UpdateFail + ",创建阶梯报价信息", "阶梯报价信息" );//写入日志 result.Code = Common.ClientCode.Fail; result.Message = "请检查阶梯报价范围!"; return(result); //提示更新失败 } string returnValue = string.Empty; if (m_BLL.Create(ref validationErrors, entity)) { LogClassModels.WriteServiceLog(Suggestion.InsertSucceed + ",创建阶梯报价信息的Id", "阶梯报价信息" );//写入日志 result.Code = Common.ClientCode.Succeed; result.Message = Suggestion.InsertSucceed; return(result); //提示创建成功 } else { if (validationErrors != null && validationErrors.Count > 0) { validationErrors.All(a => { returnValue += a.ErrorMessage; return(true); }); } LogClassModels.WriteServiceLog(Suggestion.InsertFail + ",客户_企业阶梯报价_待审核的信息," + returnValue, "客户_企业阶梯报价_待审核" );//写入日志 result.Code = Common.ClientCode.Fail; result.Message = Suggestion.InsertFail + returnValue; return(result); //提示插入失败 } } result.Code = Common.ClientCode.FindNull; result.Message = Suggestion.InsertFail + ",请核对输入的数据的格式"; //提示输入的数据的格式不对 return(result); }