司机接单
parent
3acc966fca
commit
776e85d45c
|
|
@ -7,6 +7,7 @@ import com.njzscloud.dispose.cst.order.pojo.entity.OrderEntity;
|
|||
import com.njzscloud.dispose.cst.order.pojo.param.AssignmentDriverParam;
|
||||
import com.njzscloud.dispose.cst.order.pojo.param.AssignmentOrgParam;
|
||||
import com.njzscloud.dispose.cst.order.pojo.param.CreateOrderParam;
|
||||
import com.njzscloud.dispose.cst.order.pojo.param.DriverAcceptOrderParam;
|
||||
import com.njzscloud.dispose.cst.order.service.OrderService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
|
@ -88,6 +89,16 @@ public class OrderController {
|
|||
return R.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 司机接单
|
||||
*/
|
||||
@GetMapping("/driverAcceptOrder")
|
||||
public R<?> driverAcceptOrder(@RequestBody DriverAcceptOrderParam acceptOrderParam) {
|
||||
orderService.driverAcceptOrder(acceptOrderParam);
|
||||
return R.success();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,27 @@
|
|||
package com.njzscloud.dispose.cst.order.pojo.param;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* @author ljw
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@Accessors(chain = true)
|
||||
public class DriverAcceptOrderParam {
|
||||
|
||||
/**
|
||||
* 订单运输ID
|
||||
*/
|
||||
private Long orderTransId;
|
||||
|
||||
/**
|
||||
* 车辆Id
|
||||
*/
|
||||
private Long truckId;
|
||||
|
||||
}
|
||||
|
|
@ -21,12 +21,11 @@ import com.njzscloud.dispose.cst.order.pojo.entity.OrderCargoPlaceEntity;
|
|||
import com.njzscloud.dispose.cst.order.pojo.entity.OrderEntity;
|
||||
import com.njzscloud.dispose.cst.order.pojo.entity.OrderExpenseItemsEntity;
|
||||
import com.njzscloud.dispose.cst.order.pojo.entity.OrderTransEntity;
|
||||
import com.njzscloud.dispose.cst.order.pojo.param.AssignmentDriverParam;
|
||||
import com.njzscloud.dispose.cst.order.pojo.param.AssignmentOrgParam;
|
||||
import com.njzscloud.dispose.cst.order.pojo.param.CreateOrderCargoPlaceParam;
|
||||
import com.njzscloud.dispose.cst.order.pojo.param.CreateOrderParam;
|
||||
import com.njzscloud.dispose.cst.order.pojo.param.*;
|
||||
import com.njzscloud.dispose.cst.order.pojo.result.OrderTransResult;
|
||||
import com.njzscloud.dispose.cst.order.pojo.vo.Scope;
|
||||
import com.njzscloud.dispose.cst.truck.mapper.TruckMapper;
|
||||
import com.njzscloud.dispose.cst.truck.pojo.entity.TruckEntity;
|
||||
import com.njzscloud.dispose.finance.constant.ScopeStrategy;
|
||||
import com.njzscloud.dispose.finance.pojo.entity.ExpenseItemEntity;
|
||||
import com.njzscloud.dispose.finance.service.ExpenseItemService;
|
||||
|
|
@ -38,6 +37,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
|
|
@ -54,6 +54,7 @@ public class OrderService extends ServiceImpl<OrderMapper, OrderEntity> {
|
|||
private final OrderTransMapper orderTransMapper;
|
||||
private final ExpenseItemService expenseItemService;
|
||||
private final DriverMapper driverMapper;
|
||||
private final TruckMapper truckMapper;
|
||||
private final CustomerMapper customerMapper;
|
||||
private final OrderExpenseItemsService orderExpenseItemsService;
|
||||
|
||||
|
|
@ -94,6 +95,7 @@ public class OrderService extends ServiceImpl<OrderMapper, OrderEntity> {
|
|||
transEntity.setTransTime(transOrgId == null ? null : LocalDateTime.now());
|
||||
transEntity.setCheckStatus(CheckStatus.WeiKanLiao.getVal());
|
||||
transEntity.setPaymentStatus(PaymentStatus.WeiZhiFu.getVal());
|
||||
transEntity.setTransDistance(param.getTransDistance());
|
||||
orderTransMapper.insert(transEntity);
|
||||
}
|
||||
// 付费项
|
||||
|
|
@ -120,6 +122,7 @@ public class OrderService extends ServiceImpl<OrderMapper, OrderEntity> {
|
|||
return PageResult.of(this.page(pageParam.toPage(), Wrappers.query(orderEntity)));
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void assignmentOrg(AssignmentOrgParam orgParam) {
|
||||
Assert.notNull(orgParam, () -> Exceptions.clierr("请填写参数"));
|
||||
Assert.notNull(orgParam.getOrderTransId(), () -> Exceptions.clierr("订单运输ID不可为空"));
|
||||
|
|
@ -151,6 +154,7 @@ public class OrderService extends ServiceImpl<OrderMapper, OrderEntity> {
|
|||
orderTransMapper.updateById(transEntity);
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void assignmentDriver(AssignmentDriverParam driverParam) {
|
||||
Assert.notNull(driverParam, () -> Exceptions.clierr("请填写参数"));
|
||||
Assert.notNull(driverParam.getOrderTransId(), () -> Exceptions.clierr("订单运输ID不可为空"));
|
||||
|
|
@ -164,12 +168,6 @@ public class OrderService extends ServiceImpl<OrderMapper, OrderEntity> {
|
|||
DriverEntity driver = driverMapper.selectById(driverParam.getDriverId());
|
||||
Assert.notNull(driver, () -> Exceptions.clierr("司机不存在"));
|
||||
|
||||
// 更新司机状态
|
||||
DriverEntity driverEntity = new DriverEntity();
|
||||
driverEntity.setId(driverParam.getDriverId());
|
||||
driverEntity.setBusy(Boolean.TRUE);
|
||||
driverMapper.updateById(driverEntity);
|
||||
|
||||
// 更新运输信息表 cst_trans_order 的运输状态等信息
|
||||
OrderTransEntity transEntity = new OrderTransEntity();
|
||||
transEntity.setId(driverParam.getOrderTransId());
|
||||
|
|
@ -179,6 +177,51 @@ public class OrderService extends ServiceImpl<OrderMapper, OrderEntity> {
|
|||
transEntity.setDriverCustomerId(driver.getCustomerId());
|
||||
transEntity.setDriverUserId(driver.getUserId());
|
||||
orderTransMapper.updateById(transEntity);
|
||||
|
||||
// 更新司机状态
|
||||
DriverEntity driverEntity = new DriverEntity();
|
||||
driverEntity.setId(driverParam.getDriverId());
|
||||
driverEntity.setBusy(Boolean.TRUE);
|
||||
driverMapper.updateById(driverEntity);
|
||||
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void driverAcceptOrder(DriverAcceptOrderParam acceptOrderParam) {
|
||||
Assert.notNull(acceptOrderParam, () -> Exceptions.clierr("请填写参数"));
|
||||
Assert.notNull(acceptOrderParam.getOrderTransId(), () -> Exceptions.clierr("订单运输ID不可为空"));
|
||||
Assert.notNull(acceptOrderParam.getTruckId(), () -> Exceptions.clierr("车辆Id不可为空"));
|
||||
|
||||
OrderTransResult result = orderTransMapper.getById(acceptOrderParam.getOrderTransId());
|
||||
Assert.notNull(result, () -> Exceptions.clierr("订单不存在"));
|
||||
Assert.isTrue(TransStatus.DaiJieDan.getVal().equals(result.getTransStatus()), () -> Exceptions.clierr("当前订单状态,无法确认接单"));
|
||||
|
||||
long userId = SecurityUtil.currentUserId();
|
||||
DriverEntity driver = driverMapper.selectOne(Wrappers.<DriverEntity>lambdaQuery()
|
||||
.eq(DriverEntity::getUserId, userId));
|
||||
Assert.notNull(driver, () -> Exceptions.clierr("当前登录人非司机用户"));
|
||||
Assert.isTrue(Objects.equals(driver.getId(), result.getDriverId()), () -> Exceptions.clierr("您没有权限接受此单"));
|
||||
|
||||
TruckEntity truckEntity = truckMapper.selectById(acceptOrderParam.getTruckId());
|
||||
Assert.notNull(truckEntity, () -> Exceptions.clierr("车辆不存在"));
|
||||
|
||||
// 更新运输信息
|
||||
OrderTransEntity transEntity = new OrderTransEntity();
|
||||
transEntity.setId(acceptOrderParam.getOrderTransId());
|
||||
transEntity.setTransStatus(TransStatus.YiJieDan.getVal());
|
||||
transEntity.setDriverConfirmTime(LocalDateTime.now());
|
||||
transEntity.setTruckCustomerId(truckEntity.getCustomerId());
|
||||
transEntity.setTruckOrgId(truckEntity.getOrgId());
|
||||
transEntity.setTruckId(acceptOrderParam.getTruckId());
|
||||
transEntity.setTruckLicensePlate(truckEntity.getLicensePlate());
|
||||
orderTransMapper.updateById(transEntity);
|
||||
|
||||
// 更新车辆状态
|
||||
TruckEntity truck = new TruckEntity();
|
||||
truck.setId(acceptOrderParam.getTruckId());
|
||||
truck.setBusy(Boolean.TRUE);
|
||||
truckMapper.updateById(truck);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -275,5 +318,3 @@ public class OrderService extends ServiceImpl<OrderMapper, OrderEntity> {
|
|||
orderExpenseItemsService.saveBatch(extraItems);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue