From 9fe8f2b9eb26431e0da9ddcc55c8d0ca2f6d259c Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Fri, 16 Jul 2021 15:42:58 +0800
Subject: [PATCH] Merge branch 'score-shop' of http://120.27.238.55:7000/r/xzx into score-shop

---
 gc-order/src/main/java/com/xzx/gc/order/service/JhyOrderService.java |   15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)

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..6c8c7df 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;
@@ -57,19 +58,19 @@
     @Autowired
     private IdUtils idUtils;
 
+    @Autowired
+    private DistribService distribService;
+
     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, "该区域暂无集物员");
         }
 
@@ -232,5 +233,7 @@
 
         userAccount.setCollectScore(userScore.add(totalScore).setScale( 0, BigDecimal.ROUND_DOWN ).toString());
         accountMapper.updateByPrimaryKey(userAccount);
+
+        distribService.distribRecord(order.getId(), order.getUserId());
     }
 }

--
Gitblit v1.9.1