public BaseResponse <NCIPayGrantEntity> SavePayGrant(NCIPayGrantEntity request) { var response = new BaseResponse <NCIPayGrantEntity>(); try { NCIP_SERVICEDEPOSIT servicedeposit = new NCIP_SERVICEDEPOSIT(); servicedeposit.SERVICEDEPOSITID = Convert.ToInt32(base.GenerateCode("serviceId", EnumCodeKey.serviceId)); servicedeposit.NSID = request.NSID; servicedeposit.YEARMONTH = request.GrantYear + "-" + request.GrantMonTh; servicedeposit.AMOUNT = Convert.ToDecimal(Convert.ToDouble(request.TotalNCIpay + request.AdjustAmount) * 0.05); servicedeposit.SERVICEDEPOSITDATE = DateTime.Now; servicedeposit.STATUS = 0; servicedeposit.CREATEBY = SecurityHelper.CurrentPrincipal.UserId.ToString(); servicedeposit.CREATETIME = DateTime.Now; servicedeposit.ISDELETE = false; long servicedepositid = insertServicedeposit(servicedeposit); var model = unitOfWork.GetRepository <NCIP_NCIPAYGRANT>().dbSet.FirstOrDefault(m => m.GRANTID == request.GrantID && m.ISDELETE == false); model.STATUS = Convert.ToInt32(NCIPStatusEnum.Appropriated); model.SERVICEDEPOSITID = Convert.ToInt32(servicedepositid); model.ADJUSTAMOUNT = request.AdjustAmount; model.ADJUSTREASON = request.AdjustReason; model.CREATETIME = DateTime.Now; model.ISDELETE = false; model.CREATORNAME = request.CreatorName == null ? SecurityHelper.CurrentPrincipal.UserName : request.CreatorName; unitOfWork.GetRepository <NCIP_NCIPAYGRANT>().Update(model); unitOfWork.Save(); Mapper.CreateMap <NCIP_NSMONFEE, MonFeeModel>(); var modelpay = unitOfWork.GetRepository <NCIP_NSMONFEE>().dbSet.Where(m => m.ISDELETE == false && m.NCIPAYGRANTID == request.GrantID).ToList(); var monFeeList = Mapper.Map <List <MonFeeModel> >(modelpay); if (monFeeList != null) { foreach (var item in monFeeList) { item.Status = Convert.ToInt32(NCIPStatusEnum.Appropriated); item.CreatorName = request.CreatorName == null ? SecurityHelper.CurrentPrincipal.UserName : item.CreatorName; base.Save <NCIP_NSMONFEE, MonFeeModel>(item, (q) => q.NSMONFEEID == item.NSMonFeeID); resService.SaveResidentMonfeeStatus(item.NSMonFeeID, Convert.ToInt32(NCIPStatusEnum.Appropriated)); resService.SaveDeductionMonfeeStatus(item.NSMonFeeID, Convert.ToInt32(NCIPStatusEnum.Appropriated)); } } unitOfWork.Save(); } catch (Exception ex) { throw ex; } return(response); }
/// <summary> /// 保存服务记录保证金数据 /// </summary> /// <param name="request"></param> /// <returns></returns> public long insertServicedeposit(NCIP_SERVICEDEPOSIT request) { unitOfWork.GetRepository <NCIP_SERVICEDEPOSIT>().Insert(request); unitOfWork.Save(); return(request.SERVICEDEPOSITID); }