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 io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParams;
|
import io.swagger.annotations.ApiOperation;
|
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.ResponseBody;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import java.util.Date;
|
import java.util.List;
|
|
/**
|
* @author zhibing.pu
|
* @date 2023/3/15 17:50
|
*/
|
@RestController
|
@RequestMapping("")
|
public class YouTuiController {
|
|
@Autowired
|
private IYouTuiDriverService youTuiDriverService;
|
|
@Autowired
|
private IDriverService driverService;
|
|
@Autowired
|
private IYouTuiService youTuiService;
|
|
|
|
|
|
|
|
@ResponseBody
|
@PostMapping("/api/youtui/queryDriverYouTui")
|
// @ServiceLog(name = "获取司机优推数据", url = "/api/youtui/queryDriverYouTui")
|
@ApiOperation(value = "获取司机优推数据", tags = {"司机端-个人中心"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "页码,首页1", name = "pageNum", required = true, dataType = "int"),
|
@ApiImplicitParam(value = "页条数", name = "pageSize", required = true, dataType = "int"),
|
@ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResponseWarpper<List<DriverYouTuiWarpper>> queryDriverYouTui(Integer pageNum, Integer pageSize){
|
if(ToolUtil.isEmpty(pageNum)){
|
return ResponseWarpper.success(ResultUtil.paranErr("pageNum"));
|
}
|
if(ToolUtil.isEmpty(pageSize)){
|
return ResponseWarpper.success(ResultUtil.paranErr("pageSize"));
|
}
|
try {
|
Integer uid = driverService.getUserByRequest();
|
if(null == uid){
|
return ResponseWarpper.tokenErr();
|
}
|
List<DriverYouTuiWarpper> driverYouTuiWarppers = youTuiDriverService.queryDriverYouTui(uid, pageNum, pageSize);
|
return ResponseWarpper.success(driverYouTuiWarppers);
|
}catch (Exception e){
|
e.printStackTrace();
|
return new ResponseWarpper(500, e.getMessage());
|
}
|
}
|
|
|
|
@ResponseBody
|
@PostMapping("/api/youtui/queryAllYouTui")
|
// @ServiceLog(name = "获取兑换权益列表", url = "/api/youtui/queryAllYouTui")
|
@ApiOperation(value = "获取兑换权益列表", tags = {"司机端-个人中心"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "页码,首页1", name = "pageNum", required = true, dataType = "int"),
|
@ApiImplicitParam(value = "页条数", name = "pageSize", required = true, dataType = "int"),
|
@ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResponseWarpper<List<DriverYouTuiWarpper>> queryAllYouTui(Integer pageNum, Integer pageSize){
|
if(ToolUtil.isEmpty(pageNum)){
|
return ResponseWarpper.success(ResultUtil.paranErr("pageNum"));
|
}
|
if(ToolUtil.isEmpty(pageSize)){
|
return ResponseWarpper.success(ResultUtil.paranErr("pageSize"));
|
}
|
try {
|
Integer uid = driverService.getUserByRequest();
|
if(null == uid){
|
return ResponseWarpper.tokenErr();
|
}
|
List<DriverYouTuiWarpper> driverYouTuiWarppers = youTuiDriverService.queryAllYouTui(pageNum, pageSize);
|
return ResponseWarpper.success(driverYouTuiWarppers);
|
}catch (Exception e){
|
e.printStackTrace();
|
return new ResponseWarpper(500, e.getMessage());
|
}
|
}
|
|
|
|
@ResponseBody
|
@PostMapping("/api/youtui/redeemBenefits")
|
// @ServiceLog(name = "司机兑换优推", url = "/api/youtui/redeemBenefits")
|
@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 redeemBenefits(Integer id){
|
if(ToolUtil.isEmpty(id)){
|
return ResponseWarpper.success(ResultUtil.paranErr("id"));
|
}
|
try {
|
Integer uid = driverService.getUserByRequest();
|
if(null == uid){
|
return ResponseWarpper.tokenErr();
|
}
|
ResultUtil resultUtil = youTuiDriverService.redeemBenefits(uid, id);
|
return ResponseWarpper.success(resultUtil);
|
}catch (Exception e){
|
e.printStackTrace();
|
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());
|
}
|
}
|
}
|