From 23927365bceeca84bddd58322eccfc8fa6cb1f49 Mon Sep 17 00:00:00 2001 From: "huan.xu" <275942173@qq.com> Date: Thu, 22 Oct 2020 19:56:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/EthWalletServiceImpl.java | 5 +++ .../yyyf/controller/LoginController.java | 44 ++++++++++++------- .../controller/TeachingGradeController.java | 2 +- .../yyyf/controller/YyyfMoneyController.java | 8 ++-- .../server/yyyf/dto/YyyfStudentAnswerDto.java | 2 +- .../service/impl/AssessUserServiceImpl.java | 2 +- 6 files changed, 39 insertions(+), 24 deletions(-) diff --git a/blockchain-server/blockchain-server-eth/src/main/java/com/blockchain/server/eth/service/impl/EthWalletServiceImpl.java b/blockchain-server/blockchain-server-eth/src/main/java/com/blockchain/server/eth/service/impl/EthWalletServiceImpl.java index c06b6c5..3e2f484 100644 --- a/blockchain-server/blockchain-server-eth/src/main/java/com/blockchain/server/eth/service/impl/EthWalletServiceImpl.java +++ b/blockchain-server/blockchain-server-eth/src/main/java/com/blockchain/server/eth/service/impl/EthWalletServiceImpl.java @@ -23,6 +23,8 @@ import com.blockchain.server.eth.service.*; import com.blockchain.server.eth.web3j.IWalletWeb3j; import com.codingapi.tx.annotation.ITxTransaction; import com.codingapi.tx.annotation.TxTransaction; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; @@ -78,6 +80,7 @@ public class EthWalletServiceImpl implements IEthWalletService, ITxTransaction { return ethWalletMapper.select(ethWallet); } + private static Logger LOG= LoggerFactory.getLogger(EthWalletServiceImpl.class); @Override @Transactional public EthWalletDTO insert(String userOpenId, String tokenAddr, String walletType, String pass) { @@ -445,6 +448,8 @@ public class EthWalletServiceImpl implements IEthWalletService, ITxTransaction { throw new EthWalletException(EthWalletEnums.RESET_ERROR); } YyyfUserDto yyyfUserDto = YyyfUserDtoUtils.getYyyfUserDtoByUserId(userOpenId, redisTemplate); + LOG.info(yyyfUserDto.toString()); + LOG.info("yyyfUserDtoID "+yyyfUserDto.getUserId()); ResultDTO resultDTO = yyyyfMoneyFeign.resetWallet(yyyfUserDto.getAssessUserId(), tokenId, BigDecimal.ZERO.subtract(config.getBalance())); if(resultDTO.getCode()==200 && resultDTO.getData().booleanValue()){ diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/LoginController.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/LoginController.java index a54c6c3..5664291 100644 --- a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/LoginController.java +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/LoginController.java @@ -1,5 +1,6 @@ package com.blockchain.server.yyyf.controller; +import com.alibaba.fastjson.JSONObject; import com.blockchain.common.base.constant.YyyfConstant; import com.blockchain.common.base.dto.ResultDTO; import com.blockchain.common.base.dto.TokenDTO; @@ -85,7 +86,9 @@ public class LoginController { yyyfUserDto.setUserName(userName); yyyfUserDto.setUserId(userId); yyyfUserDto.setUserType(yyyfLoginRequestVo.getUserType()); - + boolean needInit = false; + AssessUser assessUser = null; + List trainCaseTargeList = null; //做考试和练习 if (0 == reqType || 1 == reqType) { if (0 == reqType) { @@ -96,17 +99,17 @@ public class LoginController { return handleAfterLogin(yyyfLoginDto, yyyfUserDto); } } - AssessUser assessUser = this.assessUserService.selectAssessUserByUserIdAndissueIdForNotEnd(userId, examId); + assessUser = this.assessUserService.selectAssessUserByUserIdAndissueIdForNotEnd(userId, examId); if (assessUser == null) { Date now = new Date(); - String tel=new SimpleDateFormat("yyMMddHHmmss").format(now).concat(String.valueOf(userId)); + String tel = new SimpleDateFormat("yyMMddHHmmss").format(now).concat(String.valueOf(userId)); //第一次进入进行注册 - String code=String.format("%06d",new Random().nextInt(1000000)); - redisTemplate.opsForValue().set(YyyfConstant.REGISTER_KEY.concat(tel),code,YyyfConstant.TIME_OUT, TimeUnit.MINUTES); + String code = String.format("%06d", new Random().nextInt(1000000)); + redisTemplate.opsForValue().set(YyyfConstant.REGISTER_KEY.concat(tel), code, YyyfConstant.TIME_OUT, TimeUnit.MINUTES); yyyfLoginDto.setCode(code); - String password=String.format("%08d",new Random().nextInt(10000000)); + String password = String.format("%08d", new Random().nextInt(10000000)); String assessUserId = IdGenerator.uuid(); assessUser = new AssessUser(); assessUser.setId(assessUserId); @@ -126,16 +129,15 @@ public class LoginController { //获取案例信息 HashOperations examPaperOpsForHash = redisTemplate.opsForHash(); ExamPaperDto examPaperDto = examPaperOpsForHash.get(YyyfConstant.EXAM_PAPER_KEY, examPaperId); - List trainCaseTargeList = examPaperDto.getTrainCaseTargetList(); + trainCaseTargeList = examPaperDto.getTrainCaseTargetList(); assessUser.setWechatInitMoney(examPaperDto.getWechatInitMoney()); assessUser.setAlipayInitMoney(examPaperDto.getAlipayInitMoney()); assessUser.setBankcardInitMoney(examPaperDto.getBankcardInitMoney()); assessUser.setDigitwalletInitMoney(examPaperDto.getDigitwalletInitMoney()); - this.assessUserService.initAssessUser(assessUser, trainCaseTargeList); + needInit = true; } - yyyfUserDto.setAssessUserId(assessUser.getId()); yyyfLoginDto.setTel(assessUser.getTel()); yyyfLoginDto.setPassword(assessUser.getPassword()); @@ -163,7 +165,7 @@ public class LoginController { examDto.setExamPaperId(examPaperId); examDtoOpsForHash.put(YyyfConstant.EXAM_KEY, examId, examDto); } - yyyfLoginDto.setRemainingTime((examDto.getEndTime().getTime() - new Date().getTime() )/ 1000); + yyyfLoginDto.setRemainingTime((examDto.getEndTime().getTime() - new Date().getTime()) / 1000); joinStuIds = studentOpsForHash.get(YyyfConstant.JOIN_EXAM_STU_IDS_KEY, examId); if (joinStuIds == null) { joinStuIds = new ArrayList(); @@ -187,19 +189,27 @@ public class LoginController { return handleAfterLogin(yyyfLoginDto, yyyfUserDto); } } else { - String jioinExamId=null; + String jioinExamId = null; if (redisTemplate.hasKey(caseKey)) { Map examMsgMap = (Map) redisTemplate.opsForValue().get(caseKey); - jioinExamId= examMsgMap.get("examId"); - joinStuIds = studentOpsForHash.get(YyyfConstant.JOIN_EXAM_STU_IDS_KEY,jioinExamId); + jioinExamId = examMsgMap.get("examId"); + joinStuIds = studentOpsForHash.get(YyyfConstant.JOIN_EXAM_STU_IDS_KEY, jioinExamId); } //缓存是考试,要进入练习,则不让进入 if (joinStuIds != null && joinStuIds.stream() .filter(stuIds -> (stuIds.equals(userId))).count() != 0) { yyyfLoginDto.setStatus(3); yyyfLoginDto.setMsg(YyyfConstant.NO_ENTRY_INTO_PRACTICE); - ExamDto examDto = examDtoOpsForHash.get(YyyfConstant.EXAM_KEY, examId); - yyyfLoginDto.setRemainingTime((examDto.getEndTime().getTime() - new Date().getTime() )/ 1000); + ExamDto examDto = examDtoOpsForHash.get(YyyfConstant.EXAM_KEY, jioinExamId); + LOG.info("examId is " + examId + "examDto is " + JSONObject.toJSON(examDto) + "jioinExamId is " + jioinExamId); + yyyfLoginDto.setRemainingTime((examDto.getEndTime().getTime() - new Date().getTime()) / 1000); + + assessUser = this.assessUserService.selectAssessUserByUserIdAndissueIdForNotEnd(userId, jioinExamId); + yyyfUserDto.setAssessUserId(assessUser.getId()); + yyyfLoginDto.setTel(assessUser.getTel()); + yyyfLoginDto.setPassword(assessUser.getPassword()); + yyyfLoginDto.setNickName(userName); + Map map = new HashMap(); map.put("examPaperId", examDto.getExamPaperId()); @@ -218,7 +228,9 @@ public class LoginController { yyyfLoginDto.setStatus(1); } - + if (needInit && assessUser != null && trainCaseTargeList != null) { + this.assessUserService.initAssessUser(assessUser, trainCaseTargeList); + } return handleAfterLogin(yyyfLoginDto, yyyfUserDto); } diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/TeachingGradeController.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/TeachingGradeController.java index b41c2b5..51a5da5 100644 --- a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/TeachingGradeController.java +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/TeachingGradeController.java @@ -74,7 +74,7 @@ public class TeachingGradeController { * @param [issueId, totalNum, caseId, response] * @return void **/ - @GetMapping(value = "/getGradeData", produces = {"application/text;charset=UTF-8"}) + @PostMapping(value = "/getGradeData", produces = {"application/text;charset=UTF-8"}) @ResponseBody @SuppressWarnings("all") @ApiOperation(value = TeachingGradeApi.GetGradeData.METHOD_NAME, diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/YyyfMoneyController.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/YyyfMoneyController.java index c24e7c0..2b9eaec 100644 --- a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/YyyfMoneyController.java +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/YyyfMoneyController.java @@ -10,10 +10,7 @@ import io.swagger.annotations.ApiParam; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import java.math.BigDecimal; @@ -48,13 +45,14 @@ public class YyyfMoneyController { - @PostMapping("/resetWallet") + @GetMapping("/resetWallet") @ApiOperation(value = YyyfMoneyApi.ResetWallet.METHOD_NAME, notes = YyyfMoneyApi.ResetWallet.METHOD_NOTE) public ResultDTO resetDigitWallet(@ApiParam(YyyfMoneyApi.ResetWallet.METHOD_ASSESS_USER_ID) @RequestParam(name = "assessUserId",required =true) String assessUserId, @ApiParam(YyyfMoneyApi.ResetWallet.METHOD_COIN_NAME) @RequestParam(name = "coinName",required =true)String coinName, @ApiParam(YyyfMoneyApi.ResetWallet.METHOD_BALANCE) @RequestParam(name = "balance",required =true) BigDecimal balance) { + LOG.info("assessUserId is "+assessUserId+" ,coinName is "+ coinName + " ,balance is "+balance); boolean result=this.yyyfMoneyService.resetWallet(assessUserId,coinName,balance); return ResultDTO.requstSuccess(result); diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/YyyfStudentAnswerDto.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/YyyfStudentAnswerDto.java index 11342fa..4af2c91 100644 --- a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/YyyfStudentAnswerDto.java +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/YyyfStudentAnswerDto.java @@ -18,7 +18,7 @@ import java.util.Date; public class YyyfStudentAnswerDto implements Serializable { private static final long serialVersionUID = 505667820932379758L; private String authorization="87DIVy348Oxzj3ha"; - private String sysType="130"; + private String sysType="148"; private Integer userId; private Double totalScore; private Date startTime; diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/AssessUserServiceImpl.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/AssessUserServiceImpl.java index a2773c5..19db4ff 100644 --- a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/AssessUserServiceImpl.java +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/AssessUserServiceImpl.java @@ -253,7 +253,7 @@ public class AssessUserServiceImpl implements AssessUserService { this.assessUserTargetMapper.batchUpdateTargetAnswer(updateAssessUserTargetList); } - HttpClientUtil.doPostWithJSON(new StringBuilder().append(yyyfUrl).append(assessmentList).toString(), yyyfStudentAnswerDtoList); + HttpClientUtil.doPostWithJSON(new StringBuilder().append(yyyfUrl).append(assessmentList).toString(), yyyfStudentAnswerDtoList); }