public ResultModel Update(UserModel user, Model.Pricing pricing, List<Model.PricingDetail> pricingDetails) { ResultModel result = new ResultModel(); DAL.PricingDetailDAL pricingDetailDAL = new PricingDetailDAL(); DAL.PricingApplyDAL pricingApplyDAL = new PricingApplyDAL(); try { using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required)) { result = pricingDAL.Get(user, pricing.PricingId); if (result.ResultStatus != 0) return result; Model.Pricing resPricing = result.ReturnValue as Model.Pricing; if (resPricing == null || resPricing.PricingId <= 0) { result.ResultStatus = -1; result.Message = "验证数据失败"; return result; } //获取点价申请 result = pricingApplyDAL.Get(user, pricing.PricingApplyId); if (result.ResultStatus != 0) return result; Model.PricingApply pricingApply = result.ReturnValue as Model.PricingApply; if (pricingApply == null || pricingApply.PricingApplyId <= 0) { result.ResultStatus = -1; result.Message = "对应点价申请不存在"; return result; } result = pricingDAL.IsWeightCanPricing(user, pricing.PricingApplyId, pricing.FuturesCodeId, pricingApply.PricingWeight, pricing.PricingWeight, true, resPricing.PricingWeight); if (result.ResultStatus != 0) return result; resPricing.PricingWeight = pricing.PricingWeight; resPricing.MUId = pricing.MUId; resPricing.ExchangeId = pricing.ExchangeId; resPricing.FuturesCodeEndDate = pricing.FuturesCodeEndDate; resPricing.FuturesCodeId = pricing.FuturesCodeId; resPricing.SpotQP = pricing.SpotQP; resPricing.DelayFee = pricing.DelayFee; resPricing.Spread = pricing.Spread; resPricing.OtherFee = pricing.OtherFee; resPricing.AvgPrice = pricing.AvgPrice; resPricing.PricingTime = pricing.PricingTime; resPricing.CurrencyId = pricing.CurrencyId; resPricing.Pricinger = pricing.Pricinger; resPricing.AssertId = pricing.AssertId; resPricing.FinalPrice = pricing.FinalPrice; result = pricingDAL.Update(user, resPricing); if (result.ResultStatus != 0) return result; result = pricingDetailDAL.InvalidAll(user, pricing.PricingId); if (result.ResultStatus != 0) return result; foreach (Model.PricingDetail detail in pricingDetails) { detail.PricingId = pricing.PricingId; detail.DetailStatus = StatusEnum.已生效; detail.PricingApplyId = resPricing.PricingApplyId; result = pricingDetailDAL.Insert(user, detail); if (result.ResultStatus != 0) return result; } scope.Complete(); } } catch (Exception ex) { result.Message = ex.Message; } finally { if (result.ResultStatus != 0) this.Log.ErrorFormat("{0} {1},序号:{2}", user.EmpName, result.Message, result.ReturnValue); else if (this.Log.IsInfoEnabled) this.Log.InfoFormat("{0} {1},序号:{2}", user.EmpName, result.Message, result.ReturnValue); } return result; }
public ResultModel Invalid(UserModel user, int pricingId) { ResultModel result = new ResultModel(); try { using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required)) { result = pricingDAL.Get(user, pricingId); if (result.ResultStatus != 0) return result; Model.Pricing pricing = result.ReturnValue as Model.Pricing; if (pricing == null) { result.Message = "不存在点价信息"; result.ResultStatus = -1; return result; } result = pricingDAL.Invalid(user, pricing); if (result.ResultStatus != 0) return result; DAL.PricingDetailDAL pricingDetailDAL = new PricingDetailDAL(); result = pricingDetailDAL.InvalidAll(user, pricingId); if (result.ResultStatus != 0) return result; scope.Complete(); } } catch (Exception ex) { result.Message = ex.Message; } finally { if (result.ResultStatus != 0) log.ErrorFormat("{0} {1},类型序号:{2}", user.EmpName, result.Message, result.ReturnValue); else if (log.IsInfoEnabled) log.InfoFormat("{0} {1},类型序号:{2}", user.EmpName, result.Message, result.ReturnValue); } return result; }