/// <summary> /// 骑士提现功能检查数据合法性,判断是否满足提现要求 add by caoheyang 20150509 /// </summary> /// <param name="withdrawCpm">参数实体</param> /// <param name="clienter">骑士</param> /// <param name="clienterFinanceAccount">骑士金融账号信息</param> /// <returns></returns> private FinanceWithdrawC CheckWithdrawC(WithdrawCPM withdrawCpm, ref clienter clienter, ref ClienterFinanceAccount clienterFinanceAccount) { if (withdrawCpm == null) { return(FinanceWithdrawC.NoPara); } if (withdrawCpm.WithdrawPrice % 100 != 0 || withdrawCpm.WithdrawPrice < 100 || withdrawCpm.WithdrawPrice > 3000) //提现金额小于500 加2手续费 { return(FinanceWithdrawC.MoneyDoubleError); } clienter = _clienterDao.GetById(withdrawCpm.ClienterId); //获取超人信息 if (clienter == null || clienter.Status == null || clienter.Status != ClienteStatus.Status1.GetHashCode()) //骑士状态为非 审核通过不允许 提现 { return(FinanceWithdrawC.ClienterError); } else if (clienter.AllowWithdrawPrice < withdrawCpm.WithdrawPrice) //可提现金额小于提现金额,提现失败 { return(FinanceWithdrawC.MoneyError); } else if (clienter.AccountBalance < clienter.AllowWithdrawPrice) //账户余额小于 可提现金额,提现失败 账号异常 { return(FinanceWithdrawC.FinanceAccountError); } clienterFinanceAccount = _clienterFinanceAccountDao.GetById(withdrawCpm.FinanceAccountId);//获取超人金融账号信息 if (clienterFinanceAccount == null || clienterFinanceAccount.ClienterId != withdrawCpm.ClienterId) { return(FinanceWithdrawC.FinanceAccountError); } return(FinanceWithdrawC.Success); }
/// <summary> /// 骑士提现功能 add by caoheyang 20150509 /// </summary> /// <param name="withdrawCpm">参数实体</param> /// <returns></returns> public ResultModel <object> WithdrawC(WithdrawCPM withdrawCpm) { using (IUnitOfWork tran = EdsUtilOfWorkFactory.GetUnitOfWorkOfEDS()) { clienter clienter = new clienter(); var clienterFinanceAccount = new ClienterFinanceAccount(); //骑士金融账号信息 FinanceWithdrawC checkbool = CheckWithdrawC(withdrawCpm, ref clienter, ref clienterFinanceAccount); if (checkbool != FinanceWithdrawC.Success) //验证失败 此次提款操作无效 直接返回相关错误信息 { return(ResultModel <object> .Conclude(checkbool)); } else { _clienterDao.UpdateForWithdrawC(new UpdateForWithdrawPM { Id = withdrawCpm.ClienterId, Money = -withdrawCpm.WithdrawPrice }); //更新骑士表的余额,可提现余额 string withwardNo = Helper.generateOrderCode(withdrawCpm.ClienterId); #region 骑士提现 long withwardId = _clienterWithdrawFormDao.Insert(new ClienterWithdrawForm() { WithwardNo = withwardNo, //单号 规则待定 ClienterId = withdrawCpm.ClienterId, //骑士Id(Clienter表) BalancePrice = clienter.AccountBalance, //提现前骑士余额 AllowWithdrawPrice = clienter.AllowWithdrawPrice, //提现前骑士可提现金额 Status = (int)ClienterWithdrawFormStatus.WaitAllow, //待审核 Amount = withdrawCpm.WithdrawPrice, //提现金额 Balance = clienter.AccountBalance - withdrawCpm.WithdrawPrice, //提现后余额 TrueName = clienterFinanceAccount.TrueName, //骑士收款户名 AccountNo = clienterFinanceAccount.AccountNo, //卡号(DES加密) AccountType = clienterFinanceAccount.AccountType, //账号类型: BelongType = clienterFinanceAccount.BelongType, //账号类别 0 个人账户 1 公司账户 OpenBank = clienterFinanceAccount.OpenBank, //开户行 OpenSubBank = clienterFinanceAccount.OpenSubBank //开户支行 }); #endregion #region 骑士余额流水操作 更新骑士表的余额,可提现余额 _clienterBalanceRecordDao.Insert(new ClienterBalanceRecord() { ClienterId = withdrawCpm.ClienterId, //骑士Id(Clienter表) Amount = -withdrawCpm.WithdrawPrice, //流水金额 Status = (int)ClienterBalanceRecordStatus.Tradeing, //流水状态(1、交易成功 2、交易中) RecordType = (int)ClienterBalanceRecordRecordType.WithdrawApply, Operator = clienter.TrueName, WithwardId = withwardId, RelationNo = withwardNo, Remark = "骑士提现" }); #endregion #region 骑士提现记录 _clienterWithdrawLogDao.Insert(new ClienterWithdrawLog() { WithwardId = withwardId, Status = (int)ClienterWithdrawFormStatus.WaitAllow,//待审核 Remark = "骑士发起提现操作", Operator = clienter.TrueName }); //更新骑士表的余额,可提现余额 #endregion tran.Complete(); } return(ResultModel <object> .Conclude(FinanceWithdrawC.Success));; } }
public ResultModel <object> WithdrawC([FromBody] WithdrawCPM withdrawCpm) { return(iClienterFinanceProvider.WithdrawC(withdrawCpm)); }