定点、到站回收订单业务功能bug问题修复v2

door
LI-CCONG\李聪聪 7 months ago
parent 0452b91596
commit e3001bc043

@ -0,0 +1,17 @@
package cc.yunxi.common.exception;
// 业务异常类
public class BusinessLogicException extends CommonException{
public BusinessLogicException(String message) {
super(message, 410);
}
public BusinessLogicException(String message, Throwable cause) {
super(message, cause, 410);
}
public BusinessLogicException(Throwable cause) {
super(cause, 410);
}
}

@ -297,7 +297,7 @@ public class RecycleOrderController {
Collectors.toMap(ClientAddressSimpleVO::getId, v -> v, (k1, k2) -> k1)); Collectors.toMap(ClientAddressSimpleVO::getId, v -> v, (k1, k2) -> k1));
orderRespVOList.forEach(v -> { orderRespVOList.forEach(v -> {
String clientAddressId = (String) CommonUtil.obtainField(v, "clientAddressId"); String clientAddressId = (String) CommonUtil.obtainField(v, "clientAddressId");
CommonUtil.assignField(v, "clientAddressId", clientAddressId); CommonUtil.assignField(v, "addressInfo", clientAddressMap.get(clientAddressId));
}); });
} }
} }

@ -2,6 +2,7 @@ package cc.yunxi.service.impl;
import cc.yunxi.common.domain.LambdaQueryWrapperX; import cc.yunxi.common.domain.LambdaQueryWrapperX;
import cc.yunxi.common.exception.BizIllegalException; import cc.yunxi.common.exception.BizIllegalException;
import cc.yunxi.common.exception.BusinessLogicException;
import cc.yunxi.common.exception.ForbiddenException; import cc.yunxi.common.exception.ForbiddenException;
import cc.yunxi.common.utils.BeanUtils; import cc.yunxi.common.utils.BeanUtils;
import cc.yunxi.common.utils.CommonUtil; import cc.yunxi.common.utils.CommonUtil;
@ -140,7 +141,7 @@ public class RecycleOrderServiceImpl extends ServiceImpl<RecycleOrderMapper, Rec
Client client = clientService.getClientById(orderCreateVO.getClientId()); Client client = clientService.getClientById(orderCreateVO.getClientId());
RecycleOrder limitOrder = this.limitOrder(client.getId(), OrderTypeEnum.SH_ORDER); RecycleOrder limitOrder = this.limitOrder(client.getId(), OrderTypeEnum.SH_ORDER);
if (ObjectUtil.isNotEmpty(limitOrder)) { if (ObjectUtil.isNotEmpty(limitOrder)) {
throw new BizIllegalException("您有一笔正在进行中的预约回收订单!"); throw new BusinessLogicException("您有一笔正在进行中的预约回收订单!");
} }
// 判断下单地址和回收站的距离 // 判断下单地址和回收站的距离
LocationDTO location = orderCreateVO.getLocation(); LocationDTO location = orderCreateVO.getLocation();
@ -149,7 +150,7 @@ public class RecycleOrderServiceImpl extends ServiceImpl<RecycleOrderMapper, Rec
recycleStation.getLongitude(), recycleStation.getLatitude()); recycleStation.getLongitude(), recycleStation.getLatitude());
BigDecimal acceptRange = new BigDecimal(recycleStation.getAcceptRange()); BigDecimal acceptRange = new BigDecimal(recycleStation.getAcceptRange());
if (acceptRange.compareTo(distance) < 0) { if (acceptRange.compareTo(distance) < 0) {
throw new BizIllegalException("超出回收站接单范围!"); throw new BusinessLogicException("超出回收站接单范围!");
} }
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
// 创建订单 // 创建订单
@ -189,13 +190,13 @@ public class RecycleOrderServiceImpl extends ServiceImpl<RecycleOrderMapper, Rec
Client client = clientService.getClientById(tmOrderCreateVO.getClientId()); Client client = clientService.getClientById(tmOrderCreateVO.getClientId());
RecycleOrder limitOrder = this.limitOrder(client.getId(), OrderTypeEnum.TM_RECOVERY); RecycleOrder limitOrder = this.limitOrder(client.getId(), OrderTypeEnum.TM_RECOVERY);
if (ObjectUtil.isNotEmpty(limitOrder)) { if (ObjectUtil.isNotEmpty(limitOrder)) {
throw new BizIllegalException("您有一笔正在进行中的定点回收订单!"); throw new BusinessLogicException("您有一笔正在进行中的定点回收订单!");
} }
String idNumber = CommonUtil.getIdNumber(BusinessCodeEnum.ORDER.getCode()); String idNumber = CommonUtil.getIdNumber(BusinessCodeEnum.ORDER.getCode());
String housingEstateId = tmOrderCreateVO.getHousingEstateId(); String housingEstateId = tmOrderCreateVO.getHousingEstateId();
HousingEstate housingInfo = housingEstateService.getHousingInfo(housingEstateId); HousingEstate housingInfo = housingEstateService.getHousingInfo(housingEstateId);
if (housingInfo.getHasSchedule() != 1 || StrUtil.isEmpty(housingInfo.getStationId())) { if (housingInfo.getHasSchedule() != 1 || StrUtil.isEmpty(housingInfo.getStationId())) {
throw new BizIllegalException("该小区不支持定点回收或未绑定回收站点!"); throw new ForbiddenException("该小区不支持定点回收或未绑定回收站点!");
} }
// 创建订单 // 创建订单
RecycleOrder recycleOrder = BeanUtils.copyBean(tmOrderCreateVO, RecycleOrder.class); RecycleOrder recycleOrder = BeanUtils.copyBean(tmOrderCreateVO, RecycleOrder.class);
@ -220,11 +221,11 @@ public class RecycleOrderServiceImpl extends ServiceImpl<RecycleOrderMapper, Rec
Client client = clientService.getClientByMobile(dzOrderCreateVO.getClientMobile()); Client client = clientService.getClientByMobile(dzOrderCreateVO.getClientMobile());
RecycleOrder limitOrder = this.limitOrder(client.getId(), OrderTypeEnum.DZ_RECOVERY); RecycleOrder limitOrder = this.limitOrder(client.getId(), OrderTypeEnum.DZ_RECOVERY);
if (ObjectUtil.isNotEmpty(limitOrder)) { if (ObjectUtil.isNotEmpty(limitOrder)) {
throw new BizIllegalException("您有一笔正在进行中的到站回收订单!"); throw new BusinessLogicException("您有一笔正在进行中的到站回收订单!");
} }
Recycler recycler = recyclerService.getRecyclerById(dzOrderCreateVO.getRecyclerId()); Recycler recycler = recyclerService.getRecyclerById(dzOrderCreateVO.getRecyclerId());
if (StrUtil.isEmpty(recycler.getStationId())) { if (StrUtil.isEmpty(recycler.getStationId())) {
throw new BizIllegalException("警告,该回收员未绑定回收站点!"); throw new ForbiddenException("警告,该回收员未绑定回收站点!");
} }
// 创建订单 // 创建订单
String orderNo = CommonUtil.getIdNumber(BusinessCodeEnum.ORDER.getCode()); String orderNo = CommonUtil.getIdNumber(BusinessCodeEnum.ORDER.getCode());
@ -252,7 +253,7 @@ public class RecycleOrderServiceImpl extends ServiceImpl<RecycleOrderMapper, Rec
PriceProduct latestPriceProduct = this.recycleOrderProductService.getLatestPriceProduct(rp.getProductId()); PriceProduct latestPriceProduct = this.recycleOrderProductService.getLatestPriceProduct(rp.getProductId());
log.info("latest price product: {}", latestPriceProduct); log.info("latest price product: {}", latestPriceProduct);
if (ObjectUtil.isEmpty(latestPriceProduct)) { if (ObjectUtil.isEmpty(latestPriceProduct)) {
throw new BizIllegalException("产品价格信息未公布,请联系商户!"); throw new BusinessLogicException("产品价格信息未公布,请联系商户!");
} }
BigDecimal recoveryPrice = Optional.ofNullable(latestPriceProduct.getRecoveryPrice()).orElse(new BigDecimal("0.00")); BigDecimal recoveryPrice = Optional.ofNullable(latestPriceProduct.getRecoveryPrice()).orElse(new BigDecimal("0.00"));
rp.setActualRecoveryPrice(recoveryPrice); rp.setActualRecoveryPrice(recoveryPrice);
@ -281,7 +282,7 @@ public class RecycleOrderServiceImpl extends ServiceImpl<RecycleOrderMapper, Rec
RecycleOrder recycleOrder = this.getOrderById(orderUpdateVO.getId()); RecycleOrder recycleOrder = this.getOrderById(orderUpdateVO.getId());
// 接单后无法修改订单信息 // 接单后无法修改订单信息
if (!recycleOrder.getOrderStatus().equals(OrderStatusEnum.PENDING)) { if (!recycleOrder.getOrderStatus().equals(OrderStatusEnum.PENDING)) {
throw new BizIllegalException("订单处理中,无法修改订单信息"); throw new BusinessLogicException("订单处理中,无法修改订单信息");
} }
recycleOrder = BeanUtils.copyBean(orderUpdateVO, RecycleOrder.class); recycleOrder = BeanUtils.copyBean(orderUpdateVO, RecycleOrder.class);
recycleOrder.setUpdateTime(LocalDateTime.now()); recycleOrder.setUpdateTime(LocalDateTime.now());
@ -295,9 +296,9 @@ public class RecycleOrderServiceImpl extends ServiceImpl<RecycleOrderMapper, Rec
RecycleOrder recycleOrder = this.getOrderById(orderTakingVO.getId()); RecycleOrder recycleOrder = this.getOrderById(orderTakingVO.getId());
if (!recycleOrder.getOrderStatus().equals(OrderStatusEnum.PENDING)) { if (!recycleOrder.getOrderStatus().equals(OrderStatusEnum.PENDING)) {
if (recycleOrder.getOrderStatus().equals(OrderStatusEnum.CANCELED)) { if (recycleOrder.getOrderStatus().equals(OrderStatusEnum.CANCELED)) {
throw new BizIllegalException("订单已取消!"); throw new BusinessLogicException("订单已取消!");
} }
throw new BizIllegalException("订单处理中,无法接单"); throw new BusinessLogicException("订单处理中,无法接单");
} }
recycleOrder = BeanUtils.copyBean(orderTakingVO, RecycleOrder.class); recycleOrder = BeanUtils.copyBean(orderTakingVO, RecycleOrder.class);
recycleOrder.setOrderStatus(OrderStatusEnum.UNPROCESSED); recycleOrder.setOrderStatus(OrderStatusEnum.UNPROCESSED);
@ -305,7 +306,7 @@ public class RecycleOrderServiceImpl extends ServiceImpl<RecycleOrderMapper, Rec
log.info("recycleOrder takingVO: {}", recycleOrder); log.info("recycleOrder takingVO: {}", recycleOrder);
boolean takingResult = this.updateById(recycleOrder); boolean takingResult = this.updateById(recycleOrder);
if (!takingResult) { if (!takingResult) {
throw new BizIllegalException("该订单已被接单!"); throw new BusinessLogicException("该订单已被接单!");
} }
} }
@ -314,10 +315,10 @@ public class RecycleOrderServiceImpl extends ServiceImpl<RecycleOrderMapper, Rec
public void cancelOrder(RecycleOrderCancelVO orderCancelVO) { public void cancelOrder(RecycleOrderCancelVO orderCancelVO) {
RecycleOrder recycleOrder = getOrderById(orderCancelVO.getId()); RecycleOrder recycleOrder = getOrderById(orderCancelVO.getId());
if (!recycleOrder.getClientId().equals(orderCancelVO.getClientId())) { if (!recycleOrder.getClientId().equals(orderCancelVO.getClientId())) {
throw new BizIllegalException("非法操作!"); throw new ForbiddenException("非法操作!");
} }
if (recycleOrder.getOrderStatus().equals(OrderStatusEnum.FINISHED)) { if (recycleOrder.getOrderStatus().equals(OrderStatusEnum.FINISHED)) {
throw new BizIllegalException("订单已完成!"); throw new BusinessLogicException("订单已完成!");
} }
recycleOrder = BeanUtils.copyBean(orderCancelVO, RecycleOrder.class); recycleOrder = BeanUtils.copyBean(orderCancelVO, RecycleOrder.class);
; ;
@ -334,14 +335,14 @@ public class RecycleOrderServiceImpl extends ServiceImpl<RecycleOrderMapper, Rec
public void reachOrder(RecycleOrderReachVO orderReachVO) { public void reachOrder(RecycleOrderReachVO orderReachVO) {
RecycleOrder recycleOrder = getOrderById(orderReachVO.getId()); RecycleOrder recycleOrder = getOrderById(orderReachVO.getId());
if (!recycleOrder.getStaffsId().equals(orderReachVO.getStaffsId())) { if (!recycleOrder.getStaffsId().equals(orderReachVO.getStaffsId())) {
throw new BizIllegalException("非法操作!"); throw new ForbiddenException("非法操作!");
} }
// 判断是否到达 // 判断是否到达
LocationDTO location = orderReachVO.getLocation(); LocationDTO location = orderReachVO.getLocation();
BigDecimal distance = CommonUtil.getDistance(recycleOrder.getLongitude(), recycleOrder.getLatitude(), BigDecimal distance = CommonUtil.getDistance(recycleOrder.getLongitude(), recycleOrder.getLatitude(),
location.getLongitude(), location.getLatitude()); location.getLongitude(), location.getLatitude());
if (distance.compareTo(new BigDecimal("0.1")) > 0) { // 大于0.1km if (distance.compareTo(new BigDecimal("0.1")) > 0) { // 大于0.1km
throw new BizIllegalException("未到达!"); throw new BusinessLogicException("未到达!");
} }
recycleOrder = BeanUtils.copyBean(orderReachVO, RecycleOrder.class); recycleOrder = BeanUtils.copyBean(orderReachVO, RecycleOrder.class);
; ;
@ -357,10 +358,10 @@ public class RecycleOrderServiceImpl extends ServiceImpl<RecycleOrderMapper, Rec
public void finishOrder(RecycleOrderFinishVO orderFinishVO) { public void finishOrder(RecycleOrderFinishVO orderFinishVO) {
RecycleOrder recycleOrder = getOrderById(orderFinishVO.getId()); RecycleOrder recycleOrder = getOrderById(orderFinishVO.getId());
if (!recycleOrder.getStaffsId().equals(orderFinishVO.getStaffsId())) { if (!recycleOrder.getStaffsId().equals(orderFinishVO.getStaffsId())) {
throw new BizIllegalException("非法操作!"); throw new ForbiddenException("非法操作!");
} }
if (recycleOrder.getOrderStatus().equals(OrderStatusEnum.FINISHED)) { if (recycleOrder.getOrderStatus().equals(OrderStatusEnum.FINISHED)) {
throw new BizIllegalException("订单已完成结算!"); throw new BusinessLogicException("订单已完成结算!");
} }
// 更新订单明细信息 // 更新订单明细信息
List<RecycleOrderDetailUpdateVO> recycleOrderProductVOList = orderFinishVO.getOrderDetails(); List<RecycleOrderDetailUpdateVO> recycleOrderProductVOList = orderFinishVO.getOrderDetails();
@ -369,7 +370,7 @@ public class RecycleOrderServiceImpl extends ServiceImpl<RecycleOrderMapper, Rec
PriceProduct latestPriceProduct = this.recycleOrderProductService.getLatestPriceProduct(rp.getProductId()); PriceProduct latestPriceProduct = this.recycleOrderProductService.getLatestPriceProduct(rp.getProductId());
log.info("latest price product: {}", latestPriceProduct); log.info("latest price product: {}", latestPriceProduct);
if (ObjectUtil.isEmpty(latestPriceProduct)) { if (ObjectUtil.isEmpty(latestPriceProduct)) {
throw new BizIllegalException("产品价格信息未公布,请联系商户!"); throw new BusinessLogicException("产品价格信息未公布,请联系商户!");
} }
BigDecimal recoveryPrice = Optional.ofNullable(latestPriceProduct.getRecoveryPrice()).orElse(new BigDecimal("0.00")); BigDecimal recoveryPrice = Optional.ofNullable(latestPriceProduct.getRecoveryPrice()).orElse(new BigDecimal("0.00"));
rp.setActualRecoveryPrice(recoveryPrice); rp.setActualRecoveryPrice(recoveryPrice);

Loading…
Cancel
Save