其他分享
首页 > 其他分享> > 锁表问题

锁表问题

作者:互联网

/**
*团队报名
*/
@Override
//@Transactional(propagation = Propagation.REQUIRED,rollbackFor = {Exception.class,RuntimeException.class})
public Result teamCompetition(Team team,Region region) {
try {
team.setGameState(1);
int i = teamMapper.updateByPrimaryKeySelective(team);

        if(i>0){
            region.setTotalpeople( region.getTotalpeople()+team.getPeopleNum());
            region.setTotalTeam(region.getTotalTeam()+1);
            int j = regionService.updateByKeySelective(region);
            if(j>0){
            //查询团队下所有队员
            List<TeamUser> tulist =  teamUserMapper.selectteamuser(team.getTid());
                Date date = new Date();
                List<UserMatch> umlist = new ArrayList <UserMatch>();
                if(!tulist.isEmpty()){
                    for (TeamUser teamuser: tulist) {
                        UserMatch userMatch = new UserMatch();
                        userMatch.setRegionid(teamuser.getRegionid());
                        userMatch.setUserid(teamuser.getUserid());
                        userMatch.setJointype(2);
                        userMatch.setJointime(date);
                        userMatch.setInitfund(new BigDecimal(region.getInitmoney()));
                            boolean flag = wybTaskService.doNewbieTask("jt",teamuser.getUserid());
                            if(flag){
                                umlist.add(userMatch);
                            }else{
                                throw GlobalException.error(CodeMsg.INFO(400,"团队报名参赛失败"));

                            }
                    }
                    int num =userMatchMapper.insertList(umlist);
                    if(num>0){
                        Map map = new HashMap();
                        map.put("captain_id",team.getTeamLeader());//队长
                        map.put("client_id",team.getTeamLeader());//
                        map.put("team_id",String.valueOf(team.getTid()));//团队id
                        map.put("game_id",String.valueOf(team.getRegionId()));//比赛id
                        String paramStr = JSONObject.toJSONString(map);


                        boolean b = setInvokeProtocol(paramStr, 11190);
                        if(b){
                           int m = teamUserMapper.updateteamuserByApplystateis(team.getTid());
                            logger.info("团队参赛后修改未通过申请的队员信息为失效"+m+"条。。。。。");
                           return Result.success();
                        }else{
                            throw GlobalException.error(CodeMsg.INFO(400,"团队报名参赛失败"));
                        }
                    }else {
                        throw GlobalException.error(CodeMsg.INFO(400,"团队报名参赛失败"));
                    }
                }else {
                    throw GlobalException.error(CodeMsg.INFO(400,"团队报名参赛失败"));
                }
            }else{
                throw GlobalException.error(CodeMsg.INFO(400,"团队报名参赛失败"));
            }
        }else{
            throw GlobalException.error(CodeMsg.INFO(400,"团队报名参赛失败"));
        }
    }catch (Exception e){
        e.printStackTrace();
        throw GlobalException.error(CodeMsg.INFO(400,"团队报名参赛异常"));
    }
}

/***************************************************************************************************/
@Override
public boolean doNewbieTask(String taskKey, Integer userid) {
String tasknames = “”;
switch (taskKey){
case “ct”:
tasknames = “创建团队”;
break;
case “cg”:
tasknames = “创建组合”;
break;
case “jt”:
tasknames = “参加团队”;
break;
case “wg”:
tasknames = “赢得比赛”;
break;
default:
tasknames = “其他任务”;
}
try {
WybTask wybTask = wybTaskMapper.selectByBaseName(taskKey);
TaskUser taskUser = taskUserService.selectByUserAndKey(userid,wybTask.getTaskSname());
if(null == taskUser){//当前用户没有做过首次穿件团队的任务
taskUser = new TaskUser();
taskUser.setTaskkey(wybTask.getTaskSname());
taskUser.setUserid(userid);
taskUser.setTaskname(“首次”+tasknames);
int m = taskUserService.saveSelective(taskUser);
if(m>0){
//首次创建团队的任务完成
int x =subscibeWalletService.updateRatByUser(userid,wybTask.getTaskIntegral());
if(x>0){//写一份积分记录
int num = subscibeWalletService.saveWybIntegralDetails(userid,
“首次完成新手任务-”+tasknames,wybTask.getTaskIntegral(),“新手任务-”+tasknames);
if(num>0){
return true;
}else{
throw GlobalException.error(CodeMsg.INFO(400,“首次完成新手任务失败”));
}
}else {
throw GlobalException.error(CodeMsg.INFO(400,“首次完成新手任务失败”));
}
}else{
throw GlobalException.error(CodeMsg.INFO(400,“首次完成新手任务失败”));
}
}else{
return true;
}
}catch (Exception e){
e.printStackTrace();
}
return false;
}

标签:INFO,锁表,team,else,问题,CodeMsg,400,throw
来源: https://blog.csdn.net/father_Blogger/article/details/100557823