Commit 90d278e2 authored by jiaorz's avatar jiaorz

Merge remote-tracking branch 'origin/dev' into dev

parents 2491e3ad f13598c6
......@@ -35,4 +35,10 @@ public interface UserRestInterface {
return null;
}
}
default void checkAdminUser(){
if(null == getAdminUserInfo()) {
throw new BaseException(ResultCode.DB_OPERATION_FAIL_CODE);
}
}
}
......@@ -66,6 +66,16 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper,AppUserRel
log.info("----userId==="+userId+"----parentId===="+parentId+"----自己不能成为自己的上线");
return;
}
AppUserVo appUserVo=userDetailBiz.getUserInfoById(userId);
if (appUserVo==null){
log.info("----userId==="+userId+"----parentId===="+parentId+"----该用户不存在");
return;
}
appUserVo=userDetailBiz.getUserInfoById(parentId);
if (appUserVo==null){
log.info("----userId==="+userId+"----parentId===="+parentId+"----该上线用户不存在");
return;
}
AppUserRelation relation=getMyBiz().getRelationByUserId(parentId);
Long time=System.currentTimeMillis();
if(relation==null){
......@@ -122,7 +132,6 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper,AppUserRel
}
}
/**
* 小程序分享上下线绑定
* @param userid 当前人小程序id
......@@ -218,9 +227,10 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper,AppUserRel
//获取用户的下线总数
public int getCountByParentId(Integer parentId,Long time){
Example example=new Example(AppUserRelation.class);
example.createCriteria().andEqualTo("parentId",parentId).andNotEqualTo("isForever",1).andGreaterThan("bindTime",time);
return mapper.selectCountByExample(example);
if (validTime<=0){
time= validTime;
}
return mapper.countByParentId(parentId,time);
}
@CacheClear(key="user:relation{1.userId}")
......
package com.github.wxiaoqi.security.admin.mapper;
import com.github.wxiaoqi.security.admin.entity.AppUserRelation;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;
......@@ -16,4 +17,7 @@ public interface AppUserRelationMapper extends Mapper<AppUserRelation> {
List<AppUserRelation> selectByLeaderId(Integer leaderId);
//获取有效的下级
public int countByParentId(@Param("parentId")Integer parentId,@Param("bindTime")Long bindTime);
}
......@@ -6,4 +6,12 @@
<select id="selectByLeaderId" resultType="com.github.wxiaoqi.security.admin.entity.AppUserRelation">
select `parent_id` as `parentId`,`user_id`as `userId`,`bind_time` as `bindTime` from `app_user_relation` where `parent_id`=#{leaderId} and `is_del`=0 order by `bind_time` DESC
</select>
<select id="countByParentId" resultType="Integer">
select count(*) from `app_user_relation` where
`parent_id`=#{parentId} and `is_del`=0
<if test="bindTime!='' and bindTime!=null and bindTime>0">
and (is_forever=1 or bind_time>#{bindTime})
</if>
</select>
</mapper>
\ No newline at end of file
......@@ -323,7 +323,7 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> {
setOrderId(baseOrder.getId());
}});
//车辆预定审核通过
RestResponse<Integer> result = vehicleFeign.proveVehicleBooking(orvd.getBookRecordId());
RestResponse<Integer> result = vehicleFeign.rentProveVehicleBooking(orvd.getBookRecordId());
//确认免费天数
if (orvd.getFreeDays() > 0) {
......
package com.xxfc.platform.order.biz.inner;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.util.IntervalUtil;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.xxfc.platform.order.biz.*;
import com.xxfc.platform.order.contant.enumerate.*;
import com.xxfc.platform.order.entity.*;
import com.xxfc.platform.order.pojo.mq.OrderMQDTO;
import com.xxfc.platform.tour.feign.TourFeign;
import com.xxfc.platform.universal.dto.SmsTemplateDTO;
import com.xxfc.platform.universal.entity.Dictionary;
import com.xxfc.platform.universal.feign.ThirdFeign;
import com.xxfc.platform.universal.vo.OrderRefundVo;
import com.xxfc.platform.vehicle.common.RestResponse;
import com.xxfc.platform.vehicle.feign.VehicleFeign;
import com.xxfc.platform.vehicle.pojo.CompanyDetail;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.jexl2.MapContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -28,7 +20,6 @@ import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.*;
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.xxfc.platform.universal.constant.DictionaryKey.*;
......@@ -182,8 +173,8 @@ public class OrderCancelBiz {
//取消租车预定
//已支付,并且是待出行状态,取消预约
if(OrderStatusEnum.ORDER_TOSTART.equals(baseOrder.getType()) && SYS_TRUE.equals(baseOrder.getHasPay())){
vehicleFeign.unbookVehicle(orvd.getBookRecordId());
if(OrderStatusEnum.ORDER_TOSTART.equals(baseOrder.getStatus()) && SYS_TRUE.equals(baseOrder.getHasPay())){
vehicleFeign.rentUnbookVehicle(orvd.getBookRecordId());
}else {
//未支付,拒绝之前的预约
RestResponse<Integer> restResponse = vehicleFeign.rentRejectVehicleBooking(orvd.getBookRecordId());
......
......@@ -264,6 +264,21 @@ public class BackStageOrderController extends CommonBaseController implements Us
return new ObjectRestResponse<>().data(page.getData().get(0));
}
@ApiOperation("更換車輛")
@RequestMapping(value = "/bg/change-vehicle", method = RequestMethod.POST)
@IgnoreClientToken
@ResponseBody
public ObjectRestResponse<OrderPageVO> changeVehicle(@RequestBody ChangeVehicleDTO dto) {
checkAdminUser();
return ObjectRestResponse.succ();
}
@Data
public static class ChangeVehicleDTO {
String no;
String numberPlate;
}
private Query initCompanyQuery(String no) {
BackStageOrderController.QueryOrderDetailDTO qodd = new BackStageOrderController.QueryOrderDetailDTO();
//查询公司id
......
......@@ -54,12 +54,12 @@ public interface VehicleFeign {
public RestResponse<Integer> rentRejectVehicleBooking(@PathVariable(value = "bookRecordId") Long bookRecordId);
//取消预约
@RequestMapping(value = "/vehicleInfo/unbook/4employee/{bookRecordId}", method = RequestMethod.DELETE)
public RestResponse<Integer> unbookVehicle(@PathVariable(value = "bookRecordId") Long bookRecordId);
@RequestMapping(value = "/vehicleInfo/rent/unbook/{bookRecordId}", method = RequestMethod.DELETE)
public RestResponse<Integer> rentUnbookVehicle(@PathVariable(value = "bookRecordId") Long bookRecordId);
//通过预约
@RequestMapping(value = "/vehicleInfo/book/4employee/prove/{bookRecordId}", method = RequestMethod.PUT)
public RestResponse<Integer> proveVehicleBooking(@PathVariable(value = "bookRecordId") Long bookRecordId);
@RequestMapping(value = "/vehicleInfo/rent/book/prove/{bookRecordId}", method = RequestMethod.PUT)
public RestResponse<Integer> rentProveVehicleBooking(@PathVariable(value = "bookRecordId") Long bookRecordId);
//获取分公司列表
@GetMapping("/branchCompany/all")
......
package com.xxfc.platform.vehicle.rest;
import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONException;
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.auth.client.annotation.IgnoreClientToken;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken;
import com.github.wxiaoqi.security.auth.client.config.UserAuthConfig;
import com.github.wxiaoqi.security.common.context.BaseContextHandler;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.xxfc.platform.vehicle.biz.*;
import com.xxfc.platform.vehicle.common.BaseController;
import com.xxfc.platform.vehicle.common.CustomIllegalParamException;
import com.xxfc.platform.vehicle.common.RestResponse;
import com.xxfc.platform.vehicle.constant.BookType;
import com.xxfc.platform.vehicle.constant.ResCode.ResCode;
import com.xxfc.platform.vehicle.constant.VehicleBookRecordStatus;
import com.xxfc.platform.vehicle.entity.BranchCompany;
import com.xxfc.platform.vehicle.entity.Vehicle;
import com.xxfc.platform.vehicle.entity.VehicleBookInfo;
import com.xxfc.platform.vehicle.entity.VehicleBookRecord;
import com.xxfc.platform.vehicle.jobhandler.VehicleJobHandler;
import com.xxfc.platform.vehicle.pojo.*;
import com.xxfc.platform.vehicle.pojo.dto.VehiclePlanDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import static com.xxfc.platform.vehicle.constant.VehicleConstant.USER_APP;
import static com.xxfc.platform.vehicle.constant.VehicleConstant.USER_APP_NAME;
@RestController
@RequestMapping("/vehicleInfo")
@Slf4j
@IgnoreClientToken
@Api(value="租车相关车辆管理controller",tags={"租车相关车辆管理接口"})
public class RentVehicleController extends BaseController<VehicleBiz> implements UserRestInterface {
@Autowired
private VehiclePlatCataBiz vehiclePlatCataBiz;
@Autowired
UserFeign userFeign;
@Autowired
VehicleBiz vehicleBiz;
public UserFeign getUserFeign() {
return userFeign;
}
/**
* 租车拒绝预定车辆申请
*
* @param bookRecordId
* @return
*/
@RequestMapping(value = "/rent/book/reject/{bookRecordId}", method = RequestMethod.PUT)
@ApiOperation(value = "租车拒绝预定车辆")
@IgnoreUserToken
public RestResponse<Integer> rentRejectVehicleBooking(@PathVariable Long bookRecordId) throws Exception {
//默认USER_APP 预约
Integer operatorId = USER_APP;
String userName = USER_APP_NAME;
return baseBiz.reviewVehicleBooking(operatorId, bookRecordId, VehicleBookRecordStatus.REJECTED.getCode(), userName);
}
/**
* 取消车辆预订
*
* @param bookRecordId
* @return
*/
@RequestMapping(value = "/rent/unbook/{bookRecordId}", method = RequestMethod.DELETE)
@ApiOperation(value = "取消预定车辆")
public RestResponse<Integer> rentUnbookVehicle(@PathVariable Long bookRecordId) throws Exception {
//默认USER_APP 预约
Integer operatorId = USER_APP;
String userName = USER_APP_NAME;
return baseBiz.unbookVehicle4Employee(operatorId, bookRecordId, userName);
}
/**
* 批准预定车辆预定
*
* @param bookRecordId
* @return
*/
@RequestMapping(value = "/rent/book/prove/{bookRecordId}", method = RequestMethod.PUT)
@ApiOperation(value = "预定车辆审核通过")
public RestResponse<Integer> rentProveVehicleBooking(@PathVariable Long bookRecordId) throws Exception {
//默认USER_APP 预约
Integer operatorId = USER_APP;
String userName = USER_APP_NAME;
return baseBiz.reviewVehicleBooking(operatorId, bookRecordId, VehicleBookRecordStatus.APPROVE.getCode(), userName);
}
/**
* 可用车辆查询
*
* @param dto
* @return
*/
@ApiOperation("可用车辆查询")
@RequestMapping(value = "/rent/usable-vehicle", method = RequestMethod.GET)
@IgnoreUserToken
public ObjectRestResponse<PageDataVO<UsableVehicleModelVO>> rentUsableVehicle(UsableVeicleDTO dto) throws Exception {
//根据时间 获得 可用车辆
//结合车型
if (StringUtils.isNotBlank(dto.getCatasStr())) {
dto.setCatas(vehiclePlatCataBiz.groupCatasByParent(dto.getCatasStr()));
}
//设置显示是否有车
dto.setYearNo4Where(Boolean.TRUE);
return ObjectRestResponse.succ(vehicleBiz.searchUsableModel(dto));
}
/**
* 热门车型
*
* @param dto
* @return
*/
@ApiOperation("热门车型")
@RequestMapping(value = "/rent/hot-vehicle", method = RequestMethod.GET)
@IgnoreUserToken
public ObjectRestResponse<PageDataVO<UsableVehicleModelVO>> hotVehicle(HotVeicleDTO dto) throws Exception {
return ObjectRestResponse.succ(vehicleBiz.hotModel(dto));
}
/**
* 租车触发的申请预定车辆
*
* @param dto
* @return
*/
@ApiOperation("租车触发的申请预定车辆")
@RequestMapping(value = "/rent/book/vehicle", method = RequestMethod.POST)
@IgnoreClientToken
@IgnoreUserToken
public ObjectRestResponse<VehicleBookRecord> rentApplyVehicle(@RequestBody RentVehicleBookDTO dto) throws Exception {
//默认USER_APP 预约
Integer operatorId = USER_APP;
String userName = dto.getUserName();
//BaseContextHandler.getName();
dto.setLimit(1);
dto.setPage(1);
//查询可车辆信息
PageDataVO<Vehicle> pageDataVO = vehicleBiz.searchUsableVehicle(dto);
if (pageDataVO.getData().size() <= 0) {
throw new BaseException(ResultCode.NOTEXIST_CODE, new HashSet<String>(){{
add("可用车辆不存在");
}});
}
dto.setBookStartDate(dto.getBookStartDate()+ " 00:00:00");
dto.setBookEndDate(dto.getBookEndDate()+ " 23:59:59");
BookVehicleVO bookVehicleVo = BeanUtil.toBean(dto, BookVehicleVO.class);
bookVehicleVo.setBookType(BookType.USER_RENT.getCode());
bookVehicleVo.setVehicleId(pageDataVO.getData().get(0).getId());
bookVehicleVo.setStatus(VehicleBookRecordStatus.APPLY.getCode());
VehicleBookRecord vehicleBookRecord = baseBiz.applyVehicle(operatorId, bookVehicleVo, userName);
return ObjectRestResponse.succ(vehicleBookRecord);
}
}
......@@ -267,23 +267,6 @@ public class VehicleController extends BaseController<VehicleBiz> implements Use
return baseBiz.reviewVehicleBooking(operatorId, bookRecordId, VehicleBookRecordStatus.REJECTED.getCode(), userName);
}
/**
* 租车拒绝预定车辆申请
*
* @param bookRecordId
* @return
*/
@RequestMapping(value = "/rent/book/reject/{bookRecordId}", method = RequestMethod.PUT)
@ApiOperation(value = "租车拒绝预定车辆")
@IgnoreUserToken
public RestResponse<Integer> rentRejectVehicleBooking(@PathVariable Long bookRecordId) throws Exception {
//默认USER_APP 预约
Integer operatorId = USER_APP;
String userName = USER_APP_NAME;
return baseBiz.reviewVehicleBooking(operatorId, bookRecordId, VehicleBookRecordStatus.REJECTED.getCode(), userName);
}
// /**
// * 车辆归还
// * @param bookRecordId
......@@ -377,82 +360,12 @@ public class VehicleController extends BaseController<VehicleBiz> implements Use
return vehicleBookRecordBiz.retVehicle(operatorId, userName, retVehicleVo);
}
/**
* 可用车辆查询
*
* @param dto
* @return
*/
@ApiOperation("可用车辆查询")
@RequestMapping(value = "/rent/usable-vehicle", method = RequestMethod.GET)
@IgnoreUserToken
public ObjectRestResponse<PageDataVO<UsableVehicleModelVO>> rentUsableVehicle(UsableVeicleDTO dto) throws Exception {
//根据时间 获得 可用车辆
//结合车型
if (StringUtils.isNotBlank(dto.getCatasStr())) {
dto.setCatas(vehiclePlatCataBiz.groupCatasByParent(dto.getCatasStr()));
}
//设置显示是否有车
dto.setYearNo4Where(Boolean.TRUE);
return ObjectRestResponse.succ(vehicleBiz.searchUsableModel(dto));
}
@ApiOperation("根据权限获取所有车辆")
@GetMapping(value = "/info/getVehicle")
public ObjectRestResponse<PageDataVO<VehicleAndModelInfoVo>> getVehicle(VehiclePlanDto vehiclePlanDto) {
return vehicleBiz.getVehicle(vehiclePlanDto);
}
/**
* 热门车型
*
* @param dto
* @return
*/
@ApiOperation("热门车型")
@RequestMapping(value = "/rent/hot-vehicle", method = RequestMethod.GET)
@IgnoreUserToken
public ObjectRestResponse<PageDataVO<UsableVehicleModelVO>> hotVehicle(HotVeicleDTO dto) throws Exception {
return ObjectRestResponse.succ(vehicleBiz.hotModel(dto));
}
/**
* 租车触发的申请预定车辆
*
* @param dto
* @return
*/
@ApiOperation("租车触发的申请预定车辆")
@RequestMapping(value = "/rent/book/vehicle", method = RequestMethod.POST)
@IgnoreClientToken
@IgnoreUserToken
public ObjectRestResponse<VehicleBookRecord> rentApplyVehicle(@RequestBody RentVehicleBookDTO dto) throws Exception {
//默认USER_APP 预约
Integer operatorId = USER_APP;
String userName = dto.getUserName();
//BaseContextHandler.getName();
dto.setLimit(1);
dto.setPage(1);
//查询可车辆信息
PageDataVO<Vehicle> pageDataVO = vehicleBiz.searchUsableVehicle(dto);
if (pageDataVO.getData().size() <= 0) {
throw new BaseException(ResultCode.NOTEXIST_CODE, new HashSet<String>(){{
add("可用车辆不存在");
}});
}
dto.setBookStartDate(dto.getBookStartDate()+ " 00:00:00");
dto.setBookEndDate(dto.getBookEndDate()+ " 23:59:59");
BookVehicleVO bookVehicleVo = BeanUtil.toBean(dto, BookVehicleVO.class);
bookVehicleVo.setBookType(BookType.USER_RENT.getCode());
bookVehicleVo.setVehicleId(pageDataVO.getData().get(0).getId());
bookVehicleVo.setStatus(VehicleBookRecordStatus.APPLY.getCode());
VehicleBookRecord vehicleBookRecord = baseBiz.applyVehicle(operatorId, bookVehicleVo, userName);
return ObjectRestResponse.succ(vehicleBookRecord);
}
@RequestMapping(value = "/app/unauth/getVehiclePlanList", method = RequestMethod.GET)
@ApiOperation(value = "获取排车信息")
@IgnoreClientToken
......
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