Commit eda052ce authored by 周健威's avatar 周健威

修改申请接口

parent c7a15132
...@@ -20,8 +20,6 @@ import java.util.List; ...@@ -20,8 +20,6 @@ import java.util.List;
public interface UserRestInterface { public interface UserRestInterface {
public UserFeign getUserFeign(); public UserFeign getUserFeign();
default HttpServletRequest getRequest() { default HttpServletRequest getRequest() {
return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
} }
...@@ -111,16 +109,18 @@ public interface UserRestInterface { ...@@ -111,16 +109,18 @@ public interface UserRestInterface {
} }
default List<Integer> getBusinessUserCompanyIds(){ default List<Integer> getBusinessUserCompanyIds(){
//Integer currentUserIdInt = getCurrentUserIdInt(); UserDTO userDTO = getBusinessUserByAppUser();
if (getBusinessUserByAppUser() != null){
return userDTO.getCompanyIds();
}
return null;
}
default UserDTO getBusinessUserByAppUser(){
String currentUserName = BaseContextHandler.getUsername(); String currentUserName = BaseContextHandler.getUsername();
if (StrUtil.isNotBlank(currentUserName)){ if (StrUtil.isNotBlank(currentUserName)){
ObjectRestResponse<UserDTO> restResponse = getUserFeign().businessUserinfoByMobilePhone(currentUserName); ObjectRestResponse<UserDTO> restResponse = getUserFeign().businessUserinfoByMobilePhone(currentUserName);
if (restResponse.getData() != null){ return restResponse.getData();
UserDTO userDTO =restResponse.getData();
if (userDTO != null){
return userDTO.getCompanyIds();
}
}
} }
return null; return null;
} }
......
package com.xxfc.platform.order.rest; package com.xxfc.platform.order.rest;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.github.wxiaoqi.security.admin.feign.UserFeign; import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.admin.feign.dto.UserDTO;
import com.github.wxiaoqi.security.admin.feign.rest.UserRestInterface;
import com.github.wxiaoqi.security.common.context.BaseContextHandler; import com.github.wxiaoqi.security.common.context.BaseContextHandler;
import com.github.wxiaoqi.security.common.exception.BaseException; import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.rest.BaseController; import com.github.wxiaoqi.security.common.rest.BaseController;
import com.github.wxiaoqi.security.common.util.AssertUtils;
import com.github.wxiaoqi.security.common.util.OrderUtil;
import com.github.wxiaoqi.security.common.util.Query; import com.github.wxiaoqi.security.common.util.Query;
import com.github.wxiaoqi.security.common.util.process.ResultCode; import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.github.wxiaoqi.security.common.vo.PageDataVO; import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.github.wxiaoqi.security.common.vo.PageParam; import com.github.wxiaoqi.security.common.vo.PageParam;
import com.xxfc.platform.order.biz.BaseOrderBiz;
import com.xxfc.platform.order.biz.OrderRentVehicleBiz; import com.xxfc.platform.order.biz.OrderRentVehicleBiz;
import com.xxfc.platform.order.biz.ShuntApplyBiz; import com.xxfc.platform.order.biz.ShuntApplyBiz;
import com.xxfc.platform.order.biz.inner.OrderCalculateBiz; import com.xxfc.platform.order.biz.inner.OrderCalculateBiz;
import com.xxfc.platform.order.entity.BaseOrder;
import com.xxfc.platform.order.entity.ShuntApply; import com.xxfc.platform.order.entity.ShuntApply;
import com.xxfc.platform.order.mqhandler.RabbitProduct;
import com.xxfc.platform.order.pojo.order.OrderPageVO; import com.xxfc.platform.order.pojo.order.OrderPageVO;
import com.xxfc.platform.order.pojo.order.RentVehicleBO; import com.xxfc.platform.order.pojo.order.RentVehicleBO;
import com.xxfc.platform.order.pojo.order.add.AddRentVehicleDTO; import com.xxfc.platform.order.pojo.order.add.AddRentVehicleDTO;
import com.xxfc.platform.order.pojo.order.add.BgAddRentDTO; import com.xxfc.platform.order.pojo.order.add.BgAddRentDTO;
import com.xxfc.platform.order.rest.background.BgShuntApplyController;
import com.xxfc.platform.order.service.OrderRentVehicleService; import com.xxfc.platform.order.service.OrderRentVehicleService;
import com.xxfc.platform.vehicle.entity.VehicleModel; import com.xxfc.platform.vehicle.entity.VehicleModel;
import com.xxfc.platform.vehicle.feign.VehicleFeign; import com.xxfc.platform.vehicle.feign.VehicleFeign;
import com.xxfc.platform.vehicle.pojo.BookVehicleVO;
import com.xxfc.platform.vehicle.pojo.RentVehicleBookDTO;
import com.xxfc.platform.vehicle.pojo.vo.UsableVeicleVO;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.Data; import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
import static com.github.wxiaoqi.security.common.constant.CommonConstants.SYS_FALSE;
import static com.github.wxiaoqi.security.common.constant.CommonConstants.SYS_TRUE; import static com.github.wxiaoqi.security.common.constant.CommonConstants.SYS_TRUE;
import static com.github.wxiaoqi.security.common.vo.PageDataVO.pageInfo; import static com.github.wxiaoqi.security.common.vo.PageDataVO.pageInfo;
import static com.xxfc.platform.order.entity.ShuntApply.STATUS_CNL; import static com.xxfc.platform.order.entity.ShuntApply.*;
import static com.xxfc.platform.order.entity.ShuntApply.STATUS_CRT;
@RestController @RestController
@RequestMapping("shuntApply") @RequestMapping("shuntApply")
public class ShuntApplyController extends BaseController<ShuntApplyBiz, ShuntApply> { public class ShuntApplyController extends BaseController<ShuntApplyBiz, ShuntApply> implements UserRestInterface {
@Autowired @Autowired
...@@ -51,6 +68,17 @@ public class ShuntApplyController extends BaseController<ShuntApplyBiz, ShuntApp ...@@ -51,6 +68,17 @@ public class ShuntApplyController extends BaseController<ShuntApplyBiz, ShuntApp
@Autowired @Autowired
OrderRentVehicleService orderRentVehicleService; OrderRentVehicleService orderRentVehicleService;
@Autowired
BaseOrderBiz baseOrderBiz;
@Override
public UserFeign getUserFeign() {
return userFeign;
}
@Autowired
RabbitProduct rabbitProduct;
@RequestMapping(value = "/addApply", method = RequestMethod.POST) @RequestMapping(value = "/addApply", method = RequestMethod.POST)
@ResponseBody @ResponseBody
@ApiOperation(value = "添加申请") @ApiOperation(value = "添加申请")
...@@ -137,28 +165,6 @@ public class ShuntApplyController extends BaseController<ShuntApplyBiz, ShuntApp ...@@ -137,28 +165,6 @@ public class ShuntApplyController extends BaseController<ShuntApplyBiz, ShuntApp
throw new BaseException("该申请已下单", ResultCode.PARAM_ILLEGAL_CODE); throw new BaseException("该申请已下单", ResultCode.PARAM_ILLEGAL_CODE);
} }
// BgAddRentDTO bgAddRentDTO = new BgAddRentDTO();
// bgAddRentDTO.setAppUserId(shuntApply.getUserId());
// bgAddRentDTO.setStartTime(shuntApply.getStartTime());
// bgAddRentDTO.setEndTime(shuntApply.getEndTime());
// bgAddRentDTO.setVehicleId(shuntApply.getVehicleId());
//
// RentVehicleBO bo = orderRentVehicleBiz.initRentVehicleBO(bgAddRentDTO);
// bo.setDayNum(orderCalculateBiz.getIncludeDays(bgAddRentDTO.getStartTime(), bgAddRentDTO.getEndTime()));
//
// bo.setAppUserDTO(userFeign.userDetailById(bgAddRentDTO.getAppUserId()).getData());
// bo.setCrtUser("-1"+ BaseContextHandler.getUserID());
// //设置-1表示查询所有的车
// //bo.setUseType(-1);
// orderRentVehicleService.createOrder(bo);
// AddRentVehicleDTO vo = new AddRentVehicleDTO(){{
// setStartTime(shuntApply.getStartTime());
// setEndTime(shuntApply.getEndTime());
// setC
// setDayNum(orderCalculateBiz.getIncludeDays(shuntApply.getStartTime(), shuntApply.getEndTime()));
// }};
dto.setVehicleId(shuntApply.getVehicleId()); dto.setVehicleId(shuntApply.getVehicleId());
dto.setStartTime(shuntApply.getStartTime()); dto.setStartTime(shuntApply.getStartTime());
dto.setEndTime(shuntApply.getEndTime()); dto.setEndTime(shuntApply.getEndTime());
...@@ -196,4 +202,193 @@ public class ShuntApplyController extends BaseController<ShuntApplyBiz, ShuntApp ...@@ -196,4 +202,193 @@ public class ShuntApplyController extends BaseController<ShuntApplyBiz, ShuntApp
public static class CnlApplyDTO { public static class CnlApplyDTO {
Integer applyId; Integer applyId;
} }
/********************************************app商家端**********************************************************/
@RequestMapping(value = "/appBusiness/list", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "根据城市查询待确认申请列表")
public ObjectRestResponse<PageDataVO<BgShuntApplyController.StewardShuntApply>> stewardList(BgShuntApplyController.ListDTO dto) {
AssertUtils.isBlank(getBusinessUserByAppUser());
//获取该城市的申请最大和最小时间
//获取该店铺
PageDataVO<BgShuntApplyController.StewardShuntApply> list = PageDataVO.pageInfo(dto.initQuery(), () -> baseBiz.selectByWeekend(w -> {
if(null != dto.getCityCode()) {
w.andEqualTo(ShuntApply::getStartCityCode, dto.getCityCode());
}
w.andEqualTo(ShuntApply::getStatus, STATUS_CRT);
return w;
}, " crt_time desc "), BgShuntApplyController.StewardShuntApply.class);
list.getData().forEach(data -> {
data.setVehicleModel(vehicleFeign.get(data.getModelId()).getData());
});
return ObjectRestResponse.succ(list);
}
@RequestMapping(value = "/appBusiness/confirmApply", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "app商家用户确认申请")
public ObjectRestResponse stewardConfirmApply(@RequestBody BgShuntApplyController.ConfirmApplyDTO dto) {
UserDTO userDTO = getBusinessUserByAppUser();
AssertUtils.isBlank(userDTO);
//查询列表数据
if (StrUtil.isBlank(getCurrentUserId())) {
throw new BaseException(ResultCode.AJAX_WECHAT_NOTEXIST_CODE);
}
if(null == dto.getApplyId()) {
throw new BaseException(ResultCode.PARAM_ILLEGAL_CODE);
}
ShuntApply shuntApply = baseBiz.selectById(dto.getApplyId());
if(null == shuntApply && shuntApply.getStatus() != STATUS_CRT) {
throw new BaseException(ResultCode.PARAM_ILLEGAL_CODE);
}
RentVehicleBO detail = new RentVehicleBO();
detail.setStartTime(shuntApply.getStartTime());
detail.setEndTime(shuntApply.getEndTime());
detail.setVehicleId(dto.getVehicleId());
detail.setModelId(shuntApply.getModelId());
detail.setStartAddr(shuntApply.getStartCompanyName());
detail.setStartCompanyId(shuntApply.getStartCompanyId());
detail.setEndCompanyId(shuntApply.getEndCompanyId());
detail.setOrder(new BaseOrder(){{setNo(OrderUtil.GetOrderNumber("", OrderUtil.APP_MID));}});
detail.setRentFreeDay(SYS_FALSE);
detail.setBookVehicleVO(new BookVehicleVO(){{
setBookStartDate(DateUtil.date(shuntApply.getStartTime()).toDateStr());
setBookEndDate(DateUtil.date(shuntApply.getEndTime()).toDateStr());
setBookStartDateTime(DateUtil.date(shuntApply.getStartTime()).toString());
setBookEndDateTime(DateUtil.date(shuntApply.getEndTime()).toString());
}});
//预约车辆
orderRentVehicleService.acquireVehicle(detail, null , null);
shuntApply.setVehicleId(dto.getVehicleId());
shuntApply.setStatus(STATUS_CONFIRM);
shuntApply.setOrderNo(detail.getOrder().getNo());
shuntApply.setOverTime(DateUtil.offsetHour(DateUtil.date(), 1).getTime());
shuntApply.setConfirmUserId(userDTO.getId());
shuntApply.setConfirmCompanyId(userDTO.getCompanyId());
shuntApply.setBookRecordId(detail.getBookRecordId());
baseBiz.updateSelectiveByIdRe(shuntApply);
rabbitProduct.sendApplyDelayMessage(baseBiz.selectById(shuntApply.getId()), 1000L * 3601L);
return ObjectRestResponse.succ();
}
@RequestMapping(value = "/appBusiness/applyDetail", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "申请的详情")
public ObjectRestResponse stewardApplyDetail(Integer applyId) {
UserDTO userDTO = getBusinessUserByAppUser();
AssertUtils.isBlank(userDTO);
Integer companyId = userDTO.getCompanyId();
ShuntApply shuntApply = baseBiz.selectById(applyId);
BgShuntApplyController.StewardShuntApply shuntApplyVO = BeanUtil.toBean(shuntApply, BgShuntApplyController.StewardShuntApply.class);
shuntApplyVO.setVehicleModel(vehicleFeign.get(shuntApply.getModelId()).getData());
RentVehicleBookDTO rbd = new RentVehicleBookDTO();
rbd.setModelId(shuntApply.getModelId());
rbd.setParkBranchCompanyId(companyId);
rbd.setStartCompanyId(companyId);
rbd.setEndCompanyId(companyId);
rbd.setBookStartDate(DateUtil.date(shuntApply.getStartTime()).toDateStr());
rbd.setBookEndDate(DateUtil.date(shuntApply.getEndTime()).toDateStr());
rbd.setBookStartDateTime(DateUtil.date(shuntApply.getStartTime()).toString());
rbd.setBookEndDateTime(DateUtil.date(shuntApply.getEndTime()).toString());
//查询本公司时间段内可用车辆
ObjectRestResponse<PageDataVO<UsableVeicleVO>> usableVehiclePage = vehicleFeign.applyUsableVehicle(rbd);
if(CollUtil.isNotEmpty(usableVehiclePage.getData().getData())) {
List<UsableVeicleVO> vehicles = CollUtil.newArrayList();
usableVehiclePage.getData().getData().forEach(usableVeicleVO -> {
//判断是否预定时间内可租
usableVeicleVO.setAllowRent(SYS_TRUE);
//如果"必须在这时间后预定" 存在 并且 比预定开始时间 要晚,那么不允许预定
if(null != usableVeicleVO.getToLiftMustAfterDate() && DateUtil.date(shuntApply.getStartTime()).isBeforeOrEquals(usableVeicleVO.getToLiftMustAfterDate())) {
usableVeicleVO.setAllowRent(SYS_FALSE);
}
//如果"必须在这时间前预定" 存在 并且 比预定结束时间 要早,那么不允许预定
if(null != usableVeicleVO.getToReturnMustBeforeDate() && DateUtil.date(shuntApply.getEndTime()).isAfterOrEquals(usableVeicleVO.getToReturnMustBeforeDate())) {
usableVeicleVO.setAllowRent(SYS_FALSE);
}
if(SYS_TRUE.equals(usableVeicleVO.getAllowRent())) {
vehicles.add(BeanUtil.toBean(usableVeicleVO, UsableVeicleVO.class));
}
});
if(CollUtil.isNotEmpty(vehicles)) {
shuntApplyVO.setVehicles(vehicles);
}
}
return ObjectRestResponse.succ(shuntApplyVO);
}
@RequestMapping(value = "/appBusiness/myApplyList", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "我的申请")
public ObjectRestResponse myApplyList(BgShuntApplyController.PageDTO dto) {
UserDTO userDTO = getBusinessUserByAppUser();
AssertUtils.isBlank(userDTO);
PageDataVO<ShuntApplyController.ShuntApplyVO> pages = PageDataVO.pageInfo(dto.initQuery(), () -> baseBiz.selectByWeekend(w -> {
w.andEqualTo(ShuntApply::getConfirmUserId, userDTO.getId());
if(StrUtil.isNotBlank(dto.getMultiStatus())) {
w.andIn(ShuntApply::getStatus, CollUtil.toList(dto.getMultiStatus().split(",")));
}
return w;
}), ShuntApplyController.ShuntApplyVO.class);
pages.getData().forEach(data -> {
data.setVehicleModel(vehicleFeign.get(data.getModelId()).getData());
if(StrUtil.isNotBlank(data.getOrderNo())) {
Map<String, Object> map = CollUtil.newHashMap();
map.put("no", data.getOrderNo());
List<OrderPageVO> list = baseOrderBiz.pageByParm(map);
if(CollUtil.isNotEmpty(list)) {
data.setOrderPageVO(list.get(0));
}
}
});
return ObjectRestResponse.succ(pages);
}
@Data
public static class ConfirmApplyDTO {
Integer applyId;
String vehicleId;
}
@Data
public static class ListDTO extends PageParam {
Integer cityCode;
}
@Data
public static class PageDTO extends PageParam {
String multiStatus;
}
@Data
public static class StewardShuntApply extends ShuntApply {
List<UsableVeicleVO> vehicles;
VehicleModel vehicleModel;
public VehicleModel getVehicleModel() {
return vehicleModel;
}
public void setVehicleModel(VehicleModel vehicleModel) {
this.vehicleModel = vehicleModel;
}
}
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment