|
|
@@ -2,6 +2,7 @@ package com.izouma.dingdong.service;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import com.izouma.dingdong.domain.*;
|
|
|
import com.izouma.dingdong.domain.backstage.BlackList;
|
|
|
import com.izouma.dingdong.domain.merchant.Merchant;
|
|
|
@@ -268,10 +269,13 @@ public class OrderInfoService {
|
|
|
throw new BusinessException("订单已取消");
|
|
|
}
|
|
|
|
|
|
- //RiderStatus riderStatus = orderInfo.getRiderStatus();
|
|
|
+ RiderStatus riderStatus = orderInfo.getRiderStatus();
|
|
|
switch (status) {
|
|
|
//已接单状态 待取餐
|
|
|
case ARRIVE:
|
|
|
+ if (!RiderStatus.RECEIVED.equals(riderStatus)) {
|
|
|
+ throw new BusinessException("订单状态错误");
|
|
|
+ }
|
|
|
//判断是否到达商家位置
|
|
|
Merchant merchant = orderInfo.getMerchant();
|
|
|
Double latitude1 = merchant.getLatitude();
|
|
|
@@ -282,13 +286,23 @@ public class OrderInfoService {
|
|
|
//待取餐
|
|
|
orderInfo.setRiderStatus(RiderStatus.ARRIVE);
|
|
|
break;
|
|
|
- case TAKE_MEAL:
|
|
|
+ /*case TAKE_MEAL:
|
|
|
+ if (!RiderStatus.ARRIVE.equals(riderStatus)) {
|
|
|
+ throw new BusinessException("订单状态错误");
|
|
|
+ }
|
|
|
+ if (StrUtil.isEmpty(img)) {
|
|
|
+ throw new BusinessException("照片不能为空");
|
|
|
+ }
|
|
|
+ orderInfo.setPickupPhotos(img);
|
|
|
//已取餐 待送达
|
|
|
orderInfo.setRiderStatus(RiderStatus.TAKE_MEAL);
|
|
|
//商家状态已完成
|
|
|
orderInfo.setMerchantStatus(MerchantStatus.CARRY_OUT);
|
|
|
- break;
|
|
|
+ break;*/
|
|
|
case CARRY_OUT:
|
|
|
+ if (!RiderStatus.TAKE_MEAL.equals(riderStatus)) {
|
|
|
+ throw new BusinessException("订单状态错误");
|
|
|
+ }
|
|
|
//确认是否到达用户地址位置
|
|
|
Address address = addressRepo.findById(orderInfo.getAddressId())
|
|
|
.orElseThrow(new BusinessException("地址不存在"));
|
|
|
@@ -311,6 +325,28 @@ public class OrderInfoService {
|
|
|
orderInfoRepo.save(orderInfo);
|
|
|
}
|
|
|
|
|
|
+ /*
|
|
|
+ 骑手到店拍照取货
|
|
|
+ */
|
|
|
+ public void pickupPhotos(Long orderId, RiderStatus status, String img) {
|
|
|
+ OrderInfo orderInfo = orderInfoRepo.findById(orderId).orElseThrow(new BusinessException("无订单"));
|
|
|
+ if (!RiderStatus.TAKE_MEAL.equals(status)) {
|
|
|
+ throw new BusinessException("状态错误");
|
|
|
+ }
|
|
|
+ if (StrUtil.isEmpty(img)) {
|
|
|
+ throw new BusinessException("照片不能为空");
|
|
|
+ }
|
|
|
+ if (!RiderStatus.ARRIVE.equals(orderInfo.getRiderStatus())) {
|
|
|
+ throw new BusinessException("订单状态错误");
|
|
|
+ }
|
|
|
+ //已取餐 待送达
|
|
|
+ orderInfo.setRiderStatus(RiderStatus.TAKE_MEAL);
|
|
|
+ //商家状态已完成
|
|
|
+ orderInfo.setMerchantStatus(MerchantStatus.CARRY_OUT);
|
|
|
+ orderInfo.setPickupPhotos(img);
|
|
|
+ orderInfoRepo.save(orderInfo);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 按用户ID查出用户/商家/骑手订单
|
|
|
*
|
|
|
@@ -394,8 +430,6 @@ public class OrderInfoService {
|
|
|
}*/
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
/*
|
|
|
支付倒计时
|
|
|
*/
|