Exemplo n.º 1
0
 /**
  * [激活充值明细]
  *
  * @param financeAccountDetailId [充值纪录标识]
  * @return
  * @throws Exception
  */
 public boolean activeRechargeDetail(Integer financeAccountDetailId) throws Exception {
   // 申明变量
   boolean flag = false;
   FinanceAccountDetail financeAccountDetail = null;
   // 判断参数合法性
   if (NumberUtil.isEmptyOrZero(financeAccountDetailId)) {
     throw new ParamErrorException(ServiceErrorCodeConstant.E0038);
   } else {
     financeAccountDetail =
         this.hibernateTemplate.load(FinanceAccountDetail.class, financeAccountDetailId);
     if (DataStatusEnum.NORMAL.getCode().equals(financeAccountDetail.getDstatus())) {
       // 如果已经是正常状态的话,什么都不做
     } else {
       // 将状态置为正常
       financeAccountDetail.setDstatus(DataStatusEnum.NORMAL.getCode());
       // 如果成功-对冻结账户进行加值
       this.changeFinanceAccountMoney(
           financeAccountDetail.getAccountId(),
           true,
           FinanceAccountMoneyTypeEnum.FROZEN.getCode(),
           financeAccountDetail.getPrice());
     }
     flag = true;
   }
   return flag;
 }
Exemplo n.º 2
0
 /**
  * [创建财富账户]
  *
  * @param financeAccount [需要创建的财富账户实例]
  * @return
  * @throws Exception
  */
 public boolean createFinanceAcount(FinanceAccount financeAccount) throws Exception {
   // 申明变量
   boolean flag = false;
   boolean isExist = false;
   // 验证参数是否合法
   if (null == financeAccount || !financeAccount.validate()) {
     throw new ParamErrorException(ServiceErrorCodeConstant.E0035);
   } else {
     // 首先判断财富账户是否已经存在
     isExist = this.isFinanceAccountExist(financeAccount);
     if (isExist) { // 如果已经存在
       throw new ProcessErrorException(ServiceErrorCodeConstant.E0036);
     } else { // 如果不存在
       // 设定默认参数
       financeAccount.setDstatus(DataStatusEnum.NORMAL.getCode());
       // 默认账户没钱
       financeAccount.setCanUseMoney(0.0);
       financeAccount.setFrozenMoney(0.0);
       // 执行创建
       this.hibernateTemplate.save(financeAccount);
       flag = true;
     }
   }
   return flag;
 }
Exemplo n.º 3
0
 /**
  * [可用金额是否足够支付]
  *
  * @param passportId [用户标识]
  * @param money [金额]
  * @return
  * @throws Exception
  */
 public boolean isCanUseMoneyEnough(Integer passportId, Double money) throws Exception {
   // 申明变量
   boolean flag = false;
   FinanceAccount financeAccount = null;
   FinanceAccountCriteria financeAccountCriteria = null;
   List<FinanceAccount> financeAccounts = null;
   // 判断参数合法性
   if (NumberUtil.isEmptyOrZero(passportId) || NumberUtil.isEmptyOrZero(money)) {
     throw new ParamErrorException(ServiceErrorCodeConstant.E0051);
   } else {
     // 获取目标用户的财富账户
     financeAccountCriteria = new FinanceAccountCriteria();
     financeAccountCriteria.setRequirePage(false);
     financeAccountCriteria.setDstatus(DataStatusEnum.NORMAL.getCode());
     financeAccountCriteria.setPassportId(passportId);
     financeAccounts = this.financeDao.selectFinanceAccountWithPage(financeAccountCriteria);
     if (null != financeAccounts && 1 == financeAccounts.size()) {
       // 获取到该用户的财富账户
       financeAccount = financeAccounts.get(0);
       // 进行判断
       if (money <= financeAccount.getCanUseMoney()) { // 可用
         flag = true;
       } else { // 不可用
         flag = false;
       }
     } else {
       throw new ProcessErrorException(ServiceErrorCodeConstant.E0052);
     }
   }
   return flag;
 }
Exemplo n.º 4
0
 /**
  * [创建一个提现纪录信息]
  *
  * @param financeAccountDetail [需要创建的充值纪录实例]
  * @return
  * @throws Exception
  */
 public Integer createWithdrawDetail(FinanceAccountDetail financeAccountDetail) throws Exception {
   // 申明变量
   Integer id = 0;
   FinanceAccount financeAccount = null;
   // 检查参数合法性
   if (null == financeAccountDetail) {
     throw new ParamErrorException(ServiceErrorCodeConstant.E0038);
   } else {
     // 获取对应的账户信息
     financeAccount =
         this.hibernateTemplate.load(FinanceAccount.class, financeAccountDetail.getAccountId());
     // 判断提现金额
     if (financeAccount.getCanUseMoney() >= financeAccountDetail.getPrice()) {
       // 预设信息
       financeAccountDetail.setType(FinanceAccountDetailTypeEnum.WITHDRAW.getCode());
       financeAccountDetail.setStatus(FinanceAccountDetailStatusEnum.WAIT_JUDGEMENT.getCode());
       financeAccountDetail.setDstatus(DataStatusEnum.NORMAL.getCode());
       financeAccountDetail.setRequireJudgement(YesOrNoEnum.YES.getCode());
       // 执行保存操作
       id = (Integer) this.createFinanceAccountDetail(financeAccountDetail);
       // 冻结金额
       financeAccount.setCanUseMoney(
           financeAccount.getCanUseMoney() - financeAccountDetail.getPrice());
       financeAccount.setFrozenMoney(
           financeAccount.getFrozenMoney() + financeAccountDetail.getPrice());
     } else {
       throw new ProcessErrorException(ServiceErrorCodeConstant.E0089);
     }
   }
   return id;
 }
Exemplo n.º 5
0
 /**
  * [支付项目费用]
  *
  * @param passportId [支付用户标识]
  * @param money [支付金额]
  * @param type [支付类型]
  * @return
  * @throws Exception
  */
 public boolean payProjectCost(Integer passportId, Double money, String typeStr) throws Exception {
   // 申明变量
   boolean flag = false;
   FinanceAccount financeAccount = null;
   FinanceAccountCriteria financeAccountCriteria = null;
   List<FinanceAccount> financeAccounts = null;
   FinanceAccountDetail financeAccountDetail = null;
   // 判断参数合法性
   if (NumberUtil.isEmptyOrZero(passportId)
       || NumberUtil.isEmptyOrZero(money)
       || StringUtil.isEmpty(typeStr)) {
     throw new ParamErrorException(ServiceErrorCodeConstant.E0051);
   } else {
     // 获取目标用户的财富账户
     financeAccountCriteria = new FinanceAccountCriteria();
     financeAccountCriteria.setRequirePage(false);
     financeAccountCriteria.setDstatus(DataStatusEnum.NORMAL.getCode());
     financeAccountCriteria.setPassportId(passportId);
     financeAccounts = this.financeDao.selectFinanceAccountWithPage(financeAccountCriteria);
     if (null != financeAccounts && 1 == financeAccounts.size()) {
       // 获取到该用户的财富账户
       financeAccount = financeAccounts.get(0);
       // 重新获取持久化态的账户信息
       financeAccount = this.hibernateTemplate.load(FinanceAccount.class, financeAccount.getId());
       // 进行金额改动
       financeAccount.setCanUseMoney(financeAccount.getCanUseMoney() - money);
       // 生成支付明细
       if (FinanceAccountDetailTypeEnum.ENTRY_FREE.getCode().equals(typeStr)) {
         financeAccountDetail = new FinanceAccountDetail();
         financeAccountDetail.setPassportId(financeAccount.getPassportId());
         financeAccountDetail.setAccountId(financeAccount.getId());
         financeAccountDetail.setPrice(money);
         financeAccountDetail.setCurrency(CurrencyEnum.RMB.getCode());
         this.createEntryFreeDetail(financeAccountDetail);
       } else if (FinanceAccountDetailTypeEnum.ALLPAYMENT.getCode().equals(typeStr)) {
         financeAccountDetail = new FinanceAccountDetail();
         financeAccountDetail.setPassportId(financeAccount.getPassportId());
         financeAccountDetail.setAccountId(financeAccount.getId());
         financeAccountDetail.setPrice(money);
         financeAccountDetail.setCurrency(CurrencyEnum.RMB.getCode());
         this.createAllProjectFreeDetail(financeAccountDetail);
       }
       flag = true;
     } else {
       throw new ProcessErrorException(ServiceErrorCodeConstant.E0052);
     }
   }
   return flag;
 }
Exemplo n.º 6
0
 /**
  * [创建一个支付报名费纪录信息]
  *
  * @param financeAccountDetail [需要创建的充值纪录实例]
  * @return
  * @throws Exception
  */
 public boolean createEntryFreeDetail(FinanceAccountDetail financeAccountDetail) throws Exception {
   // 申明变量
   boolean flag = false;
   // 检查参数合法性
   if (null == financeAccountDetail) {
     throw new ParamErrorException(ServiceErrorCodeConstant.E0038);
   } else {
     // 预设信息
     financeAccountDetail.setType(FinanceAccountDetailTypeEnum.ENTRY_FREE.getCode());
     financeAccountDetail.setStatus(FinanceAccountDetailStatusEnum.PASS_JUDGEMENT.getCode());
     // 默认正常
     financeAccountDetail.setDstatus(DataStatusEnum.NORMAL.getCode());
     financeAccountDetail.setRequireJudgement(YesOrNoEnum.NO.getCode());
     // 执行保存操作
     this.createFinanceAccountDetail(financeAccountDetail);
     flag = true;
   }
   return flag;
 }