public virtual void UpdateInvestmentDecisionVote(InvestmentDecisionVote entity) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } _IDVoteRepository.Update(entity); }
public virtual void SubmitInvestmentDecisionApplication(InvestmentDecisionForm entity) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } if (_IDCommitteeRepository.Table.Count() == 0) { throw new Exception("请设置投资决策委员会成员!"); } decimal totalWeight = 1; decimal applyUserWeight = 0; decimal otherWeight = 0; var committeeCodes = _IDCommitteeRepository.Table.Select(x => x.Code).ToList(); if (committeeCodes.Contains(entity.ApplyUser)) { applyUserWeight = 0.35M; otherWeight = CommonHelper.SetDecimalDigits((totalWeight - applyUserWeight), 4) / (committeeCodes.Count - 1); } else { applyUserWeight = 0; otherWeight = CommonHelper.SetDecimalDigits(totalWeight, 4) / committeeCodes.Count; committeeCodes.Add(entity.ApplyUser); } entity.Point = (int)(applyUserWeight * 100); entity.SerialNo = GenerateIDFSerialNo(entity.ApplyDate); _IDFormRepository.Insert(entity); var defaultVoteInfos = new List <InvestmentDecisionVote>(); foreach (var code in committeeCodes) { var info = new InvestmentDecisionVote { AuthorityLevel = 0, Flag = code == entity.ApplyUser ? (int)EnumLibrary.IDVoteFlag.Approval : (int)EnumLibrary.IDVoteFlag.None, FormSerialNo = entity.SerialNo, Reason = code == entity.ApplyUser ? entity.Reason : string.Empty, Type = code == entity.ApplyUser ? (int)EnumLibrary.IDVoteType.Applicant : (int)EnumLibrary.IDVoteType.Committee, UserCode = code, VoteTime = _commonService.GetCurrentServerTime(), Weight = code == entity.ApplyUser ? applyUserWeight : otherWeight, }; defaultVoteInfos.Add(info); } _IDVoteRepository.Insert(defaultVoteInfos); }