From a77003cb09b1d4dabbf50f88e9354afca8042970 Mon Sep 17 00:00:00 2001
From: Helius <wangdoubleone@gmail.com>
Date: Sat, 03 Jul 2021 18:19:03 +0800
Subject: [PATCH] fix
---
gc-order/src/main/resources/mapper/order/JhyInfoMapper.xml | 5 +++++
gc-order/src/main/java/com/xzx/gc/order/mapper/JhyInfoMapper.java | 3 +++
gc-order/src/main/java/com/xzx/gc/order/service/JhyOrderService.java | 10 ++++------
3 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/gc-order/src/main/java/com/xzx/gc/order/mapper/JhyInfoMapper.java b/gc-order/src/main/java/com/xzx/gc/order/mapper/JhyInfoMapper.java
index b2a3f43..67b3545 100644
--- a/gc-order/src/main/java/com/xzx/gc/order/mapper/JhyInfoMapper.java
+++ b/gc-order/src/main/java/com/xzx/gc/order/mapper/JhyInfoMapper.java
@@ -4,7 +4,10 @@
import com.xzx.gc.util.GcMapper;
import org.apache.ibatis.annotations.Param;
+import java.util.List;
+
public interface JhyInfoMapper extends GcMapper<JhyInfo> {
JhyInfo selectJhyInfoByUserId(@Param("userId") String userId);
+ List<JhyInfo> selectJhyInfoListInAddressRange(@Param("addressId") Long addressId);
}
diff --git a/gc-order/src/main/java/com/xzx/gc/order/service/JhyOrderService.java b/gc-order/src/main/java/com/xzx/gc/order/service/JhyOrderService.java
index 28da66f..3add922 100644
--- a/gc-order/src/main/java/com/xzx/gc/order/service/JhyOrderService.java
+++ b/gc-order/src/main/java/com/xzx/gc/order/service/JhyOrderService.java
@@ -1,6 +1,7 @@
package com.xzx.gc.order.service;
import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.StrUtil;
import com.github.pagehelper.PageHelper;
@@ -59,17 +60,14 @@
public void addJhyOrder(AddJhyOrderDto orderDto) {
JhyInfo jhyInfo = jhyInfoMapper.selectJhyInfoByUserId(orderDto.getUserId());
- if (jhyInfo == null) {
- throw new RestException(-3, "集物员不存在");
- }
-
if (jhyInfo != null && JhyInfo.CHECK_PASS.equals(jhyInfo.getStatus())) {
throw new RestException(-3, "集货员不能下单");
}
AddressInfo addressInfo = addressMapper.selectByPrimaryKey(orderDto.getAddressId());
- double distance = LocationUtils.getDistance(Convert.toDouble(jhyInfo.getLon()), Convert.toDouble(jhyInfo.getLat()), Convert.toDouble(addressInfo.getLongitude()), Convert.toDouble(addressInfo.getLatitude()));
- if (distance > 500) {
+
+ List<JhyInfo> jhyInfos = jhyInfoMapper.selectJhyInfoListInAddressRange(addressInfo.getAddressId());
+ if (CollUtil.isEmpty(jhyInfos)) {
throw new RestException(-3, "该区域暂无集物员");
}
diff --git a/gc-order/src/main/resources/mapper/order/JhyInfoMapper.xml b/gc-order/src/main/resources/mapper/order/JhyInfoMapper.xml
index cde8ce2..6416ea4 100644
--- a/gc-order/src/main/resources/mapper/order/JhyInfoMapper.xml
+++ b/gc-order/src/main/resources/mapper/order/JhyInfoMapper.xml
@@ -6,4 +6,9 @@
select * from xzx_jhy_info where user_id=#{userId}
</select>
+
+ <select id="selectJhyInfoListInAddressRange" resultType="com.xzx.gc.entity.JhyInfo">
+ select * from xzx_jhy_info a
+ where 500 > lat_lng_distance(a.lat, a.lon, (select latitude from xzx_user_address_info where address_id=#{addressId}), (select longitude from xzx_user_address_info where address_id=#{addressId}))*1000
+ </select>
</mapper>
\ No newline at end of file
--
Gitblit v1.9.1