Commit 191cf7e1 authored by libin's avatar libin

Merge branch 'master' into user-thrid-authorization

parents 97dbf7c2 6c1d788d
......@@ -8,6 +8,7 @@ public enum DeductionTypeEnum {
VIOLATE_CANCEL(101, "提前取消违约金"),
VIOLATE_ADVANCE(102, "提前还车违约金"),
VIOLATE_DELAY(103, "延迟还车违约金"),
VIOLATE_CHANGE_C(104, "更换还车公司费用"),
CONSUME(201, "消费金额"),
DAMAGES(301, "赔偿金(定损)"),
VIOLATE_TRAFFIC_DEDUCT(401, "违章扣款"),
......
......@@ -7,6 +7,7 @@ import java.util.Map;
public enum OrderViolateEnum {
BEFORE(1, "提前"),
AFTER(2, "延期"),
CHANGE(3, "更换还车公司"),
;
/**
* 编码
......
......@@ -32,7 +32,7 @@ public class DedDetailDTO {
//作为:DedDetail :2、车辆损坏 3、其他
//作为:violate_amount_detail 1--提前还车 2--延期还车 3--消费超额
//作为:violate_amount_detail 1--提前还车 2--延期还车 3--更换还车公司费用
Integer type;
//小雨都不知道什么东西
......
......@@ -2,6 +2,7 @@ package com.xxfc.platform.order.pojo.order;
import com.xxfc.platform.order.entity.*;
import com.xxfc.platform.order.pojo.DedDetailDTO;
import com.xxfc.platform.vehicle.entity.BookRecordUpdateLog;
import com.xxfc.platform.vehicle.entity.VehicleUserLicense;
import lombok.Data;
......@@ -21,6 +22,9 @@ public class OrderPageVO extends BaseOrder {
List<VehicleUserLicense> vehicleUserLicenses;
//更换还车公司记录
List<BookRecordUpdateLog> bookRecordUpdateLogs;
/**
* 用户名
*/
......
......@@ -4,7 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONArray;
import com.github.wxiaoqi.security.admin.dto.UserMemberDTO;
import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO;
......@@ -16,17 +16,15 @@ import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
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.google.common.collect.Lists;
import com.google.gson.JsonObject;
import com.xxfc.platform.activity.feign.ActivityFeign;
import com.xxfc.platform.order.biz.inner.OrderCalculateBiz;
import com.xxfc.platform.order.biz.inner.OrderMsgBiz;
import com.xxfc.platform.order.contant.enumerate.*;
import com.xxfc.platform.order.entity.*;
import com.xxfc.platform.order.mapper.BaseOrderMapper;
import com.xxfc.platform.order.pojo.account.OrderAccountDetail;
import com.xxfc.platform.order.pojo.DedDetailDTO;
import com.xxfc.platform.order.pojo.account.OrderAccountDetail;
import com.xxfc.platform.order.pojo.calculate.InProgressVO;
import com.xxfc.platform.order.pojo.mq.OrderMQDTO;
import com.xxfc.platform.order.pojo.order.OrderListVo;
......@@ -48,6 +46,7 @@ import com.xxfc.platform.vehicle.entity.Vehicle;
import com.xxfc.platform.vehicle.entity.VehicleUserLicense;
import com.xxfc.platform.vehicle.feign.VehicleFeign;
import com.xxfc.platform.vehicle.pojo.CompanyDetail;
import com.xxfc.platform.vehicle.util.DistanceUtil;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
......@@ -57,15 +56,16 @@ import org.joda.time.format.DateTimeFormatter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
import static com.github.wxiaoqi.security.common.config.rabbit.RabbitConstant.*;
import static com.github.wxiaoqi.security.common.constant.CommonConstants.*;
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.APP_ORDER;
import static com.xxfc.platform.universal.constant.DictionaryKey.ILLEGAL_TYPE;
/**
* @author zjw
......@@ -315,8 +315,57 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> implements
initDedDetail(dedDetailDTO, OrderViolateEnum.AFTER.getCode(), cost, stringBuilder);
}
}
orderPageVO.setDedDetailDTO(JSONObject.toJSONString(dedDetailDTO));
JSONArray jsonArray = new JSONArray();
if ((dedDetailDTO.getCost() != null && dedDetailDTO.getCost().doubleValue() != 0) || (dedDetailDTO.getExcessCost()!=null && dedDetailDTO.getExcessCost().doubleValue() != 0)) {
jsonArray.add(dedDetailDTO);
}
DedDetailDTO dedDetailDTO1 = new DedDetailDTO();
//添加更改还车公司计算费用
if (orderPageVO.getOrderRentVehicleDetail() != null && orderPageVO.getOrderRentVehicleDetail().getBookRecordId() != null) {
//查询是否有更换还车记录
List<BookRecordUpdateLog> bookRecordUpdateLogs = vehicleFeign.get(orderPageVO.getOrderRentVehicleDetail().getBookRecordId()).getData();
if(bookRecordUpdateLogs != null && bookRecordUpdateLogs.size() > 0) {
orderPageVO.setBookRecordUpdateLogs(bookRecordUpdateLogs);
//有更换记录,则需要计算更换费用
//原始公司经纬度,列表中最后一个 bookRecordUpdateLogs.get(bookRecordUpdateLogs.size -1 ) 最后还车公司是列表中的第一条中的getNewRetCompanyId
BookRecordUpdateLog oldCompany = bookRecordUpdateLogs.get(bookRecordUpdateLogs.size() -1);
BookRecordUpdateLog newCompany = bookRecordUpdateLogs.get(0);
if (oldCompany != null && newCompany != null) {
CompanyDetail oldCompanyDetail = vehicleFeign.getCompanyDetail(oldCompany.getOldRetCompanyId()).getData();
CompanyDetail newCompanyDetail = vehicleFeign.getCompanyDetail(newCompany.getNewRetCompanyId()).getData();
if (oldCompanyDetail.getLatitude() != null && oldCompanyDetail.getLongitude() != null && newCompanyDetail.getLongitude() != null && newCompanyDetail.getLatitude() != null) {
//根据经纬度获取两个公司的距离
double distance = DistanceUtil.getDistance(oldCompanyDetail.getLongitude().doubleValue(), oldCompanyDetail.getLatitude().doubleValue(), newCompanyDetail.getLongitude().doubleValue(), newCompanyDetail.getLatitude().doubleValue());
log.info("两个公司的距离为(米): {}", distance);
BigDecimal distanceNum = new BigDecimal(distance + "").divide(new BigDecimal("1000"), 0, BigDecimal.ROUND_UP);
//取出费用计算的单价
Map<String, Dictionary> dictionaryMap = thirdFeign.dictionaryGetAll4Map().getData();
BigDecimal illegalReserve = new BigDecimal(dictionaryMap.get(ILLEGAL_TYPE + "_" + DictionaryKey.ILLEGAL_FEE_PRICE).getDetail());
BigDecimal totalCost = distanceNum.multiply(illegalReserve);
log.info("更换两个公司的总费用为: {}", totalCost);
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(illegalReserve);
stringBuilder.append(" x ");
stringBuilder.append(distanceNum);
stringBuilder.append("(KM)");
stringBuilder.append(" = ");
stringBuilder.append(totalCost);
stringBuilder.append("元");
dedDetailDTO1.setCost(totalCost);
initDedDetail(dedDetailDTO1, OrderViolateEnum.CHANGE.getCode(), totalCost, stringBuilder);
}
}
}
}
if (dedDetailDTO1.getCost() != null && dedDetailDTO1.getCost().doubleValue() != 0) {
jsonArray.add(dedDetailDTO1);
}
orderPageVO.setDedDetailDTO(jsonArray.toJSONString());
}
public void initDedDetail(DedDetailDTO dedDetailDTO, Integer type, BigDecimal cost, StringBuilder stringBuilder) {
String detailName = null;
if (type == OrderViolateEnum.BEFORE.getCode()) {
......@@ -325,6 +374,9 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> implements
} else if (type == OrderViolateEnum.AFTER.getCode()) {
dedDetailDTO.setType(OrderViolateEnum.AFTER.getCode());
detailName = "延期还车违约金";
} else if (type == OrderViolateEnum.CHANGE.getCode()) {
dedDetailDTO.setType(OrderViolateEnum.CHANGE.getCode());
detailName = "更换还车公司";
}
//900元+违约金(¥900x2天=)1800元
dedDetailDTO.setDeductions(stringBuilder.toString());
......
......@@ -481,12 +481,18 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
private void handleCrosstownDetail(OrderVehicleCrosstown crosstown, OrderAccountDetail oad, CancelStartedVO csv) {
try{
if(null != crosstown.getViolateDetail()) {
DedDetailDTO vio = JSONUtil.toBean(crosstown.getViolateDetail(), DedDetailDTO.class);
if(OrderViolateEnum.BEFORE.getCode().equals(vio.getType())) {
handleViolateDetail(DeductionTypeEnum.VIOLATE_ADVANCE, oad, vio, csv);
}else if(OrderViolateEnum.AFTER.getCode().equals(vio.getType())) {
handleViolateDetail(DeductionTypeEnum.VIOLATE_DELAY, oad, vio, csv);
//修改代码
List<DedDetailDTO> vios = JSONUtil.toList(JSONUtil.parseArray(crosstown.getViolateDetail()), DedDetailDTO.class);
//DedDetailDTO vio = JSONUtil.toBean(crosstown.getViolateDetail(), DedDetailDTO.class);
for(DedDetailDTO vio : vios) {
if(OrderViolateEnum.BEFORE.getCode().equals(vio.getType())) {
handleViolateDetail(DeductionTypeEnum.VIOLATE_ADVANCE, oad, vio, csv);
}else if(OrderViolateEnum.AFTER.getCode().equals(vio.getType())) {
handleViolateDetail(DeductionTypeEnum.VIOLATE_DELAY, oad, vio, csv);
}else if(OrderViolateEnum.CHANGE.getCode().equals(vio.getType())) {
handleViolateDetail(DeductionTypeEnum.VIOLATE_CHANGE_C, oad, vio, csv);
}
}
}
}catch (Exception e) {
......@@ -495,6 +501,7 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
}
private void handleViolateDetail(DeductionTypeEnum dte, OrderAccountDetail oad, DedDetailDTO vio, CancelStartedVO csv) {
Boolean flag = Boolean.FALSE;
for(OrderAccountDeduction deduction : oad.getDeductions()) {
if(dte.getCode().equals(deduction.getType())) {
deduction.setName(vio.getDeductions());
......@@ -504,10 +511,24 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
deduction.setAmount(vio.getCost());
//设置订单明细参数
csv.setViolateAmount(deduction.getAmount());
csv.setViolateDesc(deduction.getName());
csv.setViolateAmount(csv.getViolateAmount().add(diff));
csv.setViolateDesc(csv.getViolateDesc()+ deduction.getName());
flag = Boolean.TRUE;
break;
}
}
//如果没有修改,则添加
if(Boolean.FALSE.equals(flag)) {
OrderAccountDeduction oadNew = initDeduction(vio.getCost(), vio.getDeductions(), dte, OrderAccountDeduction.ORIGIN_DEPOSIT);
oad.getDeductions().add(oadNew);
//修改归还押金金额
oad.setDepositAmount(oad.getDepositAmount().subtract(oadNew.getAmount()));
//设置订单明细参数
csv.setViolateAmount(csv.getViolateAmount().add(oadNew.getAmount()));
csv.setViolateDesc(csv.getViolateDesc()+ oadNew.getName());
}
}
......
......@@ -12,7 +12,6 @@ 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.xxfc.platform.activity.user.UserInfoBiz;
import com.xxfc.platform.order.biz.inner.OrderCalculateBiz;
import com.xxfc.platform.order.biz.inner.OrderMsgBiz;
import com.xxfc.platform.order.contant.enumerate.CrosstownTypeEnum;
import com.xxfc.platform.order.contant.enumerate.DepositRefundStatus;
......@@ -35,7 +34,6 @@ import com.xxfc.platform.vehicle.pojo.VehicleDepartureVo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.map.HashedMap;
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;
......@@ -184,16 +182,19 @@ public class OrderVehicleCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp
return ObjectRestResponse.createFailedResult(3503, "无收车权限");
}
}
Vehicle vehicle = null;
RestResponse<Vehicle> vehicleRestResponse = vehicleFeign.findById(orderRentVehicleDetail.getVehicleId());
log.info("获取车辆信息返回消息:{}", vehicleRestResponse.getMessage());
if (vehicleRestResponse.getData() != null) {
vehicle = vehicleRestResponse.getData();
}
if (vehicle == null) {
return ObjectRestResponse.createFailedResult(ResCode.VEHICLE_DEPARTURE_VEHICLE_UNEXIST.getCode(), ResCode.VEHICLE_DEPARTURE_VEHICLE_UNEXIST.getDesc());
}
// if (vehicle.getStatus().equals(VehicleStatus.DEPARTURE.getCode())) {
// return ObjectRestResponse.createFailedResult(ResCode.VEHICLE_DEPARTURE_VEHICLE_DISABLE.getCode(), ResCode.VEHICLE_DEPARTURE_VEHICLE_DISABLE.getDesc());
// }
if (baseOrder.getStatus() != -1) {
Vehicle vehicle = null;
RestResponse<Vehicle> restResponse = vehicleFeign.findById(orderRentVehicleDetail.getVehicleId());
log.info("获取车辆信息返回消息:{}", restResponse.getMessage());
if (restResponse.getData() != null) {
vehicle = restResponse.getData();
}
if (vehicle == null) {
return ObjectRestResponse.createFailedResult(ResCode.VEHICLE_DEPARTURE_VEHICLE_UNEXIST.getCode(), ResCode.VEHICLE_DEPARTURE_VEHICLE_UNEXIST.getDesc());
}
if (vehicle.getMileageLastUpdate() != null) {
//判断车辆公里数
if (orderVehicleCrosstownDto.getMileage() == null || orderVehicleCrosstownDto.getMileage() < vehicle.getMileageLastUpdate()) {
......@@ -264,13 +265,16 @@ public class OrderVehicleCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp
}
//延期扣除费用
if (StringUtils.isNotBlank(orderVehicleCrosstownDto.getViolateDetail())) {
JSONObject jsonObject = JSONObject.parseObject(orderVehicleCrosstownDto.getViolateDetail());
if (jsonObject != null) {
if (jsonObject.getString("cost") != null) {
cost += Double.parseDouble(jsonObject.getString("cost"));
}
if (jsonObject.getString("excessCost") != null) {
cost += Double.parseDouble(jsonObject.getString("excessCost"));
JSONArray jsonArray = JSONArray.parseArray(orderVehicleCrosstownDto.getViolateDetail());
if(jsonArray != null && jsonArray.size() > 0) {
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject jsonObject = JSONObject.parseObject(jsonArray.get(i).toString());
if (jsonObject.getString("cost") != null) {
cost += Double.parseDouble(jsonObject.getString("cost"));
}
if (jsonObject.getString("excessCost") != null) {
cost += Double.parseDouble(jsonObject.getString("excessCost"));
}
}
}
}
......
......@@ -289,6 +289,15 @@ public class OrderCancelBiz {
//站点总人数减少
tourFeign.updateTourGoodPersonNum(otd.getVerificationId(), TourFeign.TOTAL_PERSON, (otd.getTotalNumber() * -1));
//已付款的取消订单发送消息
try {
AppUserDTO appUserDTO = userFeign.userDetailById(baseOrder.getUserId()).getData();
//处理后台用户提醒短信的发送
orderMsgBiz.handelMsgCancel(orvd, otd, omd, baseOrder, appUserDTO);
}catch (Exception e) {
log.error(e.getMessage(), e);
}
}
}
......
......@@ -326,7 +326,7 @@ public class OrderMsgBiz {
//后台发送消息(客服)
Cofig cofig = configFeign.getAllByType(ConfigFeign.TYPE_CUS_SER+ "").getData().get(0);
smsParams.clear();
sms2BgUser(cofig.getValue(), startCompanyDetailTour, null, orvd, otd, baseOrder, appUserDTO, SmsTemplateDTO.PAY_C, smsParams);
sms2BgUser(cofig.getValue(), startCompanyDetailTour, null, orvd, otd, baseOrder, appUserDTO, SmsTemplateDTO.CANCEL_F, smsParams);
break;
case MEMBER:
break;
......@@ -577,10 +577,14 @@ public class OrderMsgBiz {
smsParams.add(startCompanyDetail.getAddrDetail());
break;
case SmsTemplateDTO.PAY_J :
String realName = appUserDTO.getRealname();
if(StrUtil.isBlank(realName)){
realName = "";
}
if(SYS_TRUE.equals(appUserDTO.getIsMember()) && !NONE.getCode().equals(appUserDTO.getMemberLevel()) ) {
smsParams.add(USER_M+ appUserDTO.getRealname());
smsParams.add(USER_M+ realName);
}else {
smsParams.add(USER_N+ appUserDTO.getRealname());
smsParams.add(USER_N+ realName);
}
smsParams.add(baseOrder.getName());
smsParams.add(HOUR_MINUTE_FORMATTE_HUTOOL.format(DateUtil.date(otd.getStartTime())));
......@@ -684,7 +688,11 @@ public class OrderMsgBiz {
smsParams.add(orvd.getDayNum().toString());
break;
case SmsTemplateDTO.PAY_H :
smsParams.add(appUserDTO.getRealname());
String realName = appUserDTO.getRealname();
if(StrUtil.isBlank(realName)){
realName = "匿名";
}
smsParams.add(realName);
smsParams.add(appUserDTO.getUsername());
smsParams.add(baseOrder.getName());
smsParams.add(sCompany.getName());
......@@ -692,7 +700,11 @@ public class OrderMsgBiz {
smsParams.add(DateUtil.formatDateTime(DateUtil.date(otd.getStartTime())));
break;
case SmsTemplateDTO.CANCEL_F :
smsParams.add(appUserDTO.getRealname());
String realName2 = appUserDTO.getRealname();
if(StrUtil.isBlank(realName2)){
realName2 = "匿名";
}
smsParams.add(realName2);
smsParams.add(appUserDTO.getUsername());
smsParams.add(baseOrder.getName());
smsParams.add(sCompany.getName());
......
package com.xxfc.platform.uccn.rest;
import com.github.pagehelper.PageInfo;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.campsite.vo.CampsiteShopPageVo;
import com.xxfc.platform.tour.entity.TourGood;
import com.xxfc.platform.uccn.biz.SearchBiz;
import com.xxfc.platform.uccn.comstnt.ServiceConstant;
import com.xxfc.platform.uccn.entity.Article;
import com.xxfc.platform.uccn.vo.SearchResultVo;
import com.xxfc.platform.uccn.vo.ServiceResultVo;
import com.xxfc.platform.uccn.vo.SummitActivityVo;
import com.xxfc.platform.vehicle.entity.BranchCompany;
import com.xxfc.platform.vehicle.pojo.VehicleModelQueryCondition;
import com.xxfc.platform.vehicle.pojo.VehicleModelVo;
import com.xxfc.platform.vehicle.pojo.dto.BranchCompanyFindDTO;
import com.xxfc.platform.vehicle.pojo.vo.BranchCompanyListVO;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* @author libin
* @version 1.0
......@@ -48,24 +60,74 @@ public class SearchController {
vehicleModelQueryCondition.setPage(page);
vehicleModelQueryCondition.setLimit(limit);
vehicleModelQueryCondition.setVehicleName(keyWord);
return vehicleModelController.findVehicleModelPageUnauthfind(vehicleModelQueryCondition);
ObjectRestResponse<PageDataVO<VehicleModelVo>> vehicleResult =vehicleModelController.findVehicleModelPageUnauthfind(vehicleModelQueryCondition);
List<VehicleModelVo> vehicleModelVoList = vehicleResult.getData().getData();
Long vehicleTotalCount = vehicleResult.getData().getTotalCount();
ServiceResultVo<VehicleModelVo> vehicleModelVoServiceResultVo = new ServiceResultVo<>();
vehicleModelVoServiceResultVo.setData(vehicleModelVoList);
vehicleModelVoServiceResultVo.setTotalCount(vehicleTotalCount);
SearchResultVo searchResultVo = new SearchResultVo();
searchResultVo.put(ServiceConstant.VEHICLE,vehicleModelVoServiceResultVo);
return ObjectRestResponse.succ(searchResultVo);
case ServiceConstant.BRANCH_COMPANY:
BranchCompanyFindDTO branchCompanyFindDTO = new BranchCompanyFindDTO();
branchCompanyFindDTO.setPage(page);
branchCompanyFindDTO.setLimit(limit);
branchCompanyFindDTO.setName(keyWord);
return branchCompanyController.listBranchCompanyWithPage(branchCompanyFindDTO);
ObjectRestResponse<PageDataVO> branchResult = branchCompanyController.listBranchCompanyWithPage(branchCompanyFindDTO);
List branchCompanyList = branchResult.getData().getData();
Long branchCompanyTotalCount = branchResult.getData().getTotalCount();
ServiceResultVo<BranchCompanyListVO> companyServiceResultVo = new ServiceResultVo<>();
companyServiceResultVo.setData(branchCompanyList);
companyServiceResultVo.setTotalCount(branchCompanyTotalCount);
SearchResultVo branchCompanyResultVo = new SearchResultVo();
branchCompanyResultVo.put(ServiceConstant.BRANCH_COMPANY,companyServiceResultVo);
return ObjectRestResponse.succ(branchCompanyResultVo);
case ServiceConstant.TROUR:
return gwTourController.getGoodList(page, limit, null, keyWord);
ObjectRestResponse goodresult = gwTourController.getGoodList(page, limit, null, keyWord);
PageDataVO<TourGood> data = (PageDataVO<TourGood>)goodresult.getData();
List<TourGood> tourGoodList = data.getData();
Long tourGoodTotalCount = data.getTotalCount();
ServiceResultVo<TourGood> tourGoodServiceResultVo = new ServiceResultVo<>();
tourGoodServiceResultVo.setData(tourGoodList);
tourGoodServiceResultVo.setTotalCount(tourGoodTotalCount);
SearchResultVo tourGoodSearchResult = new SearchResultVo();
tourGoodSearchResult.put(ServiceConstant.TROUR,tourGoodServiceResultVo);
return ObjectRestResponse.succ(tourGoodSearchResult);
case ServiceConstant.CAMPSITE:
return campsiteUccnController.findCampsiteShopPageByType(null, page, limit, keyWord);
ObjectRestResponse<PageDataVO<CampsiteShopPageVo>> campsiteResult = campsiteUccnController.findCampsiteShopPageByType(null, page, limit, keyWord);
List<CampsiteShopPageVo> campsiteShopPageVoList = campsiteResult.getData().getData();
Long campsiteTotalCount = campsiteResult.getData().getTotalCount();
ServiceResultVo<CampsiteShopPageVo> campsiteShopPageVoServiceResultVo = new ServiceResultVo<>();
campsiteShopPageVoServiceResultVo.setData(campsiteShopPageVoList);
campsiteShopPageVoServiceResultVo.setTotalCount(campsiteTotalCount);
SearchResultVo campsiteSearchResultVo = new SearchResultVo();
campsiteSearchResultVo.put(ServiceConstant.CAMPSITE,campsiteShopPageVoServiceResultVo);
return ObjectRestResponse.succ(campsiteSearchResultVo);
case ServiceConstant.NEWS:
return articleController.getArticleList(page, limit, null, keyWord);
ObjectRestResponse articleresult = articleController.getArticleList(page, limit, 1, keyWord);
PageInfo<Article> articlePageDataVO = (PageInfo<Article>)articleresult.getData();
List<Article> articleList = articlePageDataVO.getList();
Long articleTotalCount = articlePageDataVO.getTotal();
ServiceResultVo<Article> articleServiceResultVo = new ServiceResultVo<>();
articleServiceResultVo.setTotalCount(articleTotalCount);
articleServiceResultVo.setData(articleList);
SearchResultVo articleSearchResult= new SearchResultVo();
articleSearchResult.put(ServiceConstant.NEWS,articleServiceResultVo);
return ObjectRestResponse.succ(articleSearchResult);
case ServiceConstant.ACTIVITY:
return summitActivityController.findSummitActivityWithPage(page, limit, null, keyWord);
ObjectRestResponse<PageDataVO<SummitActivityVo>> summitActivityWithPage = summitActivityController.findSummitActivityWithPage(page, limit, null, keyWord);
List<SummitActivityVo> summitActivityVos = summitActivityWithPage.getData().getData();
Long summitTotalCount = summitActivityWithPage.getData().getTotalCount();
ServiceResultVo<SummitActivityVo> summitActivityVoServiceResultVo = new ServiceResultVo<>();
summitActivityVoServiceResultVo.setData(summitActivityVos);
summitActivityVoServiceResultVo.setTotalCount(summitTotalCount);
SearchResultVo summitActivitySearchResult = new SearchResultVo();
summitActivitySearchResult.put(ServiceConstant.ACTIVITY,summitActivityVoServiceResultVo);
return ObjectRestResponse.succ(summitActivitySearchResult);
default:
SearchResultVo searchResultVo = searchBiz.searchWithKeyWords(keyWord);
return ObjectRestResponse.succ(searchResultVo);
return ObjectRestResponse.succ(searchBiz.searchWithKeyWords(keyWord));
}
}
}
......@@ -7,6 +7,17 @@ public class DictionaryKey {
*/
public static final String APP_ORDER ="APP_ORDER";
/**
* 违约类型
*/
public static final String ILLEGAL_TYPE = "ILLEGAL_TYPE";
/**
* 更换还车公司费用计算单价
*/
public static final String ILLEGAL_FEE_PRICE = "ILLEGAL_FEE_PRICE";
/**
* IM类型
*/
......
......@@ -16,7 +16,8 @@ public enum BookType {
BOOKING(7,"预约中"),
DISABLE(8,"禁用"),
CUSTOMER_APPLY(9, "客户用车"),
OTHER(10, "其他")
OTHER(10, "其他"),
DISPATCH(11, "调度")
;
/**
* 编码
......
......@@ -49,6 +49,8 @@ public enum ResCode {
VEHICLE_UPKEEP_VEHICLE_DISABLE(106002,"车辆不可用"),
VEHICLE_UPKEEP_ITEM_UNEXIST(106003, "保养项目不存在"),
VEHICLE_UPKEEP_VEHICLE_UNUPKEEP(106004, "车辆不在保养中"),
VEHICLE_STATUS_IS_NOT_NORMAL(106005, "上次的出行未做收车操作, 请先收车"),
VEHICLE_IS_BOOKED_TODAY(106006, "车辆当前时段已经被预定"),
FIND_VEHICLE_PLAT_FAILE(106007, "获取车型列表失败"),
......
......@@ -52,4 +52,10 @@ public class BookRecordUpdateLog {
*/
@Column(name = "create_time")
private Date createTime;
@Transient
private String oldCompanyName;
@Transient
private String newCompanyName;
}
\ No newline at end of file
......@@ -172,4 +172,7 @@ public interface VehicleFeign {
@RequestMapping(value = "/vehicleInfo/bookRecord/update", method = RequestMethod.POST)
public ObjectRestResponse update(@RequestBody BookRecordUpdateLog bookRecordUpdateLog);
@GetMapping(value = "/bookRecord/get")
public ObjectRestResponse<List<BookRecordUpdateLog>> get(@RequestParam(value = "bookRecordId")Long bookRecordId);
}
package com.xxfc.platform.vehicle.util;
import java.awt.geom.Point2D;
import java.math.BigDecimal;
public class DistanceUtil {
private static final double EARTH_RADIUS = 6371393; // 平均半径,单位:m
/**
* 通过AB点经纬度获取距离
* @param pointA A点(经,纬)
* @param pointB B点(经,纬)
* @return 距离(单位:米)
*/
public static double getDistance(Point2D pointA, Point2D pointB) {
// 经纬度(角度)转弧度。弧度用作参数,以调用Math.cos和Math.sin
double radiansAX = Math.toRadians(pointA.getX()); // A经弧度
double radiansAY = Math.toRadians(pointA.getY()); // A纬弧度
double radiansBX = Math.toRadians(pointB.getX()); // B经弧度
double radiansBY = Math.toRadians(pointB.getY()); // B纬弧度
// 公式中“cosβ1cosβ2cos(α1-α2)+sinβ1sinβ2”的部分,得到∠AOB的cos值
double cos = Math.cos(radiansAY) * Math.cos(radiansBY) * Math.cos(radiansAX - radiansBX)
+ Math.sin(radiansAY) * Math.sin(radiansBY);
// System.out.println("cos = " + cos); // 值域[-1,1]
double acos = Math.acos(cos); // 反余弦值
// System.out.println("acos = " + acos); // 值域[0,π]
// System.out.println("∠AOB = " + Math.toDegrees(acos)); // 球心角 值域[0,180]
return EARTH_RADIUS * acos; // 最终结果
}
public static double getDistance(double longitude1, double latitude1, double longitude2, double latitude2) {
Point2D pointDD = new Point2D.Double(longitude1, latitude1);
// 北京 西单地铁站
Point2D pointXD = new Point2D.Double(longitude2, latitude2);
return getDistance(pointDD, pointXD);
}
public static void main(String[] args) {
// 北京 东单地铁站
Point2D pointDD = new Point2D.Double(113.906121, 22.985271);
// 北京 西单地铁站
Point2D pointXD = new Point2D.Double(114.42078, 23.05989);
System.out.println(getDistance(pointDD, pointXD));
BigDecimal distanceNum = new BigDecimal(getDistance(pointDD, pointXD) + "").divide(new BigDecimal("1000"), 0, BigDecimal.ROUND_UP);
BigDecimal bigDecimal = new BigDecimal(2);
System.out.println(distanceNum.multiply(bigDecimal));
}
}
......@@ -3,12 +3,20 @@ package com.xxfc.platform.vehicle.biz;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.xxfc.platform.vehicle.entity.BookRecordUpdateLog;
import com.xxfc.platform.vehicle.entity.BranchCompany;
import com.xxfc.platform.vehicle.mapper.BookRecordUpdateLogMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;
import java.util.List;
@Service
public class BookRecordUpdateLogBiz extends BaseBiz<BookRecordUpdateLogMapper, BookRecordUpdateLog> {
@Autowired
BranchCompanyBiz branchCompanyBiz;
public ObjectRestResponse save(BookRecordUpdateLog bookRecordUpdateLog) {
BookRecordUpdateLog oldValue = mapper.selectOne(bookRecordUpdateLog);
if (oldValue != null) {
......@@ -18,4 +26,22 @@ public class BookRecordUpdateLogBiz extends BaseBiz<BookRecordUpdateLogMapper, B
return ObjectRestResponse.succ();
}
public ObjectRestResponse<List<BookRecordUpdateLog>> selectByBookRecordId(Long bookRecordId) {
Example example = new Example(BookRecordUpdateLog.class);
example.createCriteria().andEqualTo("bookRecordId", bookRecordId);
example.setOrderByClause("create_time desc");
List<BookRecordUpdateLog> bookRecordUpdateLogs = selectByExample(example);
for (BookRecordUpdateLog bookRecordUpdateLog : bookRecordUpdateLogs) {
BranchCompany oldCompany = branchCompanyBiz.getById(bookRecordUpdateLog.getOldRetCompanyId());
if (oldCompany != null) {
bookRecordUpdateLog.setOldCompanyName(oldCompany.getName());
}
BranchCompany newCompany = branchCompanyBiz.getById(bookRecordUpdateLog.getNewRetCompanyId());
if (newCompany != null) {
bookRecordUpdateLog.setNewCompanyName(newCompany.getName());
}
}
return ObjectRestResponse.succ(bookRecordUpdateLogs);
}
}
......@@ -215,7 +215,9 @@ public class BranchCompanyBiz extends BaseBiz<BranchCompanyMapper, BranchCompany
@Cache(key = RedisKey.BRANCH_COMPANY_CACHE_ALL)
public List<BranchCompany> getAll() {
return mapper.selectAll();
Example example = new Example(BranchCompany.class);
example.createCriteria().andEqualTo("isDel", 0);
return mapper.selectByExample(example);
}
/**
......
......@@ -3,6 +3,7 @@ package com.xxfc.platform.vehicle.biz;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.xxfc.platform.vehicle.constant.*;
import com.xxfc.platform.vehicle.constant.ResCode.ResCode;
import com.xxfc.platform.vehicle.entity.*;
......@@ -59,7 +60,7 @@ public class VehicleActiveService {
*/
public void departure(VehicleDepartureVo departureVo) {
log.info("出车参数: departureVo = {}", departureVo.toString());
Vehicle vehicle = vehicleMapper.selectByPrimaryKey(departureVo.getVehicleId());
Vehicle vehicle = vehicleBiz.selectById(departureVo.getVehicleId());
if (vehicle == null) {
throw new BaseException(ResCode.VEHICLE_DEPARTURE_VEHICLE_UNEXIST.getDesc(),
ResCode.VEHICLE_DEPARTURE_VEHICLE_UNEXIST.getCode());
......@@ -68,9 +69,9 @@ public class VehicleActiveService {
throw new BaseException(ResCode.CHECKUSER_AND_PHONE_NOT_NULL.getDesc(),
ResCode.CHECKUSER_AND_PHONE_NOT_NULL.getCode());
}
if (vehicle.getStatus().equals(VehicleStatus.DISCARD.getCode()) || vehicle.getIsDel() == 1) {
throw new BaseException(ResCode.VEHICLE_DEPARTURE_VEHICLE_DISABLE.getDesc() + ", 车辆状态是:" + getVehicleStatus(vehicle.getStatus(), vehicle.getId()),
ResCode.VEHICLE_DEPARTURE_VEHICLE_DISABLE.getCode());
if (vehicle.getStatus().equals(VehicleStatus.DISCARD.getCode()) || vehicle.getIsDel() == 1 || vehicle.getStatus().equals(VehicleStatus.DEPARTURE.getCode())) {
throw new BaseException(ResCode.VEHICLE_STATUS_IS_NOT_NORMAL.getDesc(),
ResCode.VEHICLE_STATUS_IS_NOT_NORMAL.getCode());
}
//添加出车时间过滤 再出车开始时间前一天至结束时间内可以出车,并且预定记录为已审核状态
checkDateInvalid(departureVo);
......@@ -309,6 +310,10 @@ public class VehicleActiveService {
}
}
public void save(VehicleDepartureLog vehicleDepartureLog){
vehicleDepartureLogMapper.insertSelective(vehicleDepartureLog);
}
//添加出车时间过滤 再出车开始时间前一天至结束时间内可以出车,并且预定记录为已审核状态
public void checkDateInvalid(VehicleDepartureVo arrivalVo) {
if (arrivalVo.getBookRecordId() != null) {
......@@ -452,6 +457,17 @@ public class VehicleActiveService {
}
public ObjectRestResponse selectDepartureLogByBookRecordId(Long bookRecordId) {
if (bookRecordId == null) {
return ObjectRestResponse.paramIsEmpty();
}
VehicleDepartureLogVo vehicleDepartureLog = vehicleDepartureLogMapper.selectByBookRecordId(bookRecordId);
if (vehicleDepartureLog == null) {
return ObjectRestResponse.createFailedResult(ResCode.FIND_DATA_NOT_EXIST.getCode(), ResCode.FIND_DATA_NOT_EXIST.getDesc());
}
return ObjectRestResponse.succ(vehicleDepartureLog);
}
public static void main(String[] args) {
DateTime startDate = DateTime.parse("2019-08-21 17:00:00", DATE_TIME_FORMATTER);
......
......@@ -80,6 +80,9 @@ public class VehicleBookRecordBiz extends BaseBiz<VehicleBookRecordMapper, Vehic
@Autowired
BookRecordUpdateLogBiz bookRecordUpdateLogBiz;
@Autowired
VehicleActiveService vehicleActiveService;
@Override
public UserFeign getUserFeign() {
return userFeign;
......@@ -302,6 +305,38 @@ public class VehicleBookRecordBiz extends BaseBiz<VehicleBookRecordMapper, Vehic
return RestResponse.suc();
}
public ObjectRestResponse addBookRecord(VehicleBookRecord vehicleBookRecord) {
if (vehicleBookRecord == null) {
return ObjectRestResponse.paramIsEmpty();
}
save(vehicleBookRecord);
if (vehicleBookRecord != null) {
//添加交还车记录
VehicleDepartureLog vehicleDepartureLog = new VehicleDepartureLog();
vehicleDepartureLog.setBookRecordId(vehicleBookRecord.getId());
vehicleDepartureLog.setArrivalBranchCompanyId(vehicleBookRecord.getRetCompany());
vehicleDepartureLog.setArrivalRemark("后台修改停靠分公司,车辆调度");
vehicleDepartureLog.setArrivalTime(new Date());
vehicleDepartureLog.setCheckMan(vehicleBookRecord.getBookUserName());
vehicleDepartureLog.setCheckManTel(vehicleBookRecord.getBookUserName());
vehicleDepartureLog.setCreateTime(new Date());
vehicleDepartureLog.setDepartureBranchCompanyId(vehicleBookRecord.getLiftCompany());
vehicleDepartureLog.setDepartureRemark("后台修改停靠分公司,车辆调度");
vehicleDepartureLog.setDepartureTime(new Date());
vehicleDepartureLog.setRecycleMan(vehicleBookRecord.getBookUserName());
vehicleDepartureLog.setRecycleManTel(vehicleBookRecord.getBookUserName());
vehicleDepartureLog.setState(1);
vehicleDepartureLog.setVehicleId(vehicleBookRecord.getVehicleId());
vehicleDepartureLog.setUse("调度");
vehicleDepartureLog.setUser(vehicleBookRecord.getBookUserName());
vehicleDepartureLog.setUserTel(vehicleBookRecord.getBookUserName());
vehicleActiveService.save(vehicleDepartureLog);
}
return ObjectRestResponse.succ();
}
/**
* 按页查询
*
......
......@@ -6,6 +6,8 @@ import com.xxfc.platform.vehicle.entity.BookRecordUpdateLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/bookRecord")
public class BookRecordUpdateLogController {
......@@ -17,4 +19,10 @@ public class BookRecordUpdateLogController {
public ObjectRestResponse save(@RequestBody BookRecordUpdateLog bookRecordUpdateLog) {
return bookRecordUpdateLogBiz.save(bookRecordUpdateLog);
}
@GetMapping(value = "/get")
public ObjectRestResponse<List<BookRecordUpdateLog>> get(Long bookRecordId) {
return bookRecordUpdateLogBiz.selectByBookRecordId(bookRecordId);
}
}
package com.xxfc.platform.vehicle.rest;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.xxfc.platform.vehicle.biz.VehicleActiveService;
import com.xxfc.platform.vehicle.biz.VehicleBiz;
import com.xxfc.platform.vehicle.common.RestResponse;
import com.xxfc.platform.vehicle.constant.ResCode.ResCode;
import com.xxfc.platform.vehicle.pojo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
......@@ -19,7 +18,8 @@ public class VehicleActiveController {
@Autowired
VehicleActiveService vehicleActiveService;
@Autowired
VehicleBiz vehicleBiz;
/**
* 发车
......@@ -34,6 +34,7 @@ public class VehicleActiveController {
return RestResponse.codeAndMessage(ResCode.INVALID_REST_REQ_PARAM.getCode(),
ResCode.INVALID_REST_REQ_PARAM.getDesc());
}
vehicleActiveService.departure(departureVo);
return RestResponse.suc();
}
......@@ -91,6 +92,12 @@ public class VehicleActiveController {
}
@GetMapping("/getOne")
public ObjectRestResponse selectByRecordId(Long bookRecordId) {
return vehicleActiveService.selectDepartureLogByBookRecordId(bookRecordId);
}
/**
* 保养
......
......@@ -126,6 +126,11 @@ public class VehicleController extends BaseController<VehicleBiz> implements Use
return RestResponse.suc(vehicles);
}
@PostMapping(value = "/test")
public ObjectRestResponse test(@RequestBody VehicleBookRecord vehicleBookRecord) {
return vehicleBiz.addVehicleBookRecord(vehicleBookRecord);
}
@RequestMapping(value = "/page", method = RequestMethod.GET)
public RestResponse<PageDataVO<ResultVehicleVo>> getByPage(@RequestParam String vehiclePageQueryVoJson) throws Exception {
VehiclePageQueryVo vehiclePageQueryVo = null;
......@@ -480,6 +485,12 @@ public class VehicleController extends BaseController<VehicleBiz> implements Use
return ObjectRestResponse.succ(map);
}
@GetMapping(value = "/app/unauth/checkVehicleStatus")
@ApiOperation(value = "检车车辆状态是否是正常状态")
public ObjectRestResponse checkVehicleStatus(String vehicleId) {
return vehicleBiz.checkVehicleStatus(vehicleId);
}
/**
* 保存
*
......
......@@ -508,6 +508,15 @@
<if test="status != null and status == -1 ">
and v4.state = 1
</if>
<if test="status != null and status == 3 ">
and v4.id is null and v1.status = 2
</if>
<if test="status != null and status == 5 ">
and v4.id is not null and v1.status = 2 and v4.state = 0
</if>
<if test="status != null and status == 7 ">
and v4.id is not null and v1.status = 2 and v4.state = 1
</if>
<if test="code != null">
and v3.code = #{code}
</if>
......@@ -517,7 +526,7 @@
</if>
<!--增加时间限制,已审核的未出车小于当前时间的不显示, 已出车的结束时间延后两天小于当前时间的不显示-->
<if test="flag == true and status == 2">
and ( v4.id IS NOT NULL OR (v4.id IS NULL AND v1.book_end_date &gt;= now()))
and ( (v4.id IS NOT NULL and DATE_ADD(v1.book_end_date,INTERVAL '2' DAY) >= now()) OR (v4.id IS NULL AND v1.book_end_date &gt;= now()))
</if>
and v1.book_user != -2
</where>
......
......@@ -29,9 +29,11 @@
</select>
<select id="selectByBookRecordId" parameterType="java.lang.Long" resultType="com.xxfc.platform.vehicle.pojo.VehicleDepartureLogVo">
select vehicle_departure_log.*
from vehicle_departure_log
where vehicle_departure_log.book_record_id = #{id}
select v.*, bc.name as departureName,bc1.name as arrivalName
from vehicle_departure_log v
LEFT JOIN branch_company bc ON v.departure_branch_company_id = bc.id
LEFT JOIN branch_company bc1 ON v.arrival_branch_company_id = bc1.id
where v.book_record_id = #{id}
order by create_time desc
</select>
<select id="selectAllDepartureLog" resultType="java.lang.Integer" parameterType="Map">
......
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