|
|
@@ -175,37 +175,40 @@ public class RiderService {
|
|
|
骑手抢单形式接单
|
|
|
5分钟内手动抢单
|
|
|
*/
|
|
|
- public void riderReceiveOrder(Long riderId, Long orderId, Boolean pass) {
|
|
|
+ public void riderReceiveOrder(Long userId, Long orderId) {
|
|
|
OrderInfo orderInfo = orderInfoRepo.findById(orderId).orElseThrow(new BusinessException("无订单"));
|
|
|
|
|
|
- if (pass) {
|
|
|
- if (!OrderStatus.PAID.equals(orderInfo.getStatus())) {
|
|
|
- throw new BusinessException("订单不可接单");
|
|
|
- }
|
|
|
- if (!MerchantStatus.RECEIVED.equals(orderInfo.getMerchantStatus())) {
|
|
|
- throw new BusinessException("商家未接单");
|
|
|
- }
|
|
|
- if (!RiderStatus.NOT_RECEIVED.equals(orderInfo.getRiderStatus())) {
|
|
|
- throw new BusinessException("已被其他骑手接单");
|
|
|
- }
|
|
|
+ Long riderId = riderRepo.findByUserId(userId).orElseThrow(new BusinessException("无骑手")).getId();
|
|
|
|
|
|
- //如果是货到付款
|
|
|
- if (PayMethod.CASH_DELIVERY.equals(orderInfo.getPayMethod())) {
|
|
|
- if (!this.canCash(riderId)) {
|
|
|
- throw new BusinessException("不满足接货到付款订单");
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
- List<OrderInfo> infos = orderInfoRepo.findAllByRiderIdAndRiderStatusIsNot(riderId, RiderStatus.CARRY_OUT);
|
|
|
- if (infos.size() >= sysConfigService.getOrderLimit()) {
|
|
|
- throw new BusinessException("未完成订单已达上线");
|
|
|
+ if (!OrderStatus.PAID.equals(orderInfo.getStatus())) {
|
|
|
+ throw new BusinessException("订单不可接单");
|
|
|
+ }
|
|
|
+ if (!MerchantStatus.RECEIVED.equals(orderInfo.getMerchantStatus())) {
|
|
|
+ throw new BusinessException("商家未接单");
|
|
|
+ }
|
|
|
+ if (!RiderStatus.NOT_RECEIVED.equals(orderInfo.getRiderStatus())
|
|
|
+ || orderInfo.getRiderStatus() == null) {
|
|
|
+ throw new BusinessException("已被其他骑手接单");
|
|
|
+ }
|
|
|
+
|
|
|
+ //如果是货到付款
|
|
|
+ if (PayMethod.CASH_DELIVERY.equals(orderInfo.getPayMethod())) {
|
|
|
+ if (!this.canCash(riderId)) {
|
|
|
+ throw new BusinessException("不满足接货到付款订单");
|
|
|
}
|
|
|
- //设置订单状态
|
|
|
- orderInfo.setRiderId(riderId);
|
|
|
- orderInfo.setRiderStatus(RiderStatus.RECEIVED);
|
|
|
-// orderInfo.setRiderOrderTime(LocalDateTime.now());
|
|
|
- orderInfoRepo.save(orderInfo);
|
|
|
}
|
|
|
+
|
|
|
+ List<OrderInfo> infos = orderInfoRepo.findAllByRiderIdAndRiderStatusIsNot(riderId, RiderStatus.CARRY_OUT);
|
|
|
+ if (infos.size() >= sysConfigService.getOrderLimit()) {
|
|
|
+ throw new BusinessException("未完成订单已达上线");
|
|
|
+ }
|
|
|
+ //设置订单状态
|
|
|
+ orderInfo.setRiderId(riderId);
|
|
|
+ orderInfo.setRiderStatus(RiderStatus.RECEIVED);
|
|
|
+// orderInfo.setRiderOrderTime(LocalDateTime.now());
|
|
|
+ orderInfoRepo.save(orderInfo);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
@@ -227,7 +230,8 @@ public class RiderService {
|
|
|
Map<Long, Double> map = new HashMap<>();
|
|
|
//筛查骑手,查出订单数小于5,3000米以内,(支持货到付款)
|
|
|
locationList.forEach(d -> {
|
|
|
- if (orderInfoRepo.countByRiderIdAndRiderStatusIsNot(d.getRiderId(), RiderStatus.CARRY_OUT) < sysConfigService.getOrderLimit()) {
|
|
|
+ if (orderInfoRepo.countByRiderIdAndRiderStatusIsNot(d.getRiderId(), RiderStatus.CARRY_OUT) < sysConfigService
|
|
|
+ .getOrderLimit()) {
|
|
|
boolean t = true;
|
|
|
if (cash) {
|
|
|
//是否支持货到付款
|