项目中的绑卡与解绑

来源:互联网 发布:yy协议号软件 编辑:程序博客网 时间:2024/04/29 00:38

解绑操作

    public void unBindCard(Long cardId, Long accountId){        AccountActivation aa = accountActivationRepo.findBychargingCard(chargingCardRepo.findById(cardId));        aa.setBindDate(null);        aa.setEvcAccount(null);        ChargingCard card = chargingCardRepo.findById(cardId);        card.setTiedDate(null);        card.setLastestUpdateBy(CurrentUserInfo.getUserName());        card.setLastestUpdateTime(new Date());        int count = accountActivationRepo.findByEvcAccountId(accountId).size();        if(count == 0){            EvcAccount account = evcAccountRepo.findById(accountId);            account.setIsTied(false);            account.setLastestUpdateBy(CurrentUserInfo.getUserName());            account.setLastestUpdateTime(new Date());        }        accountActivationRepo.delete(aa);    }



绑卡操作


    public void evcAccountBindCard(AccoutSaveInfoDTO accoutSaveInfoDTO,List<Long> cardIdList) {        Long accoutId = accoutSaveInfoDTO.getId();        EvcAccount evcAccount = evcAccountRepo.findById(accoutId);        //EvcAccount evcAccount = convertTOEvcAccount(accoutSaveInfoDTO,accoutId);        evcAccount.setIsTied(true);        evcAccount.setLastestUpdateTime(new Date());        evcAccount.setLastestUpdateBy(CurrentUserInfo.getUserName());                if(cardIdList != null) {            for (Long cardId : cardIdList) {                    ChargingCard chargingCard = chargingCardRepo.findById(cardId);                AccountActivation accountActivation = null;                if(chargingCard.getAccountActivations().isEmpty()) {                    accountActivation = new AccountActivation();                    accountActivation.setChargingCard(chargingCard);                    chargingCard.getAccountActivations().add(accountActivation);                } else{                    accountActivation = chargingCard.getAccountActivations().get(0);                }                accountActivation.setBindDate(new Date());                accountActivation.setEvcAccount(evcAccount);                chargingCard.setTiedDate(new Date());            }        }    }


0 0
原创粉丝点击