package com.stylefeng.guns.modular.system.controller.general;
|
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
import com.stylefeng.guns.core.shiro.ShiroKit;
|
import com.stylefeng.guns.core.util.*;
|
import com.stylefeng.guns.modular.system.model.*;
|
import com.stylefeng.guns.modular.system.service.*;
|
import com.stylefeng.guns.modular.system.util.ExcelExportUtil;
|
|
import com.stylefeng.guns.modular.system.util.ResultUtil;
|
import org.apache.poi.ss.usermodel.Cell;
|
import org.apache.poi.ss.usermodel.Row;
|
import org.apache.poi.ss.usermodel.Sheet;
|
import org.apache.poi.ss.usermodel.Workbook;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Controller;
|
import org.springframework.ui.Model;
|
import org.springframework.web.bind.annotation.GetMapping;
|
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.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletResponse;
|
import java.util.ArrayList;
|
import java.util.Arrays;
|
import java.util.Date;
|
import java.util.List;
|
|
/**
|
* 车辆出租
|
* @author pzb
|
* @Date 2022/5/28 14:52
|
*/
|
@Controller
|
@RequestMapping("/carRental")
|
public class CarRentalController {
|
|
private String PREFIX = "/system/carRental/";
|
|
@Autowired
|
private ITCarBrandService carBrandService;
|
|
@Autowired
|
private ICarRentalService carRentalService;
|
|
@Autowired
|
private ITRegionService regionService;
|
|
@Autowired
|
private ITUserService userService;
|
|
@Autowired
|
private ITDriverService driverService;
|
|
@Autowired
|
private ITCompanyService companyService;
|
|
|
|
/**
|
* 跳转到列表页
|
* @return
|
*/
|
@GetMapping("/showCarRental")
|
public String showCarRental(Model model){
|
List<TCarBrand> state = carBrandService.selectList(new EntityWrapper<TCarBrand>().eq("state", 1));
|
model.addAttribute("carBrand", state);
|
model.addAttribute("userType", ShiroKit.getUser().getRoleType());
|
return PREFIX + "carRental.html";
|
}
|
|
/**
|
* 跳转到添加页
|
* @param model
|
* @return
|
*/
|
@GetMapping("/carRental_add")
|
public String carRental_add(Model model){
|
model.addAttribute("push", ShiroKit.getUser().getRoleType() == 1 ? true : false);
|
List<TCarBrand> state = carBrandService.selectList(new EntityWrapper<TCarBrand>().eq("state", 1));
|
model.addAttribute("carBrand", state);
|
List<TRegion> regions = regionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", 0));
|
model.addAttribute("regions", regions);
|
regions = regionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", regions.get(0).getId()));
|
model.addAttribute("city", regions);
|
return PREFIX + "carRental_add.html";
|
}
|
|
|
/**
|
* 跳转到详情页
|
* @param model
|
* @param id
|
* @return
|
*/
|
@GetMapping("/showCarRentalInfo")
|
public String showCarRentalInfo(Model model, Integer id){
|
CarRental carRental = carRentalService.selectById(id);
|
model.addAttribute("item", carRental);
|
TCarBrand tCarBrand = carBrandService.selectById(carRental.getBrandId());
|
model.addAttribute("brand", tCarBrand.getName());
|
model.addAttribute("imgs", ToolUtil.isNotEmpty(carRental.getImgUrl()) ? carRental.getImgUrl().split(",") : "");
|
model.addAttribute("videos", ToolUtil.isNotEmpty(carRental.getVideoUrl()) ? carRental.getVideoUrl().split(",") : "");
|
model.addAttribute("describeImgs", ToolUtil.isNotEmpty(carRental.getDescribeImgUrl()) ? carRental.getDescribeImgUrl().split(",") : "");
|
if(carRental.getUserType() == 1){
|
TUser tUser = userService.selectById(carRental.getUserId());
|
model.addAttribute("pushUser", tUser.getName());
|
model.addAttribute("pushUserPhone", tUser.getPhone());
|
}
|
if(carRental.getUserType() == 2){
|
TDriver tDriver = driverService.selectById(carRental.getUserId());
|
model.addAttribute("pushUser", tDriver.getName());
|
model.addAttribute("pushUserPhone", tDriver.getPhone());
|
}
|
if(carRental.getUserType() == 3){
|
TCompany tCompany = companyService.selectById(carRental.getUserId());
|
model.addAttribute("pushUser", tCompany.getName());
|
model.addAttribute("pushUserPhone", tCompany.getPrincipalPhone());
|
}
|
model.addAttribute("status", (carRental.getStatus() == 1 || carRental.getStatus() == 4) ? "待发布" : (carRental.getStatus() == 2 ? "上架中" : carRental.getStatus() == 3 ? "下架中" : "已删除"));
|
return PREFIX + "carRental_info.html";
|
}
|
|
|
/**
|
* 跳转到编辑页
|
* @param model
|
* @param id
|
* @return
|
*/
|
@GetMapping("/carRental_update")
|
public String carRental_update(Model model, Integer id){
|
CarRental carRental = carRentalService.selectById(id);
|
model.addAttribute("item", carRental);
|
List<TCarBrand> state = carBrandService.selectList(new EntityWrapper<TCarBrand>().eq("state", 1));
|
model.addAttribute("carBrand", state);
|
model.addAttribute("imgs", ToolUtil.isNotEmpty(carRental.getImgUrl()) ? carRental.getImgUrl().split(",") : "");
|
model.addAttribute("videos", ToolUtil.isNotEmpty(carRental.getVideoUrl()) ? carRental.getVideoUrl().split(",") : "");
|
model.addAttribute("describeImgs", ToolUtil.isNotEmpty(carRental.getDescribeImgUrl()) ? carRental.getDescribeImgUrl().split(",") : "");
|
List<TRegion> regions = regionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", 0));
|
model.addAttribute("province", regions);
|
regions = regionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", regionService.selectOne(new EntityWrapper<TRegion>().eq("code", carRental.getProvinceCode())).getId()));
|
model.addAttribute("city", regions);
|
model.addAttribute("push", ShiroKit.getUser().getRoleType() == 1 ? true : false);
|
return PREFIX + "carRental_edit.html";
|
}
|
|
|
/**
|
* 跳转到车辆出租审核页
|
* @return
|
*/
|
@GetMapping("/showAuditCarRentalList")
|
public String showAuditCarRentalList(Model model){
|
List<TCarBrand> state = carBrandService.selectList(new EntityWrapper<TCarBrand>().eq("state", 1));
|
model.addAttribute("carBrand", state);
|
return PREFIX + "auditCarRental.html";
|
}
|
|
/**
|
* 跳转到审核页
|
* @return
|
*/
|
@GetMapping("/openAuditCarRental")
|
public String openAuditCarRental(Model model, Integer id){
|
CarRental carRental = carRentalService.selectById(id);
|
model.addAttribute("item", carRental);
|
TCarBrand tCarBrand = carBrandService.selectById(carRental.getBrandId());
|
model.addAttribute("brand", tCarBrand.getName());
|
model.addAttribute("imgs", ToolUtil.isNotEmpty(carRental.getImgUrl()) ? carRental.getImgUrl().split(",") : "");
|
model.addAttribute("videos", ToolUtil.isNotEmpty(carRental.getVideoUrl()) ? carRental.getVideoUrl().split(",") : "");
|
model.addAttribute("describeImgs", ToolUtil.isNotEmpty(carRental.getDescribeImgUrl()) ? carRental.getDescribeImgUrl().split(",") : "");
|
if(carRental.getUserType() == 1){
|
TUser tUser = userService.selectById(carRental.getUserId());
|
model.addAttribute("pushUser", tUser.getName());
|
model.addAttribute("pushUserPhone", tUser.getPhone());
|
}
|
if(carRental.getUserType() == 2){
|
TDriver tDriver = driverService.selectById(carRental.getUserId());
|
model.addAttribute("pushUser", tDriver.getName());
|
model.addAttribute("pushUserPhone", tDriver.getPhone());
|
}
|
if(carRental.getUserType() == 3){
|
TCompany tCompany = companyService.selectById(carRental.getUserId());
|
model.addAttribute("pushUser", tCompany.getName());
|
model.addAttribute("pushUserPhone", tCompany.getPrincipalPhone());
|
}
|
model.addAttribute("status", (carRental.getStatus() == 1 || carRental.getStatus() == 4) ? "待发布" : (carRental.getStatus() == 2 ? "上架中" : carRental.getStatus() == 3 ? "下架中" : "已删除"));
|
return PREFIX + "auditCarRental_info.html";
|
}
|
|
|
/**
|
* 获取列表数据
|
* @param createTime
|
* @param title
|
* @param brandId
|
* @param insertUser
|
* @param status
|
* @param userType
|
* @param offset
|
* @param limit
|
* @return
|
*/
|
@ResponseBody
|
@PostMapping("/list")
|
public Object list(String createTime, String title, Integer brandId, String insertUser, Integer status, Integer userType, Integer offset, Integer limit){
|
try {
|
List<Integer> state = Arrays.asList(2, 3, 4);
|
if(null != status){
|
state = Arrays.asList(status);
|
}
|
return carRentalService.list(createTime, title, brandId, insertUser, state, userType, offset, limit);
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
|
/**
|
* 添加数据
|
* @param carRental
|
* @return
|
*/
|
@ResponseBody
|
@PostMapping("/addCarRental")
|
public ResultUtil addCarRental(CarRental carRental){
|
try {
|
return carRentalService.addCarRental(carRental);
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
/**
|
* 编辑数据
|
* @param carRental
|
* @return
|
*/
|
@ResponseBody
|
@PostMapping("/updateCarRental")
|
public ResultUtil updateCarRental(CarRental carRental){
|
try {
|
return carRentalService.updateCarRental(carRental);
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
|
/**
|
* 删除数据
|
* @param id
|
* @return
|
*/
|
@ResponseBody
|
@PostMapping("/deleteCarRental")
|
public ResultUtil deleteCarRental(Integer id){
|
try {
|
CarRental carRental = carRentalService.selectById(id);
|
carRental.setStatus(6);
|
carRentalService.updateById(carRental);
|
return ResultUtil.success();
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
/**
|
* 上架操作
|
* @param id
|
* @return
|
*/
|
@ResponseBody
|
@PostMapping("/onlineCarRental")
|
public ResultUtil onlineCarRental(Integer id){
|
try {
|
CarRental carRental = carRentalService.selectById(id);
|
if(carRental.getStatus() == 1){
|
return ResultUtil.error("该数据还未审核");
|
}
|
if(carRental.getStatus() == 2){
|
return ResultUtil.error("不允许重复操作");
|
}
|
carRental.setStatus(2);
|
carRentalService.updateById(carRental);
|
return ResultUtil.success();
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
|
/**
|
* 下架操作
|
* @param id
|
* @return
|
*/
|
@ResponseBody
|
@PostMapping("/offlineCarRental")
|
public ResultUtil offlineCarRental(Integer id){
|
try {
|
CarRental carRental = carRentalService.selectById(id);
|
if(carRental.getStatus() == 1){
|
return ResultUtil.error("该数据还未审核");
|
}
|
if(carRental.getStatus() == 3){
|
return ResultUtil.error("不允许重复操作");
|
}
|
carRental.setStatus(3);
|
carRentalService.updateById(carRental);
|
return ResultUtil.success();
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
|
/**
|
* 设置首页推荐
|
* @param id
|
* @return
|
*/
|
@ResponseBody
|
@PostMapping("/homeCarRental")
|
public ResultUtil homeCarRental(Integer id){
|
try {
|
CarRental carRental = carRentalService.selectById(id);
|
if(carRental.getStatus() == 1){
|
return ResultUtil.error("该数据还未审核");
|
}
|
if(carRental.getStatus() == 3){
|
return ResultUtil.error("该数据已下架");
|
}
|
if(carRental.getStatus() == 4){
|
return ResultUtil.error("该数据还未上架");
|
}
|
if(carRental.getFirstPageShow() == 1){
|
return ResultUtil.error("不允许重复操作");
|
}
|
int i = carRentalService.selectCount(new EntityWrapper<CarRental>().in("status", Arrays.asList(2, 3)).eq("firstPageShow", 1));
|
if(i >= 6){
|
return ResultUtil.error("首页推荐最多设置6个");
|
}
|
carRental.setFirstPageShow(1);
|
carRentalService.updateById(carRental);
|
return ResultUtil.success();
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
/**
|
* 取消首页推荐
|
* @param id
|
* @return
|
*/
|
@ResponseBody
|
@PostMapping("/cancelHomeCarRental")
|
public ResultUtil cancelHomeCarRental(Integer id){
|
try {
|
CarRental carRental = carRentalService.selectById(id);
|
if(carRental.getStatus() == 1){
|
return ResultUtil.error("该数据还未审核");
|
}
|
if(carRental.getStatus() == 3){
|
return ResultUtil.error("该数据已下架");
|
}
|
if(carRental.getStatus() == 4){
|
return ResultUtil.error("该数据还未上架");
|
}
|
if(carRental.getFirstPageShow() == 2){
|
return ResultUtil.error("不允许重复操作");
|
}
|
carRental.setFirstPageShow(2);
|
carRentalService.updateById(carRental);
|
return ResultUtil.success();
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
|
/**
|
* 下载导入模板
|
* @param request
|
* @param response
|
*/
|
@RequestMapping(value = "/uploadCarRentalModel")
|
public void uploadCarRentalModel(HttpServletRequest request, HttpServletResponse response) {
|
// 表格数据【封装】
|
List<List<String>> dataList = new ArrayList<List<String>>();
|
|
// 首行【封装】
|
List<String> shellList = new ArrayList<String>();
|
shellList.add("用户类型[用户/司机/企业]");
|
shellList.add("用户手机号/企业名称");
|
shellList.add("标题");
|
shellList.add("品牌名称");
|
shellList.add("类别");
|
shellList.add("座位");
|
shellList.add("排量");
|
shellList.add("档位");
|
shellList.add("取车证件");
|
shellList.add("租金");
|
shellList.add("押金");
|
shellList.add("描述");
|
shellList.add("描述图片地址[多个英文逗号分隔]");
|
shellList.add("联系人");
|
shellList.add("联系人电话");
|
shellList.add("省");
|
shellList.add("市");
|
shellList.add("详细地址");
|
shellList.add("车辆图片地址[多个英文逗号分隔]");
|
shellList.add("车辆视频地址");
|
dataList.add(shellList);
|
|
try {
|
// 调用工具类进行导出
|
ExcelExportUtil.easySheet("车辆出租导入模板"+ DateUtil.formatDate(new Date(), "YYYYMMddHHmmss"), "车辆出租导入模板", dataList, request, response);
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
}
|
|
/**
|
* 导入数据
|
* @param request
|
* @return
|
*/
|
@ResponseBody
|
@PostMapping("/importCarRental")
|
public ResultUtil importCarRental(HttpServletRequest request){
|
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
MultipartFile file = (MultipartFile) multipartRequest.getFile("file");
|
try {
|
Workbook book = WoUtil.ImportFile(file);
|
Sheet sh = book.getSheetAt(0); //获取到第一个表
|
for (int i = 1; i <= sh.getLastRowNum(); i++) {
|
Row row = sh.getRow(i);
|
|
Cell cell0 = row.getCell(0); //用户类型[用户/司机/企业]
|
String zero = null;
|
if (SinataUtil.isNotEmpty(cell0)){
|
if(row.getCell(0)!=null){
|
row.getCell(0).setCellType(Cell.CELL_TYPE_STRING);
|
}
|
zero = String.valueOf(cell0.getStringCellValue()).trim();
|
}
|
|
Cell cell1 = row.getCell(1); //用户名称
|
String one = null;
|
if (SinataUtil.isNotEmpty(cell1)){
|
if(row.getCell(1)!=null){
|
row.getCell(1).setCellType(Cell.CELL_TYPE_STRING);
|
}
|
one = String.valueOf(cell1.getStringCellValue()).trim();
|
}
|
|
Cell cell2 = row.getCell(2); //标题
|
String two = null;
|
if (SinataUtil.isNotEmpty(cell2)){
|
if(row.getCell(2)!=null){
|
row.getCell(2).setCellType(Cell.CELL_TYPE_STRING);
|
}
|
two = String.valueOf(cell2.getStringCellValue()).trim();
|
}
|
|
Cell cell3 = row.getCell(3); //品牌名称
|
String three = null;
|
if (SinataUtil.isNotEmpty(cell3)){
|
if(row.getCell(3)!=null){
|
row.getCell(3).setCellType(Cell.CELL_TYPE_STRING);
|
}
|
three = String.valueOf(cell3.getStringCellValue()).trim();
|
}
|
|
Cell cell4 = row.getCell(4); //类别
|
String four = null;
|
if (SinataUtil.isNotEmpty(cell4)){
|
if(row.getCell(4)!=null){
|
row.getCell(4).setCellType(Cell.CELL_TYPE_STRING);
|
}
|
four = String.valueOf(cell4.getStringCellValue()).trim();
|
}
|
|
Cell cell5 = row.getCell(5); //座位
|
String five = null;
|
if (SinataUtil.isNotEmpty(cell5)){
|
if(row.getCell(5)!=null){
|
row.getCell(5).setCellType(Cell.CELL_TYPE_STRING);
|
}
|
five = String.valueOf(cell5.getStringCellValue()).trim();
|
}
|
|
Cell cell6 = row.getCell(6); //排量
|
String six = null;
|
if (SinataUtil.isNotEmpty(cell6)){
|
if(row.getCell(6)!=null){
|
row.getCell(6).setCellType(Cell.CELL_TYPE_STRING);
|
}
|
six = String.valueOf(cell6.getStringCellValue()).trim();
|
}
|
|
Cell cell7 = row.getCell(7); //档位
|
String seven = null;
|
if (SinataUtil.isNotEmpty(cell7)){
|
if(row.getCell(7)!=null){
|
row.getCell(7).setCellType(Cell.CELL_TYPE_STRING);
|
}
|
seven = String.valueOf(cell7.getStringCellValue()).trim();
|
}
|
|
Cell cell8 = row.getCell(8); //取车证件
|
String eight = null;
|
if (SinataUtil.isNotEmpty(cell8)){
|
if(row.getCell(8)!=null){
|
row.getCell(8).setCellType(Cell.CELL_TYPE_STRING);
|
}
|
eight = String.valueOf(cell8.getStringCellValue()).trim();
|
}
|
|
Cell cell9 = row.getCell(9); //租金
|
String nine = null;
|
if (SinataUtil.isNotEmpty(cell9)){
|
if(row.getCell(9)!=null){
|
row.getCell(9).setCellType(Cell.CELL_TYPE_STRING);
|
}
|
nine = String.valueOf(cell9.getStringCellValue()).trim();
|
}
|
|
Cell cell10 = row.getCell(10); //押金
|
String ten = null;
|
if (SinataUtil.isNotEmpty(cell10)){
|
if(row.getCell(10)!=null){
|
row.getCell(10).setCellType(Cell.CELL_TYPE_STRING);
|
}
|
ten = String.valueOf(cell10.getStringCellValue()).trim();
|
}
|
|
Cell cell11 = row.getCell(11); //描述
|
String eleven = null;
|
if (SinataUtil.isNotEmpty(cell11)){
|
if(row.getCell(11)!=null){
|
row.getCell(11).setCellType(Cell.CELL_TYPE_STRING);
|
}
|
eleven = String.valueOf(cell11.getStringCellValue()).trim();
|
}
|
|
Cell cell12 = row.getCell(12); //描述图片地址[多个英文逗号分隔]
|
String twelve = null;
|
if (SinataUtil.isNotEmpty(cell12)){
|
if(row.getCell(12)!=null){
|
row.getCell(12).setCellType(Cell.CELL_TYPE_STRING);
|
}
|
twelve = String.valueOf(cell12.getStringCellValue()).trim();
|
}
|
|
Cell cell13 = row.getCell(13); //联系人
|
String thirteen = null;
|
if (SinataUtil.isNotEmpty(cell13)){
|
if(row.getCell(13)!=null){
|
row.getCell(13).setCellType(Cell.CELL_TYPE_STRING);
|
}
|
thirteen = String.valueOf(cell13.getStringCellValue()).trim();
|
}
|
|
Cell cell14 = row.getCell(14); //联系人电话
|
String fourteen = null;
|
if (SinataUtil.isNotEmpty(cell14)){
|
if(row.getCell(14)!=null){
|
row.getCell(14).setCellType(Cell.CELL_TYPE_STRING);
|
}
|
fourteen = String.valueOf(cell14.getStringCellValue()).trim();
|
}
|
|
Cell cell15 = row.getCell(15); //省
|
String fifteen = null;
|
if (SinataUtil.isNotEmpty(cell15)){
|
if(row.getCell(15)!=null){
|
row.getCell(15).setCellType(Cell.CELL_TYPE_STRING);
|
}
|
fifteen = String.valueOf(cell15.getStringCellValue()).trim();
|
}
|
|
Cell cell16 = row.getCell(16); //市
|
String sixteen = null;
|
if (SinataUtil.isNotEmpty(cell16)){
|
if(row.getCell(16)!=null){
|
row.getCell(16).setCellType(Cell.CELL_TYPE_STRING);
|
}
|
sixteen = String.valueOf(cell16.getStringCellValue()).trim();
|
}
|
|
Cell cell17 = row.getCell(17); //详细地址
|
String seventeen = null;
|
if (SinataUtil.isNotEmpty(cell17)){
|
if(row.getCell(17)!=null){
|
row.getCell(17).setCellType(Cell.CELL_TYPE_STRING);
|
}
|
seventeen = String.valueOf(cell17.getStringCellValue()).trim();
|
}
|
|
Cell cell18 = row.getCell(18); //车辆图片地址[多个英文逗号分隔]
|
String eighteen = null;
|
if (SinataUtil.isNotEmpty(cell18)){
|
if(row.getCell(18)!=null){
|
row.getCell(18).setCellType(Cell.CELL_TYPE_STRING);
|
}
|
eighteen = String.valueOf(cell18.getStringCellValue()).trim();
|
}
|
|
Cell cell19 = row.getCell(19); //车辆视频地址
|
String nineteen = null;
|
if (SinataUtil.isNotEmpty(cell19)){
|
if(row.getCell(19)!=null){
|
row.getCell(19).setCellType(Cell.CELL_TYPE_STRING);
|
}
|
nineteen = String.valueOf(cell19.getStringCellValue()).trim();
|
}
|
|
|
if (SinataUtil.isEmpty(zero) || SinataUtil.isEmpty(three) || SinataUtil.isEmpty(four)
|
|| SinataUtil.isEmpty(five) || SinataUtil.isEmpty(six) || SinataUtil.isEmpty(seven)
|
|| SinataUtil.isEmpty(eight) || SinataUtil.isEmpty(nine) || SinataUtil.isEmpty(ten)
|
|| SinataUtil.isEmpty(eleven) || SinataUtil.isEmpty(twelve) || SinataUtil.isEmpty(thirteen)
|
|| SinataUtil.isEmpty(fourteen) || SinataUtil.isEmpty(fifteen) || SinataUtil.isEmpty(sixteen)
|
|| SinataUtil.isEmpty(seventeen) || SinataUtil.isEmpty(eighteen) || SinataUtil.isEmpty(nineteen)){
|
return ResultUtil.error("单元格不能为空");
|
}else{
|
//判断所属机构
|
if (!zero.equals("用户") && !zero.equals("司机") && !zero.equals("企业")){
|
return ResultUtil.error("用户类型不正确");
|
}
|
|
Integer userType = 0;
|
Integer userId = null;
|
if("用户".equals(zero)){
|
TUser tUser = userService.selectOne(new EntityWrapper<TUser>().eq("phone", one).eq("flag", 1));
|
if(null == tUser){
|
return ResultUtil.error("用户手机号不正确");
|
}
|
userType = 1;
|
userId = tUser.getId();
|
}
|
if("司机".equals(zero)){
|
TDriver tDriver = driverService.selectOne(new EntityWrapper<TDriver>().eq("phone", one).eq("flag", 1));
|
if(null == tDriver){
|
return ResultUtil.error("司机手机号不正确");
|
}
|
userType = 2;
|
userId = tDriver.getId();
|
}
|
if("企业".equals(zero)){
|
TCompany tCompany = companyService.selectOne(new EntityWrapper<TCompany>().eq("name", one).eq("flag", 1));
|
if(null == tCompany){
|
return ResultUtil.error("企业名称不正确");
|
}
|
userType = 3;
|
userId = tCompany.getId();
|
}
|
|
TCarBrand tCarBrand = carBrandService.selectOne(new EntityWrapper<TCarBrand>().eq("name", three).eq("state", 1));
|
if(null == tCarBrand){
|
return ResultUtil.error("品牌名称不正确");
|
}
|
TRegion province = regionService.selectOne(new EntityWrapper<TRegion>().eq("name", fifteen));
|
if(null == province){
|
return ResultUtil.error("省名称不正确");
|
}
|
TRegion city = regionService.selectOne(new EntityWrapper<TRegion>().eq("name", sixteen));
|
if(null == city){
|
return ResultUtil.error("市名称不正确");
|
}
|
|
|
CarRental carRental = new CarRental();
|
carRental.setUserType(userType);
|
carRental.setUserId(userId);
|
carRental.setTitle(two);
|
carRental.setBrandId(tCarBrand.getId());
|
carRental.setBrandName(three);
|
carRental.setCategory(four);
|
carRental.setSeat(five);
|
carRental.setDisplacement(six);
|
carRental.setGear(seven);
|
carRental.setPickUpCarCarCertificates(eight);
|
carRental.setRentMoney(nine);
|
carRental.setDeposit(Double.valueOf(ten));
|
carRental.setDescribe(eleven);
|
carRental.setDescribeImgUrl(twelve);
|
carRental.setContactsName(thirteen);
|
carRental.setContactsPhone(fourteen);
|
carRental.setProvinceCode(province.getCode());
|
carRental.setCityCode(city.getCode());
|
carRental.setProvinceName(province.getName());
|
carRental.setCityName(city.getName());
|
carRental.setCreateTime(new Date());
|
carRental.setStatus(1);
|
carRental.setAddres(seventeen);
|
carRental.setImgUrl(eighteen);
|
carRental.setVideoUrl(nineteen);
|
carRental.setFirstPageShow(2);
|
carRental.setInsertUser(ShiroKit.getUser().getId());
|
carRentalService.insert(carRental);
|
}
|
}
|
return ResultUtil.success();
|
} catch (Exception e) {
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
|
|
/**
|
* 获取车辆出租审核列表
|
* @param createTime
|
* @param title
|
* @param brandId
|
* @param insertUser
|
* @param status
|
* @param userType
|
* @param offset
|
* @param limit
|
* @return
|
*/
|
@ResponseBody
|
@PostMapping("/listAuditCarRental")
|
public Object listAuditCarRental(String createTime, String title, Integer brandId, String insertUser, Integer status, Integer userType, Integer offset, Integer limit){
|
try {
|
List<Integer> state = Arrays.asList(1, 5);
|
if(null != status){
|
state = Arrays.asList(status);
|
}
|
return carRentalService.list(createTime, title, brandId, insertUser, state, userType, offset, limit);
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
|
/**
|
* 审核操作
|
* @param id
|
* @param status
|
* @param authRemark
|
* @return
|
*/
|
@ResponseBody
|
@PostMapping("/auditCarRental")
|
public ResultUtil auditCarRental(Integer id, Integer status, String authRemark){
|
try {
|
return carRentalService.auditCarRental(id, status, authRemark);
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
}
|