execution返回值不對?
可以秒殺成功,但是重復秒殺的時候。execution的Response是{"success":false,"data":{"seckillId":1000,"state":-2,"stateInfo":"系統異常","successKilled":null},"error":null}。
可以秒殺成功,但是重復秒殺的時候。execution的Response是{"success":false,"data":{"seckillId":1000,"state":-2,"stateInfo":"系統異常","successKilled":null},"error":null}。
2017-06-12
舉報
2017-07-13
修改一下,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);
? ?}
}