function openLottery(uint8 _viewId) public returns(uint8,uint8) {
        uint8 viewId = _viewId;
        require(viewId < 7);
        uint256 currentTerm = CLotteries.length - 1;
        CLottery storage clottery = CLotteries[currentTerm];

        if (currentGene == 0 && clottery.openBlock > 0 && clottery.isReward == false) {
            OpenLottery(viewId, clottery.luckyGenes[viewId], currentTerm, clottery.openBlock, clottery.totalAmount);
            return (clottery.luckyGenes[viewId],1);
        }
        if (lastBlockNumber == block.number) {
            OpenLottery(viewId, clottery.luckyGenes[viewId], currentTerm, clottery.openBlock, clottery.totalAmount);
            return (clottery.luckyGenes[viewId],2);
        }
        if (currentGene == 0 && clottery.isReward == true) {
            CLottery memory _clottery;
            _clottery.luckyGenes = [0,0,0,0,0,0,0];
            _clottery.totalAmount = uint256(0);
            _clottery.isReward = false;
            _clottery.openBlock = uint256(0);
            currentTerm = CLotteries.push(_clottery) - 1;
        }

        if (this._isCarousal(currentTerm)) {
            revert();
        }

        uint8 luckyNum = 0;
        
        uint256 bonusBalance = dogCore.getAvailableBlance();
        if (currentGene == 6) {
            if (bonusBalance <= SpoolAmount) {
                OpenLottery(viewId, clottery.luckyGenes[viewId], currentTerm, 0, 0);
                return (clottery.luckyGenes[viewId],3);
            }
            luckyNum = random(8);
            CLotteries[currentTerm].luckyGenes[currentGene] = luckyNum;
            OpenLottery(currentGene, luckyNum, currentTerm, block.number, bonusBalance);
            currentGene = 0;
            CLotteries[currentTerm].openBlock = block.number;
            CLotteries[currentTerm].totalAmount = bonusBalance;
            lastBlockNumber = block.number;
        } else {         
            luckyNum = random(12);
            CLotteries[currentTerm].luckyGenes[currentGene] = luckyNum;

            OpenLottery(currentGene, luckyNum, currentTerm, 0, 0);
            currentGene ++;
            lastBlockNumber = block.number;
        }
        return (luckyNum,0);
    }