Exemple #1
0
		public BLPayEntity Update (BLPayEntity entity)
		{
			try
            {
                _blpayRepository.Update(entity);
                return entity;
            }
            catch (Exception e)
            {
				_log.Error(e,"数据库操作出错");
                return null;
            }
		}
Exemple #2
0
		public bool Delete(BLPayEntity entity)
		{
			try
            {
                _blpayRepository.Delete(entity);
                return true;
            }
            catch (Exception e)
            {
				_log.Error(e,"数据库操作出错");
                return false;
            }
		}
        public HttpResponseMessage SetPay([FromBody]PayModel payModel)
        {
            var user = (UserBase) _workContext.CurrentUser;
            var broker = new BrokerEntity { };
            var BrokeAccount = new BrokeAccountEntity { };
            var BrokerWithdraw = new BrokerWithdrawEntity { };
            var BrokerWithDrawDetail = new BrokerWithdrawDetailEntity { };
            //var condition = new BrokerWithdrawDetailSearchCondition
            //{
            //    BrokerWithdraw = payModel.Id
            //};
            if (user == null)
            {
                //broker = _brokerService.GetBrokerByUserId(user.Id); //获取当前经纪人
                //if (broker == null)
                //{
                    return PageHelper.toJson(PageHelper.ReturnValue(false, "获取用户失败,请检查是否登陆"));
                //}
            }

            if (string.IsNullOrEmpty(payModel.Id))
            {
                return PageHelper.toJson(PageHelper.ReturnValue(false, "数据不能为空"));
            }
            //根据经纪人提现ID查询经纪人体现信息
            BrokerWithdraw = _brokerwithdrawService.GetBrokerWithdrawById(Convert.ToInt32(payModel.Id));
            // 判断提现状态,如果状态为一,则表示已经提现           
            if (BrokerWithdraw.State == 1) 
            {
                return PageHelper.toJson(PageHelper.ReturnValue(false, "财务已经打款"));
            }
            ////////////////////////////////////////////////////////////////////////////////////////////////
            //if (string.IsNullOrEmpty(payModel.Ids)) 
            //{
            //    return PageHelper.toJson(PageHelper.ReturnValue(false, "数据不能为空"));
            //}
            //if (string.IsNullOrEmpty(payModel.BrokeAccountId))
            //{
            //    return PageHelper.toJson(PageHelper.ReturnValue(false,"数据不能为空"));
            //}
            //构建查询实体
            var seach = new BrokerWithdrawDetailSearchCondition
            {
                OrderBy = EnumBrokerWithdrawDetailSearchOrderBy.OrderByTime,
                BrokerWithdraw = _brokerwithdrawService.GetBrokerWithdrawById(Convert.ToInt32(payModel.Id)),
            };
            var list = _brokerwithdrawDetailService.GetBrokerWithdrawDetailsByCondition(seach).Select(b => new
            {
                b.Id,
                b.Withdrawnum,
                b.BrokeAccount_Id,
                b.Withdrawtime,
                b.Type,
                b.BrokerWithdraw.WithdrawDesc,
                b.BrokerWithdraw.BankCard.Num,

            }).ToList().Select(a => new
            {
                a.Id,
                a.Withdrawnum,
                a.BrokeAccount_Id,
                a.Type,
                a.Num,
                WithdrawDesc = a.WithdrawDesc,
                Withdrawtime = a.Withdrawtime.ToString("yyy-MM-dd"),
            });
            foreach (var p in list) 
            {
                if (p == null) 
                {
                    return PageHelper.toJson(PageHelper.ReturnValue(false, "数据错误"));
                }
                if (Convert.ToInt32(p.Type) == 0) 
                {
                    var blModel = new BLPayEntity
                    {
                        Name = payModel.Name,
                        Describe = payModel.Describe,
                        BankCard = p.Num,
                        Accountantid = user.Id,
                        Amount = p.Withdrawnum,
                        Adduser = user.Id,
                        Upuser = user.Id,
                        Addtime = DateTime.Now,
                        Uptime = DateTime.Now,
                    };
                    _blPayService.Create(blModel);

                }
                if (Convert.ToInt32(p.Type) == 1)
                {
                    var breModel = new BRECPayEntity
                    {
                        Name = payModel.Name,
                        Describe = payModel.Describe,
                        BankCard = p.Num,
                        Accountantid = user.Id,
                        Amount = p.Withdrawnum,
                        Adduser = user.Id,
                        Upuser = user.Id,
                        Addtime = DateTime.Now,
                        Uptime = DateTime.Now,
                    };
                    _brecPayService.Create(breModel);
                }
                BrokeAccount = _brokerAcountService.GetBrokeAccountById(p.BrokeAccount_Id.Id);
                BrokeAccount.State = 1;
                BrokeAccount.Uptime = DateTime.Now;
                BrokeAccount.Upuser = user.Id;
                _brokerAcountService.Update(BrokeAccount);
            }
            //string[] strBrokeAccountId = payModel.BrokeAccountId.Split(',');
            //foreach (var BrokeAccountId in strBrokeAccountId)
            //{
            //    if (string.IsNullOrEmpty(BrokeAccountId))
            //    {
            //        return PageHelper.toJson(PageHelper.ReturnValue(false, "数据错误"));
            //    }
            //    BrokeAccount = _brokerAcountService.GetBrokeAccountById(Convert.ToInt32(BrokeAccountId));
            //    if (BrokeAccount.State == 1) 
            //    {
            //        break;
            //    }
            //}
            //string[] strIds = payModel.Ids.Split(',');
            //foreach (var id in strIds)
            //{
            //    if(string.IsNullOrEmpty(id))
            //    {
            //        break;
            //    }
            //    var model = _brokerwithdrawDetailService.GetBrokerWithdrawDetailById(Convert.ToInt32(id));
            //    if (Convert.ToInt32(model.Type) == 0) 
            //    {
            //        var blModel = new BLPayEntity
            //        {
            //            Name = payModel.Name,
            //            Describe = payModel.Describe,
            //            BankCard = Convert.ToInt32(model.BankCard.Num),
            //            Accountantid = broker.Id,
            //            Amount = model.Withdrawnum,
            //            Adduser = broker.Id,
            //            Upuser = broker.Id,
            //            Addtime = DateTime.Now,
            //            Uptime = DateTime.Now,
            //        };
            //        _blPayService.Create(blModel);
            //    }
            //    if (Convert.ToInt32(model.Type) == 1) 
            //    {
            //        var breModel = new BRECPayEntity
            //        {
            //            Name = payModel.Name,
            //            Describe = payModel.Describe,
            //            BankCard = Convert.ToInt32(model.BankCard.Num),
            //            Accountantid = broker.Id,
            //            Amount = model.Withdrawnum,
            //            Adduser = broker.Id,
            //            Upuser = broker.Id,
            //            Addtime = DateTime.Now,
            //            Uptime = DateTime.Now, 
            //        };
            //        _brecPayService.Create(breModel);
            //    }
               
            //}
            BrokerWithdraw.State = 1;
            //BrokerWithdraw.AccAccountantId.UserId = user.Id;
            BrokerWithdraw.Uptime = DateTime.Now;
            BrokerWithdraw.Upuser = user.Id;
            BrokerWithdraw.WithdrawDesc = payModel.Describe;
            BrokerWithdraw.BankSn = payModel.BankSn;
            _brokerwithdrawService.Update(BrokerWithdraw);
           
            return PageHelper.toJson(PageHelper.ReturnValue(true, "打款成功"));
        }