/**
  * [可用金额是否足够支付]
  *
  * @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;
 }
 /**
  * [支付项目费用]
  *
  * @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;
 }
 /**
  * [根据通行证标识,获取财务账号信息]
  *
  * @param passportId [通行证标识]
  * @return
  * @throws Exception
  */
 public FinanceAccount getFinanceAccountByPassportId(Integer passportId) throws Exception {
   // 申明变量
   FinanceAccount financeAccount = null;
   List<FinanceAccount> list = null;
   FinanceAccountCriteria criteria = null;
   // 判断参数合法性
   if (NumberUtil.isEmptyOrZero(passportId)) {
     throw new ParamErrorException(ServiceErrorCodeConstant.E0000);
   } else {
     criteria = new FinanceAccountCriteria();
     criteria.setRequirePage(false);
     criteria.setPassportId(passportId);
     list = this.financeDao.selectFinanceAccountWithPage(criteria);
     if (null != list && 0 < list.size()) {
       financeAccount = list.get(0);
     } else {
       financeAccount = null;
     }
   }
   return financeAccount;
 }