为了账号安全,请及时绑定邮箱和手机立即绑定

execution返回值不对?

可以秒杀成功,但是重复秒杀的时候。execution的Response是{"success":false,"data":{"seckillId":1000,"state":-2,"stateInfo":"系统异常","successKilled":null},"error":null}。

正在回答

1 回答

修改一下,SeckillController 类中的  加粗的位置即可

@ResponseBody
@RequestMapping(value = "/{seckillId}/{md5}/execution", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public SeckillResult<SeckillExecution> execute(@PathVariable("seckillId") Long seckillId,
                                              @PathVariable("md5") String md5,
                                              @CookieValue(value = "killPhone", required = false) Long phone) {
   if (phone == null){
       return new SeckillResult<SeckillExecution>(false,"未注册登录的用户");
   }
   try {
       SeckillExecution seckillExecution = seckillService.executeSeckill(seckillId, phone, md5);
       return new SeckillResult<SeckillExecution>(true,seckillExecution);
   }catch (RepeatKillException e){
       SeckillExecution execution = new SeckillExecution(seckillId, SeckillStateEnum.REPEAT_KILL);
       return new SeckillResult<SeckillExecution>(true,execution);
   }catch (SeckillCloseException e){
       SeckillExecution execution = new SeckillExecution(seckillId, SeckillStateEnum.END);
       return new SeckillResult<SeckillExecution>(true,execution);
   }catch (Exception e){
       logger.error(e.getMessage(),e);
       SeckillExecution execution = new SeckillExecution(seckillId, SeckillStateEnum.INNER_ERROR);
       return new SeckillResult<SeckillExecution>(true,execution);
   }
}

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

execution返回值不对?

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信