Пример #1
0
 /**
  * [修改财富账户金额]
  *
  * @param accountId [财富账户标识]
  * @param flag [加值、减值标志]
  * @param moneyType [需要影响的金额类型]
  * @param price [具体金额]
  * @return
  * @throws Exception
  */
 public boolean changeFinanceAccountMoney(
     Integer accountId, boolean flag, String moneyType, Double price) throws Exception {
   // 申明变量
   boolean result = false;
   FinanceAccount financeAccount = null;
   // 判断参数合法性
   if (NumberUtil.isEmptyOrZero(accountId) || StringUtil.isEmpty(moneyType)) {
     throw new ParamErrorException(ServiceErrorCodeConstant.E0039);
   } else {
     // 获取财富账户、持久化状态
     financeAccount = this.hibernateTemplate.load(FinanceAccount.class, accountId);
     // 判断金额类型-并根据加减标志进行更改
     if (FinanceAccountMoneyTypeEnum.CANUSE.getCode().equals(moneyType)) {
       if (flag) {
         financeAccount.setCanUseMoney(financeAccount.getCanUseMoney() + price);
       } else {
         financeAccount.setCanUseMoney(financeAccount.getCanUseMoney() - price);
       }
     }
     if (FinanceAccountMoneyTypeEnum.FROZEN.getCode().equals(moneyType)) {
       if (flag) {
         financeAccount.setFrozenMoney(financeAccount.getFrozenMoney() + price);
       } else {
         financeAccount.setFrozenMoney(financeAccount.getFrozenMoney() - price);
       }
     }
     result = true;
   }
   return result;
 }
Пример #2
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;
 }
Пример #3
0
 /**
  * [审核充值记录]
  *
  * @param financeAccountDetailId [充值记录实例]
  * @param flag [是否通过标志]
  * @return
  * @throws Exception
  */
 public boolean judgeFinanceAccountDetail(Integer financeAccountDetailId, boolean flag)
     throws Exception {
   // 申明变量
   FinanceAccountDetail detail = null;
   boolean result = false;
   // 判断参数合法性
   if (NumberUtil.isEmptyOrZero(financeAccountDetailId)) {
     throw new ParamErrorException(ServiceErrorCodeConstant.E0044);
   } else {
     // 获取指定的账户和明细信息
     detail = this.hibernateTemplate.load(FinanceAccountDetail.class, financeAccountDetailId);
     if (YesOrNoEnum.YES.getCode().equals(detail.getRequireJudgement())) {
       if (FinanceAccountDetailTypeEnum.RECHARGE.getCode().equals(detail.getType())) { // 如果是审核记录
         if (flag) { // 如果审核通过
           detail.setStatus(FinanceAccountDetailStatusEnum.PASS_JUDGEMENT.getCode());
           this.changeFinanceAccountMoney(
               detail.getAccountId(),
               true,
               FinanceAccountMoneyTypeEnum.CANUSE.getCode(),
               detail.getPrice());
           this.changeFinanceAccountMoney(
               detail.getAccountId(),
               false,
               FinanceAccountMoneyTypeEnum.FROZEN.getCode(),
               detail.getPrice());
         } else { // 如果审核未通过
           detail.setStatus(FinanceAccountDetailStatusEnum.REFUSE_JUDGEMENT.getCode());
           this.changeFinanceAccountMoney(
               detail.getAccountId(),
               false,
               FinanceAccountMoneyTypeEnum.FROZEN.getCode(),
               detail.getPrice());
         }
         result = true;
       } else if (FinanceAccountDetailTypeEnum.WITHDRAW.getCode().equals(detail.getType())) {
         if (flag) { // 如果审核通过
           detail.setStatus(FinanceAccountDetailStatusEnum.PASS_JUDGEMENT.getCode());
           this.changeFinanceAccountMoney(
               detail.getAccountId(),
               false,
               FinanceAccountMoneyTypeEnum.FROZEN.getCode(),
               detail.getPrice());
         } else { // 如果审核未通过
           detail.setStatus(FinanceAccountDetailStatusEnum.REFUSE_JUDGEMENT.getCode());
           this.changeFinanceAccountMoney(
               detail.getAccountId(),
               true,
               FinanceAccountMoneyTypeEnum.CANUSE.getCode(),
               detail.getPrice());
           this.changeFinanceAccountMoney(
               detail.getAccountId(),
               false,
               FinanceAccountMoneyTypeEnum.FROZEN.getCode(),
               detail.getPrice());
         }
         result = true;
       }
     }
   }
   return result;
 }