示例#1
0
        private CWGLRepaymentLogDto GetChangeModel(CWGLRepayment model)
        {
            var ret = model.MapTo <CWGLRepaymentLogDto>();

            ret.Mode = model.Mode.ToString();
            return(ret);
        }
示例#2
0
        public async Task <InitWorkFlowOutput> Create(CreateCWGLRepaymentInput input)
        {
            var borrowMoney = _borrowMoneyRepository.Get(input.BorrowMoneyId);
            var money       = _repository.GetAll().Where(x => !x.IsDeleted && x.BorrowMoneyId == input.BorrowMoneyId && x.Status != -2).Sum(x => x.Money);

            if (money + input.Money > borrowMoney.Money)
            {
                throw new UserFriendlyException((int)ErrorCode.CodeValErr, "还款金额不能大于借款金额!");
            }

            var newmodel = new CWGLRepayment()
            {
                BorrowMoneyId = input.BorrowMoneyId,
                Money         = input.Money,
                Mode          = input.Mode,
                BankName      = input.BankName,
                CardNumber    = input.CardNumber,
                BankOpenName  = input.BankOpenName
            };

            newmodel.Status = 0;
            await _repository.InsertAsync(newmodel);

            return(new InitWorkFlowOutput()
            {
                InStanceId = newmodel.Id.ToString()
            });
        }
示例#3
0
        public async Task Update(UpdateCWGLRepaymentInput input)
        {
            if (input.InStanceId != Guid.Empty)
            {
                var borrowMoney = _borrowMoneyRepository.Get(input.BorrowMoneyId);
                var dbmodel     = await _repository.FirstOrDefaultAsync(x => x.Id == input.InStanceId);

                if (dbmodel == null)
                {
                    throw new UserFriendlyException((int)ErrorCode.CodeValErr, "该数据不存在!");
                }
                var money = _repository.GetAll().Where(x => !x.IsDeleted && x.BorrowMoneyId == input.BorrowMoneyId && x.Status == -1).Sum(x => x.Money);
                if (money - dbmodel.Money + input.Money > borrowMoney.Money)
                {
                    throw new UserFriendlyException((int)ErrorCode.CodeValErr, "还款金额不能大于借款金额!");
                }

                var logModel = new CWGLRepayment();
                if (input.IsUpdateForChange)
                {
                    logModel = dbmodel.DeepClone <CWGLRepayment>();
                }
                dbmodel.BorrowMoneyId    = input.BorrowMoneyId;
                dbmodel.Money            = input.Money;
                dbmodel.Mode             = input.Mode;
                dbmodel.BankName         = input.BankName;
                dbmodel.CardNumber       = input.CardNumber;
                dbmodel.BankOpenName     = input.BankOpenName;
                input.FACData.BusinessId = input.InStanceId.ToString();
                await _repository.UpdateAsync(dbmodel);

                var groupId = Guid.NewGuid();
                input.FACData.GroupId = groupId;
                if (input.IsUpdateForChange)
                {
                    var flowModel = _workFlowCacheManager.GetWorkFlowModelFromCache(input.FlowId);
                    if (flowModel == null)
                    {
                        throw new UserFriendlyException((int)ErrorCode.CodeValErr, "流程不存在");
                    }
                    var logs = GetChangeModel(logModel).GetColumnAllLogs(GetChangeModel(dbmodel));
                    await _projectAuditManager.InsertAsync(logs, input.InStanceId.ToString(), flowModel.TitleField.Table, groupId);
                }
            }
            else
            {
                throw new UserFriendlyException((int)ErrorCode.CodeValErr, "该数据不存在!");
            }
        }