/// <summary> /// Handle前检查 /// </summary> /// <param name="entity"></param> protected virtual void PreCheckForHandle(PostIncomeInfo entity, string confirmedSOSysNoStr) { entity.Validate(p => p.SysNo != null, () => { throw new ArgumentNullException("entity.SysNo"); }) .Validate(p => p.HandleStatus != null, () => { throw new ArgumentNullException("entity.HandleStatus"); }); var soSysNoList = confirmedSOSysNoStr.Replace(",", ".") .Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries) .Distinct().ToList() .ConvertAll(s => Int32.Parse(s)); var soList = ExternalDomainBroker.GetSOBaseInfoList(soSysNoList); if (soList.Count != soSysNoList.Count) { var exceptSysNoList = soSysNoList.Except(soList.Select(s => s.SysNo.Value)).ToList(); ThrowBizException("PostIncome_InvalidSOSysNo", string.Join(".", exceptSysNoList)); } else { var recTotal = soList.Sum(s => s.ReceivableAmount); if (recTotal > entity.IncomeAmt.Value) { ThrowBizException("PostIncome_ReceivableAmtMoreThanIncomeAmt"); } } }
/// <summary> /// Create Or Update前检查 /// </summary> /// <param name="entity"></param> protected virtual void PreCheckForCreateOrUpdate(PostIncomeInfo entity, bool needValidate) { entity.Validate(p => p.IncomeDate != null, () => ThrowBizException("PostIncome_IncomeDateRequired")) .Validate(p => !string.IsNullOrEmpty(p.IncomeBank), () => ThrowBizException("PostIncome_IncomeBankRequired")) .Validate(p => p.IncomeAmt != null, () => ThrowBizException("PostIncome_IncomeAmtRequired")) .Validate(p => p.IncomeAmt >= 0, () => ThrowBizException("PostIncome_IncomeAmtShouldNotLessThanZero")) .Validate(p => { if (p.SOSysNo != null && needValidate) { var so = ObjectFactory <ISOBizInteract> .Instance.GetSOBaseInfo(p.SOSysNo.Value); if (so == null) { ThrowBizException("PostIncome_SONotExistFormat", p.SOSysNo); } return(ObjectFactory <PostPayProcessor> .Instance.IsBankOrPostPayType(so.PayTypeSysNo.Value)); } return(true); }, () => ThrowBizException("PostIncome_NotMatchSOPayTypeSysNo")); }