Exemplo n.º 1
0
 public HttpResponseMessage GetModel(GatheringViewModel gathering)
 {
     _dataResult.Code = ResponseStatusCode.Success;
     _dataResult.Msg = BusinessResourceMessage.Success;
     _dataResult.Data = _gatheringService.GetModel(gathering.ID, LoginUser.ID);
     return Request.CreateResponse(HttpStatusCode.OK, _dataResult);
 }
Exemplo n.º 2
0
 public HttpResponseMessage AuditGathering(GatheringViewModel gathering)
 {
     _gatheringService.AuditGathering(gathering, LoginUser.ID);
     _dataResult.Code = ResponseStatusCode.Success;
     _dataResult.Msg = BusinessResourceMessage.Success;
     return Request.CreateResponse(HttpStatusCode.OK, _dataResult);
 }
Exemplo n.º 3
0
        /// <summary>
        /// 审核提交收款信息
        /// </summary>
        /// <param name="gathering"></param>
        /// <param name="operateUserId"></param>
        public void AuditGathering(GatheringViewModel gathering, int operateUserId)
        {
            var loginUser = RedisHelp.GetLoginUserCacheNotNull(operateUserId);
            switch (loginUser.Type)
            {
                case UserType.Company:
                    throw new DataOperationPermissions("无此操作权限,总公司账号不能操作收款信息");
                case UserType.SpecialLine:
                    throw new DataOperationPermissions("无此操作权限,专线账号不能审核提交收款");
            }

            if (!string.IsNullOrEmpty(gathering.Remark) && gathering.Remark.Length > 200)
                throw new DataValidationException("收款备注不能超过200个汉字");
            if (gathering.Status == GatheringStatus.Discard && string.IsNullOrEmpty(gathering.Remark))
                throw new DataValidationException("当收款审核废弃时,收款备注不能为空");
            if (gathering.Status == GatheringStatus.WaitVerify)
                throw new DataValidationException("参数传入错误,当前接口收款状态参数不能为待收款");
            //得到查询
            var query = _gatheringRepository.GetModelTracking()
                .Include(p => p.Special.SpecialCapital)
                .Include(p => p.Special.Branch)
                .Where(p => p.ID == gathering.ID && p.Status == GatheringStatus.WaitVerify
                && p.Special.Status == SpecialStatus.Normal
                && p.Special.Branch.Status);

            var model = query.SingleOrDefault();
            if (model == null)
            {
                throw new BusinessException("此收款信息不存在");
            }
            if (loginUser.BranchId != model.Special.BranchId)
            {
                throw new DataOperationPermissions("无此操作权限,分社账号只能操作自身下属专线收款信息");
            }

            model.Remark = gathering.Remark;
            model.Status = gathering.Status;
            model.PayeeId = loginUser.ID;
            model.PayeeName = loginUser.Name;
            model.CollectionTime = DateTime.Now;

            #region 资金变动

            if (model.Status == GatheringStatus.HasReceiving)
            {
                model.Special.SpecialCapital.Balance += model.Money;
                model.Special.SpecialCapital.Gathering += model.Money;
                model.Special.SpecialCapital.Profit +=
                    DataProces.MoneyDataProce(model.Money * (model.Special.Branch.GrossMargin / 100));
            }

            #endregion

            _gatheringRepository.Update(model);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 申请提交收款
        /// </summary>
        /// <param name="gathering"></param>
        /// <param name="operateUserId"></param>
        public void SubmitGathering(GatheringViewModel gathering, int operateUserId)
        {
            var loginUser = RedisHelp.GetLoginUserCacheNotNull(operateUserId);
            switch (loginUser.Type)
            {
                case UserType.Company:
                    throw new DataOperationPermissions("无此操作权限,总公司账号不能操作收款信息");
                case UserType.Branch:
                    throw new DataOperationPermissions("无此操作权限,分社账号不能申请提交收款");
                case 0:
                    throw new DataOperationPermissions("无此操作权限,超级管理员不能申请提交收款");
            }
            #region 数据验证
            if (!gathering.Bank.ValidateLen(30))
                throw new DataValidationException("付款银行名称长度必须在1-30个字符之间");
            if (!gathering.Drawee.ValidateLen(20))
                throw new DataValidationException("付款人姓名长度必须在1-20个字符之间");
            if (!gathering.GatheringBank.ValidateLen(20))
                throw new DataValidationException("付款银行帐号长度必须在1-20个字符之间");
            if (gathering.Money <= 0)
                throw new DataValidationException("付款金额必须大于0");
            if (!gathering.SerialNumber.ValidateLen(100))
                throw new DataValidationException("银行流水号长度必须在1-100个字符之间");
            #endregion

            var model = new Gathering();
            model.SpecialId = loginUser.SpecialId.Value;
            model.SpecialName = loginUser.Special.Name;
            model.SubmiterId = loginUser.ID;
            model.SubmiterName = loginUser.Name;
            model.SubmitTime = DateTime.Now;
            model.Bank = gathering.Bank;
            model.SerialNumber = gathering.SerialNumber;
            model.Money = gathering.Money;
            model.GatheringBank = gathering.GatheringBank;
            model.Drawee = gathering.Drawee;

            model.Status = GatheringStatus.WaitVerify;
            _gatheringRepository.Insert(model);
        }