From 428519bd1056dd90cd4589dbf85b380e403ff254 Mon Sep 17 00:00:00 2001
From: hjl <1657978663@qq.com>
Date: 星期五, 05 七月 2024 18:13:08 +0800
Subject: [PATCH] feat: 代码初始化、腾讯云短信SDK

---
 ruoyi-service/ruoyi-worker/src/main/java/com/ruoyi/worker/service/impl/MasterWorkerServiceImpl.java |   99 ++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 84 insertions(+), 15 deletions(-)

diff --git a/ruoyi-service/ruoyi-worker/src/main/java/com/ruoyi/worker/service/impl/MasterWorkerServiceImpl.java b/ruoyi-service/ruoyi-worker/src/main/java/com/ruoyi/worker/service/impl/MasterWorkerServiceImpl.java
index 0abdc49..233c475 100644
--- a/ruoyi-service/ruoyi-worker/src/main/java/com/ruoyi/worker/service/impl/MasterWorkerServiceImpl.java
+++ b/ruoyi-service/ruoyi-worker/src/main/java/com/ruoyi/worker/service/impl/MasterWorkerServiceImpl.java
@@ -1,10 +1,10 @@
 package com.ruoyi.worker.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ruoyi.common.core.constant.Constants;
 import com.ruoyi.common.core.domain.Result;
 import com.ruoyi.common.core.utils.GaoDeMapUtil;
-import com.ruoyi.common.core.utils.bean.BeanUtils;
 import com.ruoyi.worker.entity.MasterWorker;
 import com.ruoyi.worker.entity.Order;
 import com.ruoyi.worker.entity.RecoveryServe;
@@ -46,37 +46,106 @@
 
     @Override
     public List<OrderListVO> orderNotHandle(Integer userid, String longitude, String latitude) {
-        List<Order> orderList = orderService.lambdaQuery().eq(Order::getServerId, userid).eq(Order::getState, Constants.TWO)
-                .eq(Order::getIsDelete, 0).eq(Order::getType, Constants.ZERO).list();
+        QueryWrapper<Order> wrapper = new QueryWrapper<>();
+        wrapper.eq("server_id", userid)
+                .in("state", 1, 2)
+                .eq("is_delete", Constants.ZERO)
+                .orderByAsc("CASE WHEN topSort IS NULL THEN 1 ELSE 0 END")
+                .orderByAsc("topSort");
+        List<Order> orderList = orderService.list(wrapper);
         // 根据经纬度距离封装
         List<OrderNotHandleVO> list = new ArrayList<>();
+        boolean item = false;
+        for (Order order : orderList) {
+            if (null != order.getTopSort()) {
+                item = true;
+                break;
+            }
+        }
         for (Order order : orderList) {
             // 用户下单经纬度
             Double orderLongitude = order.getLongitude();
             Double orderLatitude = order.getLatitude();
+            Integer topSort = order.getTopSort();
             String orderPosition = orderLongitude + "," + orderLatitude;
             // 根据经纬度计算与师傅的距离
             Result<Long> result = GaoDeMapUtil.getDistance(orderPosition, longitude + "," + latitude);
             Long distance = result.getDatas();
+            // 回收服务信息
+            RecoveryServe recoveryServe = recoveryServeService.lambdaQuery()
+                    .eq(RecoveryServe::getId, order.getServeId())
+                    .eq(RecoveryServe::getIsDelete, 0).one();
             // vo类信息封装
             OrderListVO orderListVO = new OrderListVO(order.getServeId());
-            BeanUtils.copyProperties(orderListVO, orderListVO);
+            orderListVO.setOrderId(order.getId());
+            orderListVO.setOrderNumber(order.getOrderNumber());
+            orderListVO.setSiteId(order.getSiteId());
+            orderListVO.setSiteName(order.getSiteName());
+            orderListVO.setServeId(order.getServeId());
+            orderListVO.setServeName(order.getServeName());
+            if (null != recoveryServe) {
+                orderListVO.setServePicture(recoveryServe.getCover());
+                orderListVO.setServePrice(recoveryServe.getDefaultPrice());
+            }
+            orderListVO.setUserId(userid);
+            orderListVO.setReservationName(order.getReservationName());
+            orderListVO.setReservationPhone(order.getReservationPhone());
+            orderListVO.setReservationAddress(order.getReservationAddress());
+            orderListVO.setTime(order.getTime());
+            orderListVO.setServerId(order.getServerId());
+            orderListVO.setServerName(order.getServerName());
+            orderListVO.setServerPhone(order.getServerPhone());
+            orderListVO.setReservationRemark(order.getReservationRemark());
+            orderListVO.setOrderMoney(order.getOrderMoney());
+            orderListVO.setState(order.getState());
+            orderListVO.setAcceptTime(order.getAcceptTime());
+            orderListVO.setArriveTime(order.getArriveTime());
+            orderListVO.setType(order.getType());
+            orderListVO.setLongitude(order.getLongitude());
+            orderListVO.setLatitude(order.getLatitude());
+            orderListVO.setTopSort(topSort);
             OrderNotHandleVO vo = new OrderNotHandleVO(distance, orderListVO);
             list.add(vo);
         }
-        // 根据距离排序
-        list.sort(Comparator.comparing(OrderNotHandleVO::getDistance));
-        List<OrderListVO> resultList = list.stream().map(OrderNotHandleVO::getOrderList).collect(Collectors.toList());
-        for (OrderListVO orderListVO : resultList) {
-            Integer serveId = orderListVO.getServeId();
-            // 回收服务信息
-            RecoveryServe recoveryServe = recoveryServeService.lambdaQuery().eq(RecoveryServe::getId, serveId)
-                    .eq(RecoveryServe::getIsDelete, 0).one();
-            if (null != recoveryServe) {
-                orderListVO.setServePicture(recoveryServe.getCover());
+        if (item) {
+            return list.stream().map(OrderNotHandleVO::getOrderList).collect(Collectors.toList());
+        } else {
+            // 根据距离排序
+            list.sort(Comparator.comparing(OrderNotHandleVO::getDistance));
+            List<OrderListVO> resultList = list.stream().map(OrderNotHandleVO::getOrderList).collect(Collectors.toList());
+            for (OrderListVO orderListVO : resultList) {
+                Integer serveId = orderListVO.getServeId();
+                // 回收服务信息
+                RecoveryServe recoveryServe = recoveryServeService.lambdaQuery().eq(RecoveryServe::getId, serveId)
+                        .eq(RecoveryServe::getIsDelete, 0).one();
+                if (null != recoveryServe) {
+                    orderListVO.setServePicture(recoveryServe.getCover());
+                }
+            }
+            return resultList;
+        }
+
+    }
+
+    @Override
+    public Boolean orderTop(Integer orderId, Integer userid) {
+        // 订单代办列表
+        List<Order> orderList = orderService.lambdaQuery().eq(Order::getServerId, userid)
+                .in(Order::getState, Constants.ONE, Constants.TWO)
+                .eq(Order::getIsDelete, 0)
+                .orderByAsc(Order::getTopSort).list();
+        int itemSort = 2;
+        for (Order order : orderList) {
+            if (null != order.getTopSort()) {
+                order.setTopSort(itemSort);
+                itemSort++;
             }
         }
-        return resultList;
+        orderService.updateBatchById(orderList);
+        return orderService.lambdaUpdate().set(Order::getTopSort, Constants.ONE)
+                .eq(Order::getServerId, userid)
+                .eq(Order::getId, orderId)
+                .eq(Order::getIsDelete, 0).update();
     }
 
 }

--
Gitblit v1.7.1