Commit 0c84b2f7 by 查志伟

配送范围判断fix

parent 8bd8fed8
...@@ -32,6 +32,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -32,6 +32,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Objects;
@Service("gradDeliveryService") @Service("gradDeliveryService")
public class GradDeliveryServiceImpl extends AbstractDeliveryServiceImpl implements DeliveryService { public class GradDeliveryServiceImpl extends AbstractDeliveryServiceImpl implements DeliveryService {
...@@ -141,22 +142,18 @@ public class GradDeliveryServiceImpl extends AbstractDeliveryServiceImpl impleme ...@@ -141,22 +142,18 @@ public class GradDeliveryServiceImpl extends AbstractDeliveryServiceImpl impleme
Integer scopeConfig = deliveryInfo.getScopeConfig(); Integer scopeConfig = deliveryInfo.getScopeConfig();
// 配送范围绘制方式: 1-自定义 2-半径 // 配送范围绘制方式: 1-自定义 2-半径
if ("2".equals(scopeConfig)) { if (Objects.equals(scopeConfig, 2)) {
if (deliveryInfo.getDeliveryRadius() == null || deliveryInfo.getDeliveryRadius() <= 0) { if (deliveryInfo.getDeliveryRadius() == null || deliveryInfo.getDeliveryRadius() <= 0) {
throw new ServiceException(ResponseResult.STORE_DELIVERY_AMOUNT_ERROR); throw new ServiceException(ResponseResult.STORE_DELIVERY_AMOUNT_ERROR);
} }
//用户收货地址距离门店距离 单位米 //用户收货地址距离门店距离 单位米
double distance = LocationUtil.getDistance(Double.parseDouble(storeInfo.getLatitude()), Double.parseDouble(storeInfo.getLongitude()), double distance = LocationUtil.getDistance(Double.parseDouble(storeInfo.getLatitude()), Double.parseDouble(storeInfo.getLongitude()),
Double.parseDouble(userLatitude), Double.parseDouble(userLongitude)); Double.parseDouble(userLatitude), Double.parseDouble(userLongitude));
if (distance > deliveryInfo.getDeliveryRadius().doubleValue()) {
return false;
}
} else if (!LocationUtil.gpsIsInclude(userLongitude, userLatitude, storeInfo.getDistributionScope())) {
// 超出配送范围
return true;
}
return true; return distance <= deliveryInfo.getDeliveryRadius().doubleValue();
} else {
return LocationUtil.gpsIsInclude(userLongitude, userLatitude, storeInfo.getDistributionScope());
}
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment