Commit 9a521569 authored by jiaorz's avatar jiaorz

修改租車訂單地址,修改车辆预定时添加订单号

parent db119a26
......@@ -53,6 +53,7 @@ public enum ResCode {
ORDER_DETAIL_IS_NOT_EXIST(10001, "订单详情不可查询"),
YOU_AUTH_FAIL(-2,"无权限查看此信息"),
ORDER_IS_NOT_PAY(10002, "订单未支付"),
USER_IS_EXIST(10003, "用户名已存在");
;
/**
* 返回码
......
......@@ -2,9 +2,9 @@ package com.xxfc.platform.vehicle.biz;
import com.alibaba.fastjson.JSON;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.xxfc.platform.vehicle.common.CustomIllegalParamException;
import com.xxfc.platform.vehicle.constant.ConstantType;
import com.xxfc.platform.vehicle.constant.RedisKey;
import com.xxfc.platform.vehicle.entity.Constant;
......@@ -159,7 +159,7 @@ public class ConstantBiz extends BaseBiz<ConstantMapper,Constant> {
return Boolean.FALSE;
}
if(constants.size()>MAX_BATCH_SIZE_CONSTANT_UPDATE){
throw new IllegalArgumentException(" exceed max batch size");
throw new BaseException(" exceed max batch size");
}
return Boolean.TRUE;
......@@ -198,7 +198,7 @@ public class ConstantBiz extends BaseBiz<ConstantMapper,Constant> {
return 0;
}
if(codes.size()>MAX_BATCH_SIZE_CONSTANT_UPDATE){
throw new IllegalArgumentException(" exceed max batch size");
throw new BaseException(" exceed max batch size");
}
List<String> delCodes = Lists.newArrayList();
for(Integer code:codes){
......@@ -242,12 +242,12 @@ public class ConstantBiz extends BaseBiz<ConstantMapper,Constant> {
*/
public Boolean checkIfExists(Integer type,Integer code){
if(!ConstantType.exists(type)){
throw new CustomIllegalParamException(" no such type of constant");
throw new BaseException(" no such type of constant");
}
List<ConstantVo> constantVoList = getAllConstantByType(type);
if(CollectionUtils.isEmpty(constantVoList)){
throw new CustomIllegalParamException(" no such code of constant in relative type");
throw new BaseException(" no such code of constant in relative type");
}
for(ConstantVo constantVo:constantVoList){
......@@ -255,7 +255,7 @@ public class ConstantBiz extends BaseBiz<ConstantMapper,Constant> {
return Boolean.TRUE;
}
}
throw new CustomIllegalParamException(" no such code of constant in relative type");
throw new BaseException(" no such code of constant in relative type");
}
}
......@@ -3,8 +3,8 @@ package com.xxfc.platform.vehicle.biz;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.google.common.collect.Lists;
import com.xxfc.platform.vehicle.common.CustomIllegalParamException;
import com.xxfc.platform.vehicle.constant.RedisKey;
import com.xxfc.platform.vehicle.constant.RegionType;
import com.xxfc.platform.vehicle.entity.SysRegion;
......@@ -42,7 +42,7 @@ public class SysRegionBiz extends BaseBiz<SysRegionMapper, SysRegion> {
public List<SysRegion> getRegionsByCodes(List<Long> ids){
List<String> redisCacheKeys = Lists.newArrayList();
if(CollectionUtils.isEmpty(ids)){
throw new CustomIllegalParamException("empty id list");
throw new BaseException("empty id list");
}
for(Long id:ids){
redisCacheKeys.add(RedisKey.SYS_REGION_CACHE_PREFIX+id);
......
......@@ -208,7 +208,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
public RestResponse add(List<AddOrUpdateVehicleVo> addOrUpdateVehicleVoList) throws Exception{
if(addOrUpdateVehicleVoList.size()>MAX_BATCH_SIZE_VEHICLE){
throw new CustomIllegalParamException("添加的车辆数量过多!");
throw new BaseException(ResultCode.ADD_VEHICLE_MORE);
}
for(AddOrUpdateVehicleVo addOrUpdateVehicleVo:addOrUpdateVehicleVoList) {
......@@ -217,7 +217,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
BeanUtilsBean.getInstance().copyProperties(vehicle, addOrUpdateVehicleVo);
if (addOrUpdateVehicleVo.getParkBranchCompanyId()==null) {
throw new CustomIllegalParamException("停靠公司不能为空");
throw new BaseException(ResultCode.RET_COMPANY_CAN_NOT_BE_NULL);
}
vehicle.setId(UUID.randomUUID().toString());
......@@ -251,7 +251,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
// }
if(addOrUpdateVehicleVo.getNumberPlate() == null){
throw new CustomIllegalParamException("车牌不能为空");
throw new BaseException(ResultCode.NUMBER_PLAT_CAN_NOT_BE_NULL);
}
List<Vehicle> vehicles = mapper.lockByCode(addOrUpdateVehicleVo);
return vehicles;
......@@ -265,14 +265,14 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
@Transactional
public RestResponse update(List<AddOrUpdateVehicleVo> addOrUpdateVehicleVoList) throws Exception{
if(addOrUpdateVehicleVoList.size()>MAX_BATCH_SIZE_VEHICLE){
throw new CustomIllegalParamException("exceed max batch size");
throw new BaseException(ResultCode.ADD_VEHICLE_MORE);
}
for(AddOrUpdateVehicleVo addOrUpdateVehicleVo:addOrUpdateVehicleVoList){
Vehicle vehicle = new Vehicle();
BeanUtilsBean.getInstance().copyProperties(vehicle, addOrUpdateVehicleVo);
if (addOrUpdateVehicleVo.getParkBranchCompanyId()==null) {
throw new CustomIllegalParamException("Stop at branch office cannot be empty");
throw new BaseException(ResultCode.RET_COMPANY_CAN_NOT_BE_NULL);
}
//悲观锁,检查是否已存在车牌或编码
......@@ -305,7 +305,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
*/
public RestResponse discard(List<String> idList){
if(idList.size()>MAX_BATCH_SIZE_VEHICLE){
throw new CustomIllegalParamException("exceed max batch size");
throw new BaseException(ResultCode.ADD_VEHICLE_MORE);
}
Map<String,Object> params = Maps.newHashMap();
params.put("idList",idList);
......@@ -341,7 +341,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
//转换日期范围为列表,并检查是否合法
fillDateList4DatePeriod(yearMonthAndDate,startDay,endDay);
if(yearMonthAndDate.size()>3){//连续的日期最多夸3个月
throw new CustomIllegalParamException(" you can only within 2 month");
throw new BaseException(ResultCode.ONLY_BOOK_TWO_MONTH);
}
for(Map.Entry<String,List<String>> entry:yearMonthAndDate.entrySet()){
Boolean rsEach = applyVehicle4EmployeePerMonth(bookVehicleVo.getVehicleId(),entry.getValue(),entry.getKey());
......@@ -427,7 +427,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
//转换日期范围为列表,并检查是否合法
fillDateList4DatePeriod(yearMonthAndDate,startDay,endDay);
if(yearMonthAndDate.size()>3){//连续的日期最多夸3个月
throw new CustomIllegalParamException(" 只可以预约两个月内的车辆");
throw new BaseException(ResultCode.ONLY_BOOK_TWO_MONTH);
}
//检查车辆是否可以预定
for(Map.Entry<String,List<String>> entry:yearMonthAndDate.entrySet()){
......@@ -470,7 +470,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
//修改相关车辆预定记录
Boolean hasSuc = bookedVehicle(bookVehicleVo);
if(!hasSuc){
throw new BaseException("车辆预定失败");
throw new BaseException(ResultCode.BOOKED_FAILED_CODE);
}
//添加随车物品
......@@ -511,7 +511,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
//转换日期范围为列表,并检查是否合法
fillDateList4DatePeriod(yearMonthAndDate,startDay,endDay);
if(yearMonthAndDate.size()>3){//连续的日期最多夸3个月
throw new CustomIllegalParamException(" 只可以预约两个月内的车辆");
throw new BaseException(ResultCode.ONLY_BOOK_TWO_MONTH);
}
for(Map.Entry<String,List<String>> entry:yearMonthAndDate.entrySet()){
Boolean rsEach = applyVehicle4EmployeePerMonth(bookVehicleVo.getVehicleId(),entry.getValue(),entry.getKey());
......@@ -607,7 +607,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
VehicleBookRecord vehicleBookRecord = vehicleBookRecordBiz.selectById(bookRecordId);
//申请记录验证
if(vehicleBookRecord == null){
throw new CustomIllegalParamException(" invalid book record");
return RestResponse.codeAndMessage(ResCode.VEHICLE_BOOK_RECORD_IS_NOT_EXIST.getCode(), ResCode.VEHICLE_BOOK_RECORD_IS_NOT_EXIST.getDesc());
}
if(!VehicleBookRecordStatus.APPLY.getCode().equals(vehicleBookRecord.getStatus())){
return RestResponse.code(ResCode.VEHICLE_BOOKED_RECORD_ALREADY_CHANGED.getCode());
......@@ -663,7 +663,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
VehicleBookRecord vehicleBookRecord = vehicleBookRecordBiz.selectById(bookRecordId);
//申请记录验证
if(vehicleBookRecord == null){
throw new CustomIllegalParamException(" invalid book record");
return RestResponse.codeAndMessage(ResCode.VEHICLE_BOOK_RECORD_IS_NOT_EXIST.getCode(), ResCode.VEHICLE_BOOK_RECORD_IS_NOT_EXIST.getDesc());
}
//已通过审核的可以取消预定
if(!VehicleBookRecordStatus.APPROVE.getCode().equals(vehicleBookRecord.getStatus())){
......@@ -679,7 +679,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
//取消预定
Boolean hasSuc = unbookVehicle(bookVehicleVo);
if(!hasSuc){
throw new IllegalArgumentException(" invalid book record ");
return RestResponse.codeAndMessage(ResCode.VEHICLE_BOOK_RECORD_IS_NOT_EXIST.getCode(), ResCode.VEHICLE_BOOK_RECORD_IS_NOT_EXIST.getDesc());
}
//修改预定状态,写入取消人
Map<String,Object> updateParam = Maps.newHashMap();
......@@ -751,7 +751,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
//转换日期范围为列表,并检查是否合法
fillDateList4DatePeriod(yearMonthAndDate,startDay,endDay);
if(yearMonthAndDate.size()>3){//连续的日期最多夸3个月
throw new CustomIllegalParamException(" 只可以预约两个月内的车辆");
throw new BaseException(ResultCode.ONLY_BOOK_TWO_MONTH);
}
Boolean rs = Boolean.TRUE;
for(Map.Entry<String,List<String>> entry:yearMonthAndDate.entrySet()){
......@@ -789,7 +789,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
params.put("yearMonth",yearMonth);
//加入更新条件
if(CollectionUtils.isEmpty(bookedDates)){
throw new CustomIllegalParamException(" there are no day to book");
throw new BaseException(ResultCode.BOOKED_DATE_IS_EMPTY);
}
Map<String,List<String>> yearMonthAndDate = new HashMap<>();
yearMonthAndDate.put(vehicleBookInfo.getYearMonth(),bookedDates);
......@@ -1043,10 +1043,10 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
Map<String,List<String>> yearMonthAndDateNotBooked = new HashMap<>();//未预定年月 - 未预定日期列表
classifyByYearMonth(notBookedDates,yearMonthAndDateNotBooked,allYearMonth);
if(allYearMonth.size()>0 && params.get("subordinateBranch") == null){
throw new CustomIllegalParamException(" <subordinateBranch> must included in params while using <bookedInfo> param. ");
throw new BaseException(" <subordinateBranch> must included in params while using <bookedInfo> param. ");
}
if(allYearMonth.size()>MAX_MONTH_COUNT_BOOKED_INFO_QUERY){
throw new CustomIllegalParamException(" only 3 month can be included <bookedInfo> param.");
throw new BaseException(" only 3 month can be included <bookedInfo> param.");
}
//加入预定信息查询条件
fillBookedDateSearchParam(params,yearMonthAndDate,yearMonthAndDateNotBooked);
......
......@@ -3,10 +3,10 @@ package com.xxfc.platform.vehicle.biz;
import com.ace.cache.annotation.Cache;
import com.ace.cache.annotation.CacheClear;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
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.google.common.collect.Maps;
import com.xxfc.platform.vehicle.common.CustomIllegalParamException;
import com.xxfc.platform.vehicle.constant.ResCode.ResCode;
import com.xxfc.platform.vehicle.entity.VehicleBookHourInfo;
import com.xxfc.platform.vehicle.mapper.VehicleBookHourInfoMapper;
......@@ -39,15 +39,15 @@ public class VehicleBookHourInfoBiz extends BaseBiz<VehicleBookHourInfoMapper, V
startDate = simpleDateFormat.parse(bookStartDate);
endDate = simpleDateFormat.parse(bookEndDate);
}catch (Exception e) {
e.printStackTrace();
}
//判定时间是否合法
if (bookStartDate.compareTo(DateTime.now().toString(DEFAULT_DATE_TIME_FORMATTER)) < 0) {
throw new CustomIllegalParamException(ResultCode.getMsg(ResultCode.ONLY_BOOK_FROM_TODAY));
throw new BaseException(ResultCode.ONLY_BOOK_FROM_TODAY);
}
if (bookStartDate.compareTo(bookEndDate) > 0) {
throw new CustomIllegalParamException("预定开始日期不能大于结束日期!");
throw new BaseException(ResultCode.ONLY_BOOK_FROM_TODAY);
}
Map<String, Integer> predictableHours = Maps.newHashMap();
//预定开始小时
......
......@@ -12,7 +12,6 @@ import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
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.RedisKey;
......@@ -273,7 +272,7 @@ public class VehicleBookRecordBiz extends BaseBiz<VehicleBookRecordMapper, Vehic
if(params.get("selectedMonth") != null) {
String selectedMonth = (String)params.get("selectedMonth");
if(StringUtils.isBlank(selectedMonth)){
throw new CustomIllegalParamException(" no month selected ");
throw new BaseException("no month selected ");
}
DateTime selectedMonthDate = DateTime.parse(selectedMonth,YEARMONTH_DATE_TIME_FORMATTER);
if(selectedMonthDate.compareTo(DateTime.now().plusMonths(-1).withDayOfMonth(1).withMillisOfDay(0)) < 0){
......
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