提交 17ec5f5f authored 作者: huyufan's avatar huyufan

优化代码

上级 826f5dff
...@@ -55,7 +55,27 @@ public enum OwnerAccountEnum { ...@@ -55,7 +55,27 @@ public enum OwnerAccountEnum {
; ;
private final Integer code; private final Integer code;
private final String msg; private final String msg;
public String getMsg() {
return this.msg;
}
public Integer getCode() {
return this.code;
}
}
@Getter
@AllArgsConstructor
public enum OrderChildTypeStatus {
ORDINARY(1, "普通单"),
NETWORK(2, "网运单"),
;
private final Integer code;
private final String msg;
public Integer getCode() {
return this.code;
}
} }
@Getter @Getter
......
...@@ -16,5 +16,5 @@ public class ThawAccountParam { ...@@ -16,5 +16,5 @@ public class ThawAccountParam {
private String orderNo; private String orderNo;
// 1: 普通单 2:网运单 // 1: 普通单 2:网运单
private String orderType; private Integer orderType;
} }
package com.clx.performance.component;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.json.JSONUtil;
import com.clx.order.enums.OrderEnum;
import com.clx.order.feign.OrderFeign;
import com.clx.performance.dao.OrderChildDao;
import com.clx.performance.dao.OrderGoodsDao;
import com.clx.performance.enums.OrderChildEnum;
import com.clx.performance.enums.OrderGoodsStatusEnum;
import com.clx.performance.enums.PendingOrderWayStatusEnum;
import com.clx.performance.enums.PerformanceResultEnum;
import com.clx.performance.extranal.user.DriverService;
import com.clx.performance.model.OrderChild;
import com.clx.performance.model.OrderGoods;
import com.clx.performance.param.pc.OrderCancelParam;
import com.clx.performance.service.OrderChildService;
import com.clx.user.enums.driver.DriverInfoEnum;
import com.msl.common.exception.ServiceSystemException;
import com.msl.common.result.Result;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Component
@Slf4j
@AllArgsConstructor
public class OrderCancelComponent {
private final OrderChildDao orderChildDao;
private final OrderGoodsDao orderGoodsDao;
private final OrderChildService orderChildService;
private final GoodsOrderTruckRecordComponent goodsOrderTruckRecordComponent;
private final OrderFeign orderFeign;
private final DriverService driverService;
public void ownerProcess(OrderCancelParam param){
String orderNo = param.getOrderNo();
List<OrderGoods> orderGoodsList = null;
Integer orderStatusCode = OrderEnum.Status.CANCELED.getCode();
switch (param.getCancelType()) {
case 1: //单纯取消订单
log.info("1:货主单纯取消订单");
if (CollectionUtil.isNotEmpty(orderChildDao.getOrderChildByOrderNo(orderNo))) {
throw new ServiceSystemException(PerformanceResultEnum.HTTP_ERROR, "当前订单已发生变化,请重新选择取消方式");
}
orderGoodsList = orderGoodsDao.getOrderGoodsListByOrderNo(orderNo);
if (CollectionUtil.isNotEmpty(orderGoodsList)) {
List<Integer> ids = new LinkedList<>();
for (OrderGoods orderGoods : orderGoodsList) {
if (orderGoods.getPendingOrderWay().equals(PendingOrderWayStatusEnum.Status.DX.getCode())) {
orderChildService.updateCancelTruckBind(orderGoods.getOrderGoodsNo());
}
goodsOrderTruckRecordComponent.deleteTruckRecord(orderGoods.getOrderGoodsNo());
ids.add(orderGoods.getId());
}
orderGoodsDao.batchUpdateOrderGoodsStatus(OrderGoodsStatusEnum.Status.CANCEL.getCode(),
ids);
}
break;
case 2: //取消未拉运吨数的货单
log.info("2:货主取消未拉运吨数的货单");
orderGoodsList = orderGoodsDao.getOrderGoodsListByOrderNo(orderNo);
for (OrderGoods orderGoods : orderGoodsList) {
OrderGoods update = new OrderGoods();
update.setId(orderGoods.getId());
if (orderGoods.getResidueTransportWeight().compareTo(orderGoods.getExtractWeight()) == 0) {
update.setOrderGoodsStatus(OrderGoodsStatusEnum.Status.CANCEL.getCode());
} else {
orderStatusCode = OrderEnum.Status.COMPLETED.getCode();
update.setOrderGoodsStatus(OrderGoodsStatusEnum.Status.COMPLETED.getCode());
}
if (orderGoods.getPendingOrderWay().equals(PendingOrderWayStatusEnum.Status.DX.getCode())) {
orderChildService.updateCancelTruckBind(orderGoods.getOrderGoodsNo());
}
goodsOrderTruckRecordComponent.deleteTruckRecord(orderGoods.getOrderGoodsNo());
orderGoodsDao.updateEntityByKey(update);
}
break;
case 3: //取消未拉运+未到达货源地吨数
log.info("3:货主取消未拉运+未到达货源地吨数");
List<OrderChild> orderChildren = orderChildDao.selectResidueWeight(orderNo, OrderChildEnum.Status.ARRIVE_SEND.getCode());
log.info("执行货主取消未拉运+未到达货源地吨数,当前运单个数"+ orderChildren.size());
List<Integer> ids = new LinkedList<>();
for (OrderChild orderChild : orderChildren) {
log.info("取消的运单:{}", JSONUtil.parse(orderChild));
//释放车辆
driverService.updateOrderStatus(orderChild.getDriverUserNo(), DriverInfoEnum.DriverStatus.NO.getCode(), orderChild.getTruckId(), 1);
ids.add(orderChild.getId());
}
Map<String, List<OrderChild>> orderChildMap = new HashMap<>();
if (CollectionUtil.isNotEmpty(ids)) {
log.info("ids:{}", ids);
orderChildDao.batchUpdateOrderChildStatus(
OrderChildEnum.Status.OWNER_CANCEL.getCode(), "货主取消",
ids);
orderChildMap = orderChildren.stream()
.collect(Collectors.groupingBy(OrderChild::getOrderGoodsNo));
}
orderGoodsList = orderGoodsDao.getOrderGoodsListByOrderNo(orderNo);
for (OrderGoods orderGoods : orderGoodsList) {
OrderGoods update = new OrderGoods();
update.setId(orderGoods.getId());
if (CollectionUtil.isEmpty(orderChildMap.get(orderGoods.getOrderGoodsNo()))) {
update.setOrderGoodsStatus(OrderGoodsStatusEnum.Status.CANCEL.getCode());
} else {
BigDecimal reduce = BigDecimal.ZERO;
for (OrderChild orderChild : orderChildMap.get(orderGoods.getOrderGoodsNo())) {
reduce = reduce.add(orderChild.getWeight());
}
if (orderGoods.getExtractWeight().compareTo(orderGoods.getResidueTransportWeight().add(reduce)) == 0) {
update.setOrderGoodsStatus(OrderGoodsStatusEnum.Status.CANCEL.getCode());
} else {
orderStatusCode = OrderEnum.Status.COMPLETED.getCode();
update.setOrderGoodsStatus(OrderGoodsStatusEnum.Status.COMPLETED.getCode());
}
}
if (orderGoods.getPendingOrderWay().equals(PendingOrderWayStatusEnum.Status.DX.getCode())) {
orderChildService.updateCancelTruckBind(orderGoods.getOrderGoodsNo());
}
goodsOrderTruckRecordComponent.deleteTruckRecord(orderGoods.getOrderGoodsNo());
orderGoodsDao.updateEntityByKey(update);
}
break;
default:
throw new ServiceSystemException(PerformanceResultEnum.HTTP_ERROR, "参数有误");
}
log.info("执行货主取消订单更改状态");
if (!orderFeign.updateOrderStatusByOrderNo(orderNo, orderStatusCode).succeed()) {
throw new ServiceSystemException(PerformanceResultEnum.HTTP_ERROR, "货主取消订单失败,原因:远程调用取消订单失败");
}
}
}
...@@ -34,7 +34,7 @@ public class OrderCancelFeignController { ...@@ -34,7 +34,7 @@ public class OrderCancelFeignController {
// cancelParam.setCancelType(3); // cancelParam.setCancelType(3);
// cancelParam.setCreateByType(1); // cancelParam.setCreateByType(1);
// orderCancelService.platformCancelOrderPrePC(cancelParam); // orderCancelService.platformCancelOrderPrePC(cancelParam);
orderCancelService.ownerCancelOrderPre(param.getOrderNo()); orderCancelService.ownerConfirmCancelOrderPre(param.getOrderNo());
return Result.ok(); return Result.ok();
} }
} }
...@@ -4,13 +4,13 @@ import com.clx.performance.param.pc.OrderCancelParam; ...@@ -4,13 +4,13 @@ import com.clx.performance.param.pc.OrderCancelParam;
public interface OrderCancelService { public interface OrderCancelService {
// void platformCancelOrderPre(String orderNo); /**
// * 承运端取消订单,货主同意调用此接口
// void platformCancelOrder(String orderNo); * @param orderNo
// */
void ownerCancelOrderPre(String orderNo); void ownerConfirmCancelOrderPre(String orderNo);
//
void ownerCancelOrder(String orderNo); void ownerConfirmCancelProcess(String orderNo);
/** /**
* 货主取消订单前置(只修改订单状态) * 货主取消订单前置(只修改订单状态)
......
...@@ -8,6 +8,7 @@ import com.clx.order.param.feign.OrderCancelReasonParam; ...@@ -8,6 +8,7 @@ import com.clx.order.param.feign.OrderCancelReasonParam;
import com.clx.order.param.feign.RollbackOrderWeightParam; import com.clx.order.param.feign.RollbackOrderWeightParam;
import com.clx.order.vo.feign.FeignOrderVO; import com.clx.order.vo.feign.FeignOrderVO;
import com.clx.performance.component.GoodsOrderTruckRecordComponent; import com.clx.performance.component.GoodsOrderTruckRecordComponent;
import com.clx.performance.component.OrderCancelComponent;
import com.clx.performance.constant.RabbitKeyConstants; import com.clx.performance.constant.RabbitKeyConstants;
import com.clx.performance.dao.OrderChildDao; import com.clx.performance.dao.OrderChildDao;
import com.clx.performance.dao.OrderGoodsDao; import com.clx.performance.dao.OrderGoodsDao;
...@@ -16,7 +17,6 @@ import com.clx.performance.enums.*; ...@@ -16,7 +17,6 @@ import com.clx.performance.enums.*;
import com.clx.performance.extranal.user.DriverService; import com.clx.performance.extranal.user.DriverService;
import com.clx.performance.model.OrderChild; import com.clx.performance.model.OrderChild;
import com.clx.performance.model.OrderGoods; import com.clx.performance.model.OrderGoods;
import com.clx.performance.param.mq.OrderCancelMqParam;
import com.clx.performance.param.pc.OrderCancelParam; import com.clx.performance.param.pc.OrderCancelParam;
import com.clx.performance.param.pc.owner.ThawAccountParam; import com.clx.performance.param.pc.owner.ThawAccountParam;
import com.clx.performance.service.OrderCancelService; import com.clx.performance.service.OrderCancelService;
...@@ -66,11 +66,13 @@ public class OrderCancelServiceImpl implements OrderCancelService { ...@@ -66,11 +66,13 @@ public class OrderCancelServiceImpl implements OrderCancelService {
private final GoodsOrderTruckRecordComponent goodsOrderTruckRecordComponent; private final GoodsOrderTruckRecordComponent goodsOrderTruckRecordComponent;
private final OrderCancelComponent orderCancelComponent;
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void ownerCancelOrderPre(String orderNo) { public void ownerConfirmCancelOrderPre(String orderNo) {
List<OrderGoods> orderGoodsList = orderGoodsDao.getOrderGoodsListByOrderNo(orderNo); List<OrderGoods> orderGoodsList = orderGoodsDao.getOrderGoodsListByOrderNo(orderNo);
if (CollectionUtil.isEmpty(orderGoodsList)) { if (CollectionUtil.isEmpty(orderGoodsList)) {
//未产生货单 //未产生货单
...@@ -82,10 +84,10 @@ public class OrderCancelServiceImpl implements OrderCancelService { ...@@ -82,10 +84,10 @@ public class OrderCancelServiceImpl implements OrderCancelService {
ThawAccountParam thawAccountParam = new ThawAccountParam(); ThawAccountParam thawAccountParam = new ThawAccountParam();
thawAccountParam.setOrderNo(orderNo); thawAccountParam.setOrderNo(orderNo);
thawAccountParam.setOrderType("1"); thawAccountParam.setOrderType(OwnerAccountEnum.OrderChildTypeStatus.NETWORK.getCode());
log.info("执行解冻账户,参数:{}", JSONUtil.parse(thawAccountParam)); log.info("执行解冻账户,参数:{}", JSONUtil.parse(thawAccountParam));
ownerAccountService.ownerAccountThaw(thawAccountParam); ownerAccountService.ownerAccountThaw(thawAccountParam);
this.ownerCancelOrder(orderNo); this.ownerConfirmCancelProcess(orderNo);
return; return;
} }
...@@ -169,10 +171,10 @@ public class OrderCancelServiceImpl implements OrderCancelService { ...@@ -169,10 +171,10 @@ public class OrderCancelServiceImpl implements OrderCancelService {
ThawAccountParam thawAccountParam = new ThawAccountParam(); ThawAccountParam thawAccountParam = new ThawAccountParam();
thawAccountParam.setOrderNo(orderNo); thawAccountParam.setOrderNo(orderNo);
thawAccountParam.setOrderType("1"); thawAccountParam.setOrderType(OwnerAccountEnum.OrderChildTypeStatus.NETWORK.getCode());
log.info("执行解冻账户,参数:{}", JSONUtil.parse(thawAccountParam)); log.info("执行解冻账户,参数:{}", JSONUtil.parse(thawAccountParam));
ownerAccountService.ownerAccountThaw(thawAccountParam); ownerAccountService.ownerAccountThaw(thawAccountParam);
this.ownerCancelOrder(orderNo); this.ownerConfirmCancelProcess(orderNo);
Result<Object> result = orderFeign.updateOrderStatusByOrderNo(orderNo, OrderEnum.Status.COMPLETED.getCode()); Result<Object> result = orderFeign.updateOrderStatusByOrderNo(orderNo, OrderEnum.Status.COMPLETED.getCode());
if (!result.succeed()) { if (!result.succeed()) {
throw new RuntimeException("货主取消订单失败,原因:远程调用取消订单失败"); throw new RuntimeException("货主取消订单失败,原因:远程调用取消订单失败");
...@@ -181,7 +183,7 @@ public class OrderCancelServiceImpl implements OrderCancelService { ...@@ -181,7 +183,7 @@ public class OrderCancelServiceImpl implements OrderCancelService {
} }
@Override @Override
public void ownerCancelOrder(String orderNo) { public void ownerConfirmCancelProcess(String orderNo) {
log.info("开始执行订单取消吨数回填"); log.info("开始执行订单取消吨数回填");
FeignOrderVO orderInfoFeignVO = orderFeign.getOrderInfoFeign(orderNo); FeignOrderVO orderInfoFeignVO = orderFeign.getOrderInfoFeign(orderNo);
...@@ -192,21 +194,7 @@ public class OrderCancelServiceImpl implements OrderCancelService { ...@@ -192,21 +194,7 @@ public class OrderCancelServiceImpl implements OrderCancelService {
if (!TruckDemandEnum.TruckType.PLATFORM_ANY_CAR.getCode().equals(orderInfoFeignVO.getTruckDemand())) { if (!TruckDemandEnum.TruckType.PLATFORM_ANY_CAR.getCode().equals(orderInfoFeignVO.getTruckDemand())) {
if (OrderEnum.Status.COMPLETED.getCode().equals(orderInfoFeignVO.getOrderStatus())) { if (OrderEnum.Status.COMPLETED.getCode().equals(orderInfoFeignVO.getOrderStatus())) {
//已完结 //已完结
// List<Integer> ids = new LinkedList<>();
List<OrderChild> orderChildrenList = orderChildDao.selectResidueWeight(orderNo, OrderChildEnum.Status.ARRIVE_SEND.getCode()); List<OrderChild> orderChildrenList = orderChildDao.selectResidueWeight(orderNo, OrderChildEnum.Status.ARRIVE_SEND.getCode());
// for (OrderChild orderChild : orderChildrenList) {
// //释放车辆
// driverService.updateOrderStatus(orderChild.getDriverUserNo(), DriverInfoEnum.DriverStatus.NO.getCode(), orderChild.getTruckId(), 1);
// ids.add(orderChild.getId());
// }
//
// if (CollectionUtil.isNotEmpty(ids)) {
// orderChildDao.batchUpdateOrderChildStatus(
// OrderChildEnum.Status.OWNER_CANCEL.getCode(),
// ids);
// }
Map<String, List<OrderGoods>> orderGoodsMap = orderGoodsList.stream() Map<String, List<OrderGoods>> orderGoodsMap = orderGoodsList.stream()
.collect(Collectors.groupingBy(OrderGoods::getOrderGoodsNo)); .collect(Collectors.groupingBy(OrderGoods::getOrderGoodsNo));
...@@ -236,17 +224,13 @@ public class OrderCancelServiceImpl implements OrderCancelService { ...@@ -236,17 +224,13 @@ public class OrderCancelServiceImpl implements OrderCancelService {
truckDemandMap.get(orderGoods.getTruckDemand()) truckDemandMap.get(orderGoods.getTruckDemand())
.add(orderGoods.getResidueTransportWeight())); .add(orderGoods.getResidueTransportWeight()));
} }
} }
Integer truckDemand = orderInfoFeignVO.getTruckDemand(); Integer truckDemand = orderInfoFeignVO.getTruckDemand();
BigDecimal residueWeight = truckDemandMap.get(truckDemand); BigDecimal residueWeight = truckDemandMap.get(truckDemand);
if (residueWeight.compareTo(BigDecimal.ZERO) == 0) { if (residueWeight.compareTo(BigDecimal.ZERO) == 0) {
log.info("当前订单对应的货单无需吨数回填,订单编号{}", orderNo); log.info("当前订单对应的货单无需吨数回填,订单编号{}", orderNo);
return; return;
} }
//归还吨数 //归还吨数
RollbackOrderWeightParam param = new RollbackOrderWeightParam(); RollbackOrderWeightParam param = new RollbackOrderWeightParam();
param.setOrderNo(orderInfoFeignVO.getOrderNo()); param.setOrderNo(orderInfoFeignVO.getOrderNo());
...@@ -269,19 +253,6 @@ public class OrderCancelServiceImpl implements OrderCancelService { ...@@ -269,19 +253,6 @@ public class OrderCancelServiceImpl implements OrderCancelService {
if (OrderEnum.Status.COMPLETED.getCode().equals(orderInfoFeignVO.getOrderStatus())) { if (OrderEnum.Status.COMPLETED.getCode().equals(orderInfoFeignVO.getOrderStatus())) {
//已完结 //已完结
List<OrderChild> orderChildrenList = orderChildDao.selectResidueWeight(orderNo, OrderChildEnum.Status.ARRIVE_SEND.getCode()); List<OrderChild> orderChildrenList = orderChildDao.selectResidueWeight(orderNo, OrderChildEnum.Status.ARRIVE_SEND.getCode());
// List<Integer> ids = new LinkedList<>();
// for (OrderChild orderChild : orderChildrenList) {
// //释放车辆
// driverService.updateOrderStatus(orderChild.getDriverUserNo(), DriverInfoEnum.DriverStatus.NO.getCode(), orderChild.getTruckId(), 1);
// ids.add(orderChild.getId());
// }
//
// if (CollectionUtil.isNotEmpty(ids)) {
// orderChildDao.batchUpdateOrderChildStatus(
// OrderChildEnum.Status.OWNER_CANCEL.getCode(),
// ids);
// }
//货单 //货单
Map<String, List<OrderGoods>> orderGoodsMap = orderGoodsList.stream() Map<String, List<OrderGoods>> orderGoodsMap = orderGoodsList.stream()
.collect(Collectors.groupingBy(OrderGoods::getOrderGoodsNo)); .collect(Collectors.groupingBy(OrderGoods::getOrderGoodsNo));
...@@ -289,7 +260,6 @@ public class OrderCancelServiceImpl implements OrderCancelService { ...@@ -289,7 +260,6 @@ public class OrderCancelServiceImpl implements OrderCancelService {
Map<String, List<OrderChild>> orderChildMap = orderChildrenList.stream() Map<String, List<OrderChild>> orderChildMap = orderChildrenList.stream()
.collect(Collectors.groupingBy(OrderChild::getOrderGoodsNo)); .collect(Collectors.groupingBy(OrderChild::getOrderGoodsNo));
for (Map.Entry<String, List<OrderGoods>> entry : orderGoodsMap.entrySet()) { for (Map.Entry<String, List<OrderGoods>> entry : orderGoodsMap.entrySet()) {
String orderGoodsNo = entry.getKey(); String orderGoodsNo = entry.getKey();
OrderGoods orderGoods = entry.getValue().get(0); OrderGoods orderGoods = entry.getValue().get(0);
...@@ -302,11 +272,8 @@ public class OrderCancelServiceImpl implements OrderCancelService { ...@@ -302,11 +272,8 @@ public class OrderCancelServiceImpl implements OrderCancelService {
vehicleUsageMap.put(orderGoods.getVehicleUsage(), vehicleUsageMap.put(orderGoods.getVehicleUsage(),
vehicleUsageMap.get(orderGoods.getVehicleUsage()) vehicleUsageMap.get(orderGoods.getVehicleUsage())
.add(orderGoods.getResidueTransportWeight().add(sum))); .add(orderGoods.getResidueTransportWeight().add(sum)));
orderGoodsDao.updateOrderGoodsSetResidueWeightAndAlreadyWeight(sum, sum, orderGoods.getId()); orderGoodsDao.updateOrderGoodsSetResidueWeightAndAlreadyWeight(sum, sum, orderGoods.getId());
} }
} else if (OrderEnum.Status.CANCELED.getCode().equals(orderInfoFeignVO.getOrderStatus())) { } else if (OrderEnum.Status.CANCELED.getCode().equals(orderInfoFeignVO.getOrderStatus())) {
for (OrderGoods orderGoods : orderGoodsList) { for (OrderGoods orderGoods : orderGoodsList) {
vehicleUsageMap.put(orderGoods.getVehicleUsage(), vehicleUsageMap.put(orderGoods.getVehicleUsage(),
...@@ -315,7 +282,6 @@ public class OrderCancelServiceImpl implements OrderCancelService { ...@@ -315,7 +282,6 @@ public class OrderCancelServiceImpl implements OrderCancelService {
} }
} }
//归还吨数 //归还吨数
BigDecimal platformResidueSum = vehicleUsageMap.get(1); BigDecimal platformResidueSum = vehicleUsageMap.get(1);
BigDecimal ownResidueSum = vehicleUsageMap.get(2); BigDecimal ownResidueSum = vehicleUsageMap.get(2);
...@@ -338,10 +304,8 @@ public class OrderCancelServiceImpl implements OrderCancelService { ...@@ -338,10 +304,8 @@ public class OrderCancelServiceImpl implements OrderCancelService {
throw new ServiceSystemException(PerformanceResultEnum.HTTP_ERROR, e.getMessage()); throw new ServiceSystemException(PerformanceResultEnum.HTTP_ERROR, e.getMessage());
} }
} }
} }
...@@ -349,125 +313,8 @@ public class OrderCancelServiceImpl implements OrderCancelService { ...@@ -349,125 +313,8 @@ public class OrderCancelServiceImpl implements OrderCancelService {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void ownerCancelOrderPre(OrderCancelParam param) { public void ownerCancelOrderPre(OrderCancelParam param) {
String orderNo = param.getOrderNo(); String orderNo = param.getOrderNo();
List<OrderGoods> orderGoodsList = null; orderCancelComponent.ownerProcess(param);
Integer orderStatusCode = OrderEnum.Status.CANCELED.getCode();
log.info("+++++++++++++++++++++++++");
switch (param.getCancelType()) {
case 1: //单纯取消订单
log.info("1:单纯取消订单");
if (CollectionUtil.isNotEmpty(orderChildDao.getOrderChildByOrderNo(orderNo))) {
throw new ServiceSystemException(PerformanceResultEnum.HTTP_ERROR, "当前订单已发生变化,请重新选择取消方式");
}
orderGoodsList = orderGoodsDao.getOrderGoodsListByOrderNo(orderNo);
if (CollectionUtil.isNotEmpty(orderGoodsList)) {
List<Integer> ids = new LinkedList<>();
for (OrderGoods orderGoods : orderGoodsList) {
if (orderGoods.getPendingOrderWay().equals(PendingOrderWayStatusEnum.Status.DX.getCode())) {
orderChildService.updateCancelTruckBind(orderGoods.getOrderGoodsNo());
}
goodsOrderTruckRecordComponent.deleteTruckRecord(orderGoods.getOrderGoodsNo());
ids.add(orderGoods.getId());
}
orderGoodsDao.batchUpdateOrderGoodsStatus(OrderGoodsStatusEnum.Status.CANCEL.getCode(),
ids);
}
Result<Object> result = orderFeign.updateOrderStatusByOrderNo(orderNo, OrderEnum.Status.CANCELED.getCode());
if (!result.succeed()) {
throw new ServiceSystemException(PerformanceResultEnum.HTTP_ERROR, "货主取消订单失败,原因:远程调用取消订单失败");
}
break;
case 2: //取消未拉运吨数的货单
log.info("2:取消未拉运吨数的货单");
orderGoodsList = orderGoodsDao.getOrderGoodsListByOrderNo(orderNo);
for (OrderGoods orderGoods : orderGoodsList) {
OrderGoods update = new OrderGoods();
update.setId(orderGoods.getId());
if (orderGoods.getResidueTransportWeight().compareTo(orderGoods.getExtractWeight()) == 0) {
update.setOrderGoodsStatus(OrderGoodsStatusEnum.Status.CANCEL.getCode());
} else {
orderStatusCode = OrderEnum.Status.COMPLETED.getCode();
update.setOrderGoodsStatus(OrderGoodsStatusEnum.Status.COMPLETED.getCode());
}
if (orderGoods.getPendingOrderWay().equals(PendingOrderWayStatusEnum.Status.DX.getCode())) {
orderChildService.updateCancelTruckBind(orderGoods.getOrderGoodsNo());
}
goodsOrderTruckRecordComponent.deleteTruckRecord(orderGoods.getOrderGoodsNo());
orderGoodsDao.updateEntityByKey(update);
}
if (!orderFeign.updateOrderStatusByOrderNo(orderNo, orderStatusCode).succeed()) {
throw new ServiceSystemException(PerformanceResultEnum.HTTP_ERROR, "货主取消订单失败,原因:远程调用取消订单失败");
}
break;
case 3: //取消未拉运+未到达货源地吨数
log.info("3:取消未拉运+未到达货源地吨数");
List<OrderChild> orderChildren = orderChildDao.selectResidueWeight(orderNo, OrderChildEnum.Status.ARRIVE_SEND.getCode());
log.info("执行货主取消未拉运+未到达货源地吨数,当前运单个数"+ orderChildren.size());
List<Integer> ids = new LinkedList<>();
for (OrderChild orderChild : orderChildren) {
log.info("取消的运单:{}", JSONUtil.parse(orderChild));
//释放车辆
driverService.updateOrderStatus(orderChild.getDriverUserNo(), DriverInfoEnum.DriverStatus.NO.getCode(), orderChild.getTruckId(), 1);
ids.add(orderChild.getId());
}
Map<String, List<OrderChild>> orderChildMap = new HashMap<>();
if (CollectionUtil.isNotEmpty(ids)) {
log.info("ids:{}", ids);
orderChildDao.batchUpdateOrderChildStatus(
OrderChildEnum.Status.OWNER_CANCEL.getCode(), "货主取消",
ids);
orderChildMap = orderChildren.stream()
.collect(Collectors.groupingBy(OrderChild::getOrderGoodsNo));
}
orderGoodsList = orderGoodsDao.getOrderGoodsListByOrderNo(orderNo);
for (OrderGoods orderGoods : orderGoodsList) {
OrderGoods update = new OrderGoods();
update.setId(orderGoods.getId());
if (CollectionUtil.isEmpty(orderChildMap.get(orderGoods.getOrderGoodsNo()))) {
update.setOrderGoodsStatus(OrderGoodsStatusEnum.Status.CANCEL.getCode());
} else {
BigDecimal reduce = BigDecimal.ZERO;
for (OrderChild orderChild : orderChildMap.get(orderGoods.getOrderGoodsNo())) {
reduce = reduce.add(orderChild.getWeight());
}
if (orderGoods.getExtractWeight().compareTo(orderGoods.getResidueTransportWeight().add(reduce)) == 0) {
update.setOrderGoodsStatus(OrderGoodsStatusEnum.Status.CANCEL.getCode());
} else {
orderStatusCode = OrderEnum.Status.COMPLETED.getCode();
update.setOrderGoodsStatus(OrderGoodsStatusEnum.Status.COMPLETED.getCode());
}
}
if (orderGoods.getPendingOrderWay().equals(PendingOrderWayStatusEnum.Status.DX.getCode())) {
orderChildService.updateCancelTruckBind(orderGoods.getOrderGoodsNo());
}
goodsOrderTruckRecordComponent.deleteTruckRecord(orderGoods.getOrderGoodsNo());
orderGoodsDao.updateEntityByKey(update);
}
if (!orderFeign.updateOrderStatusByOrderNo(orderNo, orderStatusCode).succeed()) {
throw new ServiceSystemException(PerformanceResultEnum.HTTP_ERROR, "货主取消订单失败,原因:远程调用取消订单失败");
}
break;
default:
throw new ServiceSystemException(PerformanceResultEnum.HTTP_ERROR, "参数有误");
}
OrderCancelReasonParam orderCancelReasonParam = new OrderCancelReasonParam(); OrderCancelReasonParam orderCancelReasonParam = new OrderCancelReasonParam();
orderCancelReasonParam.setOrderNo(orderNo); orderCancelReasonParam.setOrderNo(orderNo);
orderCancelReasonParam.setReason(param.getCancelReason()); orderCancelReasonParam.setReason(param.getCancelReason());
...@@ -481,7 +328,7 @@ public class OrderCancelServiceImpl implements OrderCancelService { ...@@ -481,7 +328,7 @@ public class OrderCancelServiceImpl implements OrderCancelService {
ThawAccountParam thawAccountParam = new ThawAccountParam(); ThawAccountParam thawAccountParam = new ThawAccountParam();
thawAccountParam.setOrderNo(orderNo); thawAccountParam.setOrderNo(orderNo);
thawAccountParam.setOrderType("1"); thawAccountParam.setOrderType(OwnerAccountEnum.OrderChildTypeStatus.NETWORK.getCode());
log.info("执行解冻账户,参数:{}", JSONUtil.parse(thawAccountParam)); log.info("执行解冻账户,参数:{}", JSONUtil.parse(thawAccountParam));
ownerAccountService.ownerAccountThaw(thawAccountParam); ownerAccountService.ownerAccountThaw(thawAccountParam);
...@@ -613,7 +460,7 @@ public class OrderCancelServiceImpl implements OrderCancelService { ...@@ -613,7 +460,7 @@ public class OrderCancelServiceImpl implements OrderCancelService {
//TODO 注意判断普通单还是网运单 普通单类型 1 网运单 2 //TODO 注意判断普通单还是网运单 普通单类型 1 网运单 2
ThawAccountParam thawAccountParam = new ThawAccountParam(); ThawAccountParam thawAccountParam = new ThawAccountParam();
thawAccountParam.setOrderNo(orderNo); thawAccountParam.setOrderNo(orderNo);
thawAccountParam.setOrderType("1"); thawAccountParam.setOrderType(OwnerAccountEnum.OrderChildTypeStatus.NETWORK.getCode());
log.info("执行解冻账户,参数:{}", JSONUtil.parse(thawAccountParam)); log.info("执行解冻账户,参数:{}", JSONUtil.parse(thawAccountParam));
ownerAccountService.ownerAccountThaw(thawAccountParam); ownerAccountService.ownerAccountThaw(thawAccountParam);
......
...@@ -782,7 +782,7 @@ public class OwnerAccountServiceImpl implements OwnerAccountService { ...@@ -782,7 +782,7 @@ public class OwnerAccountServiceImpl implements OwnerAccountService {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void ownerAccountThaw(ThawAccountParam param) { public void ownerAccountThaw(ThawAccountParam param) {
String orderNo = param.getOrderNo(); String orderNo = param.getOrderNo();
if (StringUtils.equals(param.getOrderType(), "1")) { if (OwnerAccountEnum.OrderChildTypeStatus.ORDINARY.getCode().equals(param.getOrderType())) {
List<OwnerRunningWaterRecord> list = ownerRunningWaterRecordDao.getOwnerRunningWaterRecord(orderNo); List<OwnerRunningWaterRecord> list = ownerRunningWaterRecordDao.getOwnerRunningWaterRecord(orderNo);
if (null == list || list.size() != 2) { if (null == list || list.size() != 2) {
log.info("解冻预付运费、保证金账户出错,查询出冻结流水有问题,参数为{}", JSONUtil.parse(param)); log.info("解冻预付运费、保证金账户出错,查询出冻结流水有问题,参数为{}", JSONUtil.parse(param));
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论