class MostVotedJob {

    public void insertDailyVotedCount() {
        List<UserGroup> userGroups = userGroupMapper.selectByGroupId(1);
        /**
         * 统计每人每天的投票数
         */
        for (UserGroup userGroup : userGroups) {
            Integer count = voteRecordMapper.selectDailyVotedCountByGroupUserId(userGroup.getUserGroupId(),new Date());
            MostVotedRecord mostVotedRecord = mostVotedRecordMapper.selectByVotedDateAndUserGroupId(new Date(), userGroup.getUserGroupId());
            if (mostVotedRecord == null) {
                mostVotedRecord = new MostVotedRecord();
                mostVotedRecord.setGroupId(1);
                mostVotedRecord.setUserGroupId(userGroup.getUserGroupId());
                mostVotedRecord.setVotedCount(count);
                mostVotedRecord.setCoinGiveStatus(0);
                mostVotedRecord.setVotedDate(new Date());
                mostVotedRecordMapper.insertSelective(mostVotedRecord);
            }else {
                mostVotedRecord.setVotedCount(count);
                mostVotedRecordMapper.updateByPrimaryKeySelective(mostVotedRecord);
            }
        }

        calculateThePersonToGetCoin();
    }

}