| | |
| | | package com.supersavedriving.driver.modular.system.api; |
| | | |
| | | import com.supersavedriving.driver.core.util.ToolUtil; |
| | | import com.supersavedriving.driver.modular.system.model.YouTui; |
| | | import com.supersavedriving.driver.modular.system.model.YouTuiDriver; |
| | | import com.supersavedriving.driver.modular.system.service.IDriverService; |
| | | import com.supersavedriving.driver.modular.system.service.IYouTuiDriverService; |
| | | import com.supersavedriving.driver.modular.system.service.IYouTuiService; |
| | | import com.supersavedriving.driver.modular.system.util.ResultUtil; |
| | | import com.supersavedriving.driver.modular.system.warpper.DriverYouTuiWarpper; |
| | | import com.supersavedriving.driver.modular.system.warpper.ResponseWarpper; |
| | |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | |
| | | @Autowired |
| | | private IDriverService driverService; |
| | | |
| | | @Autowired |
| | | private IYouTuiService youTuiService; |
| | | |
| | | |
| | | |
| | |
| | | return new ResponseWarpper(500, e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/youtui/userYouTui") |
| | | // @ServiceLog(name = "司机使用优推", url = "/api/youtui/userYouTui") |
| | | @ApiOperation(value = "司机使用优推", tags = {"司机端-个人中心"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "优推数据id", name = "id", required = true, dataType = "int"), |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResponseWarpper userYouTui(Integer id){ |
| | | if(ToolUtil.isEmpty(id)){ |
| | | return ResponseWarpper.success(ResultUtil.paranErr("id")); |
| | | } |
| | | try { |
| | | Integer uid = driverService.getUserByRequest(); |
| | | if(null == uid){ |
| | | return ResponseWarpper.tokenErr(); |
| | | } |
| | | YouTuiDriver youTuiDriver = youTuiDriverService.selectById(id); |
| | | youTuiDriver.setState(2); |
| | | if(youTuiDriver.getType() == 2){ |
| | | YouTui youTui = youTuiService.selectById(youTuiDriver.getYouTuiId()); |
| | | youTuiDriver.setEndTime(new Date(System.currentTimeMillis() + (youTui.getNumber() * 3600000))); |
| | | } |
| | | youTuiDriverService.updateById(youTuiDriver); |
| | | return ResponseWarpper.success(); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return new ResponseWarpper(500, e.getMessage()); |
| | | } |
| | | } |
| | | } |