Commit 568a1155 authored by 周健威's avatar 周健威

添加代码

parent adf59238
......@@ -231,4 +231,12 @@ public class SpecialRent implements Serializable {
@Column(name = "goods_json")
@ApiModelProperty(value = "商品信息json")
private String goodsJson;
@Column(name = "brand_name")
@ApiModelProperty("品牌名称")
private String brandName;
@Column(name = "category_name")
@ApiModelProperty("型号名称")
private String categoryName;
}
package com.xxfc.platform.order.biz;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.admin.feign.dto.UserDTO;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.AssertUtils;
import com.github.wxiaoqi.security.common.util.OrderUtil;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.xxfc.platform.order.entity.BaseOrder;
import com.xxfc.platform.order.pojo.order.RentVehicleBO;
import com.xxfc.platform.order.service.OrderRentVehicleService;
import com.xxfc.platform.vehicle.entity.Vehicle;
import com.xxfc.platform.vehicle.entity.VehicleCategory;
import com.xxfc.platform.vehicle.feign.VehicleFeign;
import com.xxfc.platform.vehicle.pojo.BookVehicleVO;
import com.xxfc.platform.vehicle.pojo.CompanyDetail;
import org.mockito.internal.util.collections.Sets;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.xxfc.platform.order.entity.SpecialRent;
import com.xxfc.platform.order.mapper.SpecialRentMapper;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
import static com.github.wxiaoqi.security.common.constant.CommonConstants.SYS_FALSE;
import static com.xxfc.platform.order.entity.SpecialRent.STATUS_CRT;
import static com.xxfc.platform.vehicle.entity.Vehicle.STATE_DOWN;
/**
* 特惠租车
*
......@@ -19,6 +45,16 @@ import java.util.List;
@Service
public class SpecialRentBiz extends BaseBiz<SpecialRentMapper, SpecialRent> {
@Autowired
OrderRentVehicleService orderRentVehicleService;
@Autowired
UserFeign userFeign;
@Autowired
VehicleFeign vehicleFeign;
/**
* 判断车辆是否有进行中的特惠租车
* @param vehicleId
......@@ -36,4 +72,102 @@ public class SpecialRentBiz extends BaseBiz<SpecialRentMapper, SpecialRent> {
}
return Boolean.FALSE;
}
/**
* 添加发布特惠租车
* @param specialRent
* @param userDTO
*/
public void addRent(@RequestBody SpecialRent specialRent, UserDTO userDTO) {
AssertUtils.isBlank(userDTO);
if(StrUtil.isBlank(specialRent.getVehicleId())) {
throw new BaseException(ResultCode.PARAM_ILLEGAL_CODE);
}
Vehicle vehicle = vehicleFeign.get(specialRent.getVehicleId()).getData();
if(null == vehicle) {
throw new BaseException(ResultCode.PARAM_ILLEGAL_CODE);
}
//判断车辆是否下架、是否已经存在一个特惠租车
if(STATE_DOWN == vehicle.getStatus() || checkHasSpecialRent(vehicle.getId())) {
throw new BaseException(ResultCode.PARAM_ILLEGAL_CODE);
}
//设置当前经营门店为停靠门店、品牌id、型号id
specialRent.setStartCompanyId(vehicle.getManageCompanyId());
specialRent.setBrandId(vehicle.getBrandId());
specialRent.setCategoryId(vehicle.getCategoryId());
//缓存商品信息
specialRent.setGoodsJson(JSONUtil.parse(vehicle).toString());
DateTime startDateTime = DateUtil.date(specialRent.getStartTime());
// DateTime endDateTime = DateUtil.date(sFpecialRent.getEndTime());
// DateTime tomorrowBegin = DateUtil.beginOfDay(DateUtil.tomorrow());
DateTime afterDateTime = DateUtil.offsetHour(DateUtil.date(), 1);
if(!startDateTime.isAfterOrEquals(afterDateTime)) {
throw new BaseException(ResultCode.FAILED_CODE, Sets.newSet("请提前一小时特惠租车发布"));
}
if(null != specialRent.getStartCompanyId()) {
CompanyDetail companyDetail = vehicleFeign.getCompanyDetail(specialRent.getStartCompanyId()).getData();
specialRent.setStartCompanyName(companyDetail.getName());
specialRent.setStartCityCode(companyDetail.getAddrCity());
}
if(null != specialRent.getEndCompanyId()) {
CompanyDetail companyDetail = vehicleFeign.getCompanyDetail(specialRent.getEndCompanyId()).getData();
specialRent.setEndCompanyName(companyDetail.getName());
specialRent.setEndCityCode(companyDetail.getAddrCity());
}
if(null != specialRent.getEndCompanyId()) {
CompanyDetail companyDetail = vehicleFeign.getCompanyDetail(specialRent.getEndCompanyId()).getData();
specialRent.setEndCompanyName(companyDetail.getName());
specialRent.setEndCityCode(companyDetail.getAddrCity());
}
if(null != specialRent.getCategoryId()) {
VehicleCategory vehicleCategory = vehicleFeign.getVehicleCategory(specialRent.getEndCompanyId()).getData();
specialRent.setBrandName(vehicleCategory.getBrandName());
specialRent.setCategoryName(vehicleCategory.getName());
}
specialRent.setPublishUserId(userDTO.getId());
specialRent.setStatus(STATUS_CRT);
RentVehicleBO detail = new RentVehicleBO();
detail.setStartTime(specialRent.getStartTime());
detail.setEndTime(specialRent.getEndTime());
detail.setVehicleId(specialRent.getVehicleId());
detail.setStartAddr(specialRent.getStartCompanyName());
detail.setStartCompanyId(specialRent.getStartCompanyId());
detail.setEndCompanyId(specialRent.getEndCompanyId());
detail.setOrder(new BaseOrder(){{setNo(OrderUtil.GetOrderNumber("", OrderUtil.APP_MID));}});
detail.setRentFreeDay(SYS_FALSE);
detail.setBookVehicleVO(new BookVehicleVO(){{
setBookStartDate(DateUtil.date(specialRent.getStartTime()).toDateStr());
setBookEndDate(DateUtil.date(specialRent.getEndTime()).toDateStr());
setBookStartDateTime(DateUtil.date(specialRent.getStartTime()).toString());
setBookEndDateTime(DateUtil.date(specialRent.getEndTime()).toString());
}});
//预约车辆
orderRentVehicleService.acquireVehicle(detail, null , null);
specialRent.setOrderNo(detail.getOrder().getNo());
// specialRent.setOverTime(DateUtil.offsetHour(DateUtil.date(), 1).getTime());
specialRent.setBookRecordId(detail.getBookRecordId());
//设置车辆下架
ObjectRestResponse restResponse = vehicleFeign.updVehicleFeign(new Vehicle(){{
setId(vehicle.getId());
setState(STATE_DOWN);
}});
// rabbitProduct.sendApplyDelayMessage(baseBiz.selectById(specialRent.getId()), 1000L * 3601L);
// Long delayTime = DateUtil.date().getTime() - DateUtil.offsetDay(endDateTime, -1).getTime();
// specialRent.setOverTime(delayTime);
insertSelective(specialRent);
// rabbitProduct.sendApplyRequireDelayMessage(baseBiz.selectById(shuntApply.getId()), delayTime);
}
}
\ No newline at end of file
package com.xxfc.platform.order.rest;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
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;
......@@ -40,7 +42,7 @@ import static com.xxfc.platform.order.entity.SpecialRent.STATUS_CRT;
import static com.xxfc.platform.vehicle.entity.Vehicle.STATE_DOWN;
@RestController
@RequestMapping("specialRent")
@RequestMapping("/chw/specialRent")
public class SpecialRentController extends BaseController<SpecialRentBiz, SpecialRent> implements UserRestInterface {
@Autowired
......@@ -65,85 +67,30 @@ public class SpecialRentController extends BaseController<SpecialRentBiz, Specia
@RequestMapping(value = "/appBusiness/addRent", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "添加特惠租车")
@ApiOperation(value = "添加发布特惠租车")
public ObjectRestResponse appBusinessAddRent(@RequestBody SpecialRent specialRent) {
UserDTO userDTO = getBusinessUserByAppUser();
AssertUtils.isBlank(userDTO);
if(StrUtil.isNotBlank(specialRent.getVehicleId())) {
throw new BaseException(ResultCode.PARAM_ILLEGAL_CODE);
}
Vehicle vehicle = vehicleFeign.get(specialRent.getVehicleId()).getData();
if(null == vehicle) {
throw new BaseException(ResultCode.PARAM_ILLEGAL_CODE);
}
baseBiz.addRent(specialRent, userDTO);
//判断车辆是否下架、是否已经存在一个特惠租车
if(STATE_DOWN == vehicle.getStatus() || baseBiz.checkHasSpecialRent(vehicle.getId())) {
throw new BaseException(ResultCode.PARAM_ILLEGAL_CODE);
}
specialRent.setGoodsJson(JSONUtil.parse(vehicle).toString());
DateTime startDateTime = DateUtil.date(specialRent.getStartTime());
// DateTime endDateTime = DateUtil.date(specialRent.getEndTime());
// DateTime tomorrowBegin = DateUtil.beginOfDay(DateUtil.tomorrow());
DateTime afterDateTime = DateUtil.offsetHour(DateUtil.date(), 1);
if(!startDateTime.isAfterOrEquals(afterDateTime)) {
throw new BaseException(ResultCode.FAILED_CODE, Sets.newSet("请提前一小时特惠租车发布"));
}
if(null != specialRent.getStartCompanyId()) {
specialRent.setStartCityCode(vehicleFeign.getCompanyDetail(specialRent.getStartCompanyId()).getData().getAddrCity());
}
if(null != specialRent.getEndCompanyId()) {
specialRent.setEndCityCode(vehicleFeign.getCompanyDetail(specialRent.getEndCompanyId()).getData().getAddrCity());
}
specialRent.setPublishUserId(userDTO.getId());
specialRent.setStatus(STATUS_CRT);
RentVehicleBO detail = new RentVehicleBO();
detail.setStartTime(specialRent.getStartTime());
detail.setEndTime(specialRent.getEndTime());
detail.setVehicleId(specialRent.getVehicleId());
detail.setStartAddr(specialRent.getStartCompanyName());
detail.setStartCompanyId(specialRent.getStartCompanyId());
detail.setEndCompanyId(specialRent.getEndCompanyId());
detail.setOrder(new BaseOrder(){{setNo(OrderUtil.GetOrderNumber("", OrderUtil.APP_MID));}});
detail.setRentFreeDay(SYS_FALSE);
detail.setBookVehicleVO(new BookVehicleVO(){{
setBookStartDate(DateUtil.date(specialRent.getStartTime()).toDateStr());
setBookEndDate(DateUtil.date(specialRent.getEndTime()).toDateStr());
setBookStartDateTime(DateUtil.date(specialRent.getStartTime()).toString());
setBookEndDateTime(DateUtil.date(specialRent.getEndTime()).toString());
}});
return ObjectRestResponse.succ();
}
//预约车辆
orderRentVehicleService.acquireVehicle(detail, null , null);
@RequestMapping(value = "/appBusiness/cnlRent", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "取消发布特惠租车")
public ObjectRestResponse appBusinessCnlRent(@RequestBody SpecialRent specialRent) {
UserDTO userDTO = getBusinessUserByAppUser();
specialRent.setOrderNo(detail.getOrder().getNo());
// specialRent.setOverTime(DateUtil.offsetHour(DateUtil.date(), 1).getTime());
specialRent.setBookRecordId(detail.getBookRecordId());
//设置车辆下架
ObjectRestResponse restResponse = vehicleFeign.updVehicleFeign(new Vehicle(){{
setId(vehicle.getId());
setStatus(STATE_DOWN);
//拒绝原来的预约
orderRentVehicleService.errorRejectVehicle(new RentVehicleBO(){{
setBookRecordId(specialRent.getBookRecordId());
}});
// rabbitProduct.sendApplyDelayMessage(baseBiz.selectById(specialRent.getId()), 1000L * 3601L);
// Long delayTime = DateUtil.date().getTime() - DateUtil.offsetDay(endDateTime, -1).getTime();
// specialRent.setOverTime(delayTime);
baseBiz.insertSelective(specialRent);
// rabbitProduct.sendApplyRequireDelayMessage(baseBiz.selectById(shuntApply.getId()), delayTime);
return ObjectRestResponse.succ();
}
@RequestMapping(value = "/pageList", method = RequestMethod.GET)
@RequestMapping(value = "/appBusiness/pageList", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "分页查询可参加特惠租车")
public ObjectRestResponse<SpecialRentVO> pageList(QueryDTO dto) {
......@@ -161,7 +108,7 @@ public class SpecialRentController extends BaseController<SpecialRentBiz, Specia
return ObjectRestResponse.succ(pages);
}
@RequestMapping(value = "/specialOrder", method = RequestMethod.POST)
@RequestMapping(value = "/appBusiness/specialOrder", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "特惠租车下单")
public ObjectRestResponse specialOrder(@RequestBody SpecialOrderDTO dto) {
......@@ -226,7 +173,14 @@ public class SpecialRentController extends BaseController<SpecialRentBiz, Specia
@Data
public static class SpecialRentVO extends SpecialRent{
Vehicle vehicle;
@Override
public void setGoodsJson(String goodsJson) {
super.setGoodsJson(goodsJson);
if(StrUtil.isNotBlank(goodsJson)) {
setVehicle(JSONUtil.toBean(goodsJson, Vehicle.class));
super.setGoodsJson(null);
}
}
}
@Data
......
package com.xxfc.platform.order.rest.background;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
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.IgnoreUserToken;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
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.process.ResultCode;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.github.wxiaoqi.security.common.vo.PageParam;
import com.xxfc.platform.order.biz.OrderRentVehicleBiz;
import com.xxfc.platform.order.biz.SpecialRentBiz;
import com.xxfc.platform.order.entity.BaseOrder;
import com.xxfc.platform.order.entity.SpecialRent;
import com.xxfc.platform.order.mqhandler.RabbitProduct;
import com.xxfc.platform.order.pojo.order.RentVehicleBO;
import com.xxfc.platform.order.pojo.order.add.AddRentVehicleDTO;
import com.xxfc.platform.order.service.OrderRentVehicleService;
import com.xxfc.platform.vehicle.entity.Vehicle;
import com.xxfc.platform.vehicle.feign.VehicleFeign;
import com.xxfc.platform.vehicle.pojo.BookVehicleVO;
import io.swagger.annotations.ApiOperation;
import lombok.Data;
import org.mockito.internal.util.collections.Sets;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import static com.github.wxiaoqi.security.common.constant.CommonConstants.SYS_FALSE;
import static com.xxfc.platform.order.entity.SpecialRent.STATUS_CRT;
import static com.xxfc.platform.vehicle.entity.Vehicle.STATE_DOWN;
@RestController
@RequestMapping("/background/specialRent")
public class BgSpecialRentController extends BaseController<SpecialRentBiz, SpecialRent> implements UserRestInterface {
@Autowired
RabbitProduct rabbitProduct;
@Autowired
OrderRentVehicleBiz orderRentVehicleBiz;
@Autowired
OrderRentVehicleService orderRentVehicleService;
@Autowired
VehicleFeign vehicleFeign;
@Autowired
UserFeign userFeign;
@Override
public UserFeign getUserFeign() {
return userFeign;
}
@RequestMapping(value = "/business/addRent", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "添加特惠租车")
public ObjectRestResponse businessAddRent(@RequestBody SpecialRent specialRent) {
UserDTO userDTO = getAdminUserInfoV2();
baseBiz.addRent(specialRent, userDTO);
return ObjectRestResponse.succ();
}
}
\ No newline at end of file
......@@ -28,7 +28,7 @@ public class FileUploadServiceImpl implements FileUploadService {
private String xx_url ;
private static final String APK_SUFFIX=".apk";
private static final String APK_NAME="xxfc.apk";
private static final String APK_NAME="chw.apk";
private static final String JPG=".jpg";
private static final String PNG=".png";
......
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