夏文涛 1 rok pred
rodič
commit
8ac56b9f1c
22 zmenil súbory, kde vykonal 801 pridanie a 91 odobranie
  1. 37 0
      db/insert_250402.sql
  2. 35 10
      src/main/java/com/sqx/modules/app/controller/app/AppController.java
  3. 14 9
      src/main/java/com/sqx/modules/app/dao/UserDao.java
  4. 44 0
      src/main/java/com/sqx/modules/app/entity/queryRiderVo.java
  5. 28 0
      src/main/java/com/sqx/modules/app/entity/queryRidersVo.java
  6. 4 1
      src/main/java/com/sqx/modules/app/service/UserService.java
  7. 21 11
      src/main/java/com/sqx/modules/app/service/impl/UserServiceImpl.java
  8. 94 22
      src/main/java/com/sqx/modules/errand/controller/app/AppTbIndentController.java
  9. 47 0
      src/main/java/com/sqx/modules/errand/controller/app/TransferRecordController.java
  10. 4 1
      src/main/java/com/sqx/modules/errand/dao/TbIndentDao.java
  11. 25 0
      src/main/java/com/sqx/modules/errand/dao/TransferRecordDao.java
  12. 22 0
      src/main/java/com/sqx/modules/errand/dto/RiderTransferOrdersDTO.java
  13. 54 0
      src/main/java/com/sqx/modules/errand/entity/TransferRecordEntity.java
  14. 43 0
      src/main/java/com/sqx/modules/errand/entity/TransferRecordVo.java
  15. 21 9
      src/main/java/com/sqx/modules/errand/service/TbIndentService.java
  16. 16 0
      src/main/java/com/sqx/modules/errand/service/TransferRecordService.java
  17. 107 3
      src/main/java/com/sqx/modules/errand/service/impl/TbIndentServiceImpl.java
  18. 47 0
      src/main/java/com/sqx/modules/errand/service/impl/TransferRecordServiceImpl.java
  19. 55 0
      src/main/java/com/sqx/modules/errand/vo/queryOrderInfoVo.java
  20. 22 1
      src/main/resources/mapper/app/UserDao.xml
  21. 48 24
      src/main/resources/mapper/errand/TbIndentMapper.xml
  22. 13 0
      src/main/resources/mapper/errand/TransferRecordDao.xml

+ 37 - 0
db/insert_250402.sql

@@ -0,0 +1,37 @@
+/*
+ Navicat Premium Data Transfer
+
+ Source Server         : 外卖测试108
+ Source Server Type    : MySQL
+ Source Server Version : 50744
+ Source Host           : 172.16.20.108:3306
+ Source Schema         : tcwm2.5
+
+ Target Server Type    : MySQL
+ Target Server Version : 50744
+ File Encoding         : 65001
+
+ Date: 02/04/2025 09:31:40
+*/
+
+SET NAMES utf8mb4;
+SET FOREIGN_KEY_CHECKS = 0;
+
+-- ----------------------------
+-- Table structure for transfer_record
+-- ----------------------------
+DROP TABLE IF EXISTS `transfer_record`;
+CREATE TABLE `transfer_record`  (
+  `id` int(20) NOT NULL AUTO_INCREMENT COMMENT '记录id',
+  `user_id` int(11) NULL DEFAULT NULL COMMENT '骑手ID',
+  `user_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '骑手名称',
+  `user_phone` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '骑手手机号',
+  `order_id` int(11) NULL DEFAULT NULL COMMENT '订单ID',
+  `receve_time` datetime(0) NULL DEFAULT NULL COMMENT '接单时间',
+  `station_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '站点名称',
+  `delete_flag` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '删除标识;0未删除、1已删除',
+  PRIMARY KEY (`id`) USING BTREE,
+  INDEX `order_id_idx`(`order_id`) USING BTREE COMMENT '订单ID'
+) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;
+
+SET FOREIGN_KEY_CHECKS = 1;

+ 35 - 10
src/main/java/com/sqx/modules/app/controller/app/AppController.java

@@ -1,24 +1,28 @@
 package com.sqx.modules.app.controller.app;
 
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.sqx.common.utils.PageUtils;
 import com.sqx.common.utils.Result;
 import com.sqx.modules.app.annotation.Login;
 import com.sqx.modules.app.annotation.LoginUser;
 import com.sqx.modules.app.entity.UserEntity;
+import com.sqx.modules.app.entity.queryRidersVo;
 import com.sqx.modules.app.service.AppService;
 import com.sqx.modules.app.service.UserService;
 import com.sqx.modules.common.service.CommonInfoService;
+import com.sqx.modules.errand.vo.queryOrderInfoVo;
 import com.sqx.modules.utils.MD5Util;
 import icu.xuyijie.secureapi.annotation.DecryptParam;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.RequestAttribute;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.ResponseBody;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.Arrays;
+import java.util.List;
 
 /**
  * APP登录授权
@@ -36,6 +40,28 @@ public class AppController {
     private CommonInfoService commonInfoService;
 
     @Login
+    @GetMapping(value = "findRiders")
+    @ApiOperation("查找被转单骑手")
+    public Result findRiders(@RequestAttribute Long userId, @RequestParam Integer page, @RequestParam Integer limit, String keyword) {
+        UserEntity userEntity = userService.selectUserById(userId);
+        if (userEntity != null) {
+            //tb_user表中的user_type = 2 标识当前用户是骑手,
+            //tb_user表中的rider_station_id 标识当前骑手所在站点,
+            //tb_user表中的on_line_flag 中存储的值0是休息,1是接单中;
+            //查找被转单骑手是要找同一个站点,并且接单中的
+            Integer ursIds = userEntity.getRiderStationId();
+            if(ursIds == null){
+                IPage<queryRidersVo> pages = new Page<>();
+                PageUtils pageUtils = new PageUtils(pages);
+                return Result.success().put("data", pageUtils);
+            }
+            Result result = userService.queryRiders(page, limit,userId, ursIds,keyword);
+            return result;
+        }
+        return Result.error("用户不存在!");
+    }
+
+    @Login
     @RequestMapping(value = "/updatePwd", method = RequestMethod.POST)
     @ResponseBody
     @ApiOperation("用户端修改密码")
@@ -63,7 +89,7 @@ public class AppController {
     @RequestMapping(value = "/updateUser", method = RequestMethod.POST)
     @ApiOperation("用户修改个人信息")
     @ResponseBody
-    public Result updateUserImageUrl(@RequestAttribute("userId") Long userId,@RequestBody UserEntity userEntity) {
+    public Result updateUserImageUrl(@RequestAttribute("userId") Long userId, @RequestBody UserEntity userEntity) {
         userEntity.setUserId(userId);
         userService.updateById(userEntity);
         return Result.success();
@@ -110,7 +136,7 @@ public class AppController {
     @RequestMapping(value = "/updateClientId", method = RequestMethod.POST)
     @ApiOperation("用户端绑定消息推送clientId")
     @ResponseBody
-    public Result updateClientId(@DecryptParam String clientId, @RequestAttribute Long userId,Integer sysPhone) {
+    public Result updateClientId(@DecryptParam String clientId, @RequestAttribute Long userId, Integer sysPhone) {
         UserEntity userEntity = userService.getById(userId);
         if (userEntity != null) {
             //检查是否有其他用户设置这个clientId 如果有 则清除其他用户
@@ -124,12 +150,11 @@ public class AppController {
     }
 
 
-
     @Login
     @RequestMapping(value = "/updateRiderClientId", method = RequestMethod.POST)
     @ApiOperation("骑手端绑定消息推送clientId")
     @ResponseBody
-    public Result updateRiderClientId(@DecryptParam String clientId, @RequestAttribute Long userId,Integer sysPhone) {
+    public Result updateRiderClientId(@DecryptParam String clientId, @RequestAttribute Long userId, Integer sysPhone) {
         UserEntity userEntity = userService.selectUserById(userId);
         if (userEntity != null) {
             userService.updateUserRiderClientIdIsNull(clientId);

+ 14 - 9
src/main/java/com/sqx/modules/app/dao/UserDao.java

@@ -5,6 +5,9 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.sqx.common.utils.Result;
 import com.sqx.modules.app.entity.UserEntity;
+import com.sqx.modules.app.entity.queryRiderVo;
+import com.sqx.modules.app.entity.queryRidersVo;
+import com.sqx.modules.errand.vo.queryOrderInfoVo;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -17,10 +20,12 @@ import java.util.Map;
  */
 @Mapper
 public interface UserDao extends BaseMapper<UserEntity> {
+    queryRiderVo queryRider(Long userId);
 
+    IPage<queryRidersVo> queryRiders(Page<queryRidersVo> pages, Long userId, Integer riderStationId, String keyword);
 
     IPage<UserEntity> selectUserPage(Page<UserEntity> page, String search, Integer sex, String platform, String sysPhone, Integer status,
-                                     Integer type, String userName, Integer isVip, Integer shopAdminFlag,String nickName);
+                                     Integer type, String userName, Integer isVip, Integer shopAdminFlag, String nickName);
 
     int queryInviterCount(@Param("inviterCode") String inviterCode);
 
@@ -40,7 +45,7 @@ public interface UserDao extends BaseMapper<UserEntity> {
     IPage<UserEntity> selectUserList(Page<UserEntity> iPage, String userName);
 
 
-    int updateCashDeposit(@Param("userId") Long userId,@Param("cashDeposit") Double cashDeposit);
+    int updateCashDeposit(@Param("userId") Long userId, @Param("cashDeposit") Double cashDeposit);
 
     void updateMoney(Integer type, Long userId, Double money);
 
@@ -50,16 +55,16 @@ public interface UserDao extends BaseMapper<UserEntity> {
 
     int topUpMoney(@Param("classify") Integer classify, @Param("orderId") String out_trade_no, @Param("money") Double money, @Param("userId") Long userId, @Param("state") Integer state, @Param("date") String date, @Param("date1") String date1, @Param("type") Integer type);
 
-    int certification(@Param("userId") Long userId,@Param("phone") String phone, @Param("userName") String userName,
-                      @Param("identityCardNumber") String identityCardNumber,@Param("identityCardFront") String identityCardFront,
-                      @Param("identityCardVerso") String identityCardVerso,  @Param("selfIdentityCard") String selfIdentityCard,
-                      @Param("format") String format,@Param("checkNumber") String checkNumber, @Param("cashDeposit") BigDecimal cashDeposit);
+    int certification(@Param("userId") Long userId, @Param("phone") String phone, @Param("userName") String userName,
+                      @Param("identityCardNumber") String identityCardNumber, @Param("identityCardFront") String identityCardFront,
+                      @Param("identityCardVerso") String identityCardVerso, @Param("selfIdentityCard") String selfIdentityCard,
+                      @Param("format") String format, @Param("checkNumber") String checkNumber, @Param("cashDeposit") BigDecimal cashDeposit);
 
     Result shopBindingQrCode(Long userId, String cashQrCode);
 
-    void userFeedback(Integer feedbackType,Long userId, String userEmail, Integer feedbackScore, String feedbackMessage, String format);
+    void userFeedback(Integer feedbackType, Long userId, String userEmail, Integer feedbackScore, String feedbackMessage, String format);
 
-    int addRedPacket(@Param("userId") Long userId, @Param("redPacketType")String redPacketType, @Param("minimumAmount")BigDecimal minimumAmount,@Param("redPacketAmount") BigDecimal redPacketAmount,@Param("redPacketTitle") String redPacketTitle,@Param("expirationTime") String expirationTime, @Param("createTime")String createTime);
+    int addRedPacket(@Param("userId") Long userId, @Param("redPacketType") String redPacketType, @Param("minimumAmount") BigDecimal minimumAmount, @Param("redPacketAmount") BigDecimal redPacketAmount, @Param("redPacketTitle") String redPacketTitle, @Param("expirationTime") String expirationTime, @Param("createTime") String createTime);
 
     int updateOldUser(Long userId);
 
@@ -73,5 +78,5 @@ public interface UserDao extends BaseMapper<UserEntity> {
 
     int updateUserShopClientIdIsNull(String clientid);
 
-    List<UserEntity> selectRiderUserByOnLineFlag(String distance,String lng,String lat);
+    List<UserEntity> selectRiderUserByOnLineFlag(String distance, String lng, String lat);
 }

+ 44 - 0
src/main/java/com/sqx/modules/app/entity/queryRiderVo.java

@@ -0,0 +1,44 @@
+package com.sqx.modules.app.entity;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ * @Author: xwt
+ * @Date: 2025/4/1 星期二 14:19
+ * @Description: com.sqx.modules.errand.vo
+ * @Version: 1.0
+ */
+@Data
+@ApiModel("获取待转单骑手数据")
+public class queryRiderVo {
+    @ApiModelProperty("用户id")
+    private Long userId;
+
+    @ApiModelProperty("骑手名称")
+    private String userName;
+
+    @ApiModelProperty("骑手手机号")
+    private String phone;
+
+    @ApiModelProperty("实名认证审核状态(0:待审核;1:审核通过;2:审核不通过)")
+    private String checkCertification;
+
+    @ApiModelProperty("保证金")
+    private BigDecimal cashDeposit;
+
+    @ApiModelProperty("站点名称")
+    private String stationName;
+
+    @ApiModelProperty("普通用户微信小程序openid")
+    private String openId;
+
+    @ApiModelProperty("骑手用户微信小程序openid")
+    private String riderOpenId;
+
+    @ApiModelProperty("设备id")
+    private String clientid;
+}

+ 28 - 0
src/main/java/com/sqx/modules/app/entity/queryRidersVo.java

@@ -0,0 +1,28 @@
+package com.sqx.modules.app.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * @Author: xwt
+ * @Date: 2025/4/1 星期二 14:19
+ * @Description: com.sqx.modules.errand.vo
+ * @Version: 1.0
+ */
+@Data
+@ApiModel("获取待转单骑手数据")
+public class queryRidersVo {
+    @ApiModelProperty("用户id")
+    private Long userId;
+
+    @ApiModelProperty("骑手名称")
+    private String userName;
+
+    @ApiModelProperty("骑手手机号")
+    private String phone;
+
+    @ApiModelProperty("站点名称")
+    private String stationName;
+}

+ 4 - 1
src/main/java/com/sqx/modules/app/service/UserService.java

@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import com.sqx.common.utils.PageUtils;
 import com.sqx.common.utils.Result;
 import com.sqx.modules.app.entity.UserEntity;
+import com.sqx.modules.app.entity.queryRiderVo;
 import com.sqx.modules.errand.entity.Feedback;
 import org.apache.poi.ss.formula.functions.T;
 
@@ -170,7 +171,6 @@ public interface UserService extends IService<UserEntity> {
      */
     Result login(String phone, String pwd);
 
-
     /**
      * 根据 code 获取openId
      *
@@ -180,6 +180,9 @@ public interface UserService extends IService<UserEntity> {
      */
     Result getOpenId(String code, Long userId);
 
+    queryRiderVo queryRider(Long userId);
+
+    Result queryRiders(Integer page, Integer limit, Long userId,Integer riderStationId, String keyword);
 
     /**
      * 根据用户id查询用户

+ 21 - 11
src/main/java/com/sqx/modules/app/service/impl/UserServiceImpl.java

@@ -36,16 +36,14 @@ import com.sqx.common.utils.Result;
 import com.sqx.modules.app.dao.MsgDao;
 import com.sqx.modules.app.dao.UserDao;
 import com.sqx.modules.app.dao.UserMoneyDao;
-import com.sqx.modules.app.entity.AppUserInfo;
-import com.sqx.modules.app.entity.Msg;
-import com.sqx.modules.app.entity.UserEntity;
-import com.sqx.modules.app.entity.UserMoney;
+import com.sqx.modules.app.entity.*;
 import com.sqx.modules.app.service.UserService;
 import com.sqx.modules.app.utils.JwtUtils;
 import com.sqx.modules.app.utils.UserConstantInterface;
 import com.sqx.modules.common.entity.CommonInfo;
 import com.sqx.modules.common.service.CommonInfoService;
 import com.sqx.modules.errand.entity.Feedback;
+import com.sqx.modules.errand.vo.queryOrderInfoVo;
 import com.sqx.modules.file.utils.Md5Utils;
 import com.sqx.modules.integral.dao.UserIntegralDao;
 import com.sqx.modules.integral.entity.UserIntegral;
@@ -99,6 +97,18 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements
     @Autowired
     private UserIntegralDao userIntegralDao;
 
+    @Override
+    public queryRiderVo queryRider(Long userId) {
+        queryRiderVo result = userDao.queryRider( userId);
+        return result;
+    }
+
+    @Override
+    public Result queryRiders(Integer page, Integer limit, Long userId, Integer riderStationId, String keyword) {
+        Page<queryRidersVo> pages = new Page<>(page, limit);
+        PageUtils pageUtils = new PageUtils(userDao.queryRiders(pages, userId, riderStationId, keyword));
+        return Result.success().put("data", pageUtils);
+    }
 
     @Override
     public UserEntity queryByPhone(String phone) {
@@ -292,9 +302,9 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements
                 }
 
             }
-            if(StringUtils.isEmpty(userInfo.getNickName()) || "微信用户".equals(userInfo.getNickName())){
-                if(StringUtils.isNotEmpty(userInfo.getPhone())){
-                    userInfo.setNickName(userInfo.getPhone().replaceAll("(\\d{3})\\d*([0-9a-zA-Z]{4})","$1****$2"));
+            if (StringUtils.isEmpty(userInfo.getNickName()) || "微信用户".equals(userInfo.getNickName())) {
+                if (StringUtils.isNotEmpty(userInfo.getPhone())) {
+                    userInfo.setNickName(userInfo.getPhone().replaceAll("(\\d{3})\\d*([0-9a-zA-Z]{4})", "$1****$2"));
                 }
             }
 
@@ -346,9 +356,9 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements
                 userInfo1.setNewUserFlag(1);
                 userInfo1.setNewUserFlagWm(1);
 
-                if(StringUtils.isEmpty(userInfo1.getNickName()) || "微信用户".equals(userInfo1.getNickName())){
-                    if(StringUtils.isNotEmpty(userInfo1.getPhone())){
-                        userInfo1.setNickName(userInfo1.getPhone().replaceAll("(\\d{3})\\d*([0-9a-zA-Z]{4})","$1****$2"));
+                if (StringUtils.isEmpty(userInfo1.getNickName()) || "微信用户".equals(userInfo1.getNickName())) {
+                    if (StringUtils.isNotEmpty(userInfo1.getPhone())) {
+                        userInfo1.setNickName(userInfo1.getPhone().replaceAll("(\\d{3})\\d*([0-9a-zA-Z]{4})", "$1****$2"));
                     }
                 }
 
@@ -1032,7 +1042,7 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements
 
     @Override
     public PageUtils selectUserPage(Integer page, Integer limit, String search, Integer sex, String platform, String sysPhone, Integer status,
-                                       Integer type, String userName, Integer isVip, Integer shopAdminFlag, String nickName) {
+                                    Integer type, String userName, Integer isVip, Integer shopAdminFlag, String nickName) {
         Page<UserEntity> pages = new Page<>(page, limit);
         return new PageUtils(baseMapper.selectUserPage(pages, search, sex, platform, sysPhone, status, type, userName, isVip, shopAdminFlag, nickName));
     }

+ 94 - 22
src/main/java/com/sqx/modules/errand/controller/app/AppTbIndentController.java

@@ -1,46 +1,46 @@
 package com.sqx.modules.errand.controller.app;
 
+import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.json.JSONUtil;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.sqx.common.exception.SqxException;
 import com.sqx.common.utils.PageUtils;
 import com.sqx.common.utils.Result;
 import com.sqx.modules.app.annotation.Login;
 import com.sqx.modules.app.entity.UserEntity;
+import com.sqx.modules.app.entity.queryRiderVo;
 import com.sqx.modules.app.service.UserService;
 import com.sqx.modules.common.service.CommonInfoService;
 import com.sqx.modules.errand.dto.*;
-import com.sqx.modules.errand.entity.ErrandAddress;
-import com.sqx.modules.errand.entity.ErrandComplaint;
-import com.sqx.modules.errand.entity.ErrandEvaluate;
-import com.sqx.modules.errand.entity.ErrandRedPacket;
-import com.sqx.modules.errand.entity.TbIndent;
+import com.sqx.modules.errand.entity.*;
 import com.sqx.modules.errand.service.ErrandComplaintService;
 import com.sqx.modules.errand.service.TbIndentService;
+import com.sqx.modules.errand.service.TransferRecordService;
+import com.sqx.modules.errand.service.impl.TransferRecordServiceImpl;
+import com.sqx.modules.errand.vo.queryOrderInfoVo;
+import com.sqx.modules.printInfo.entity.PrintInfo;
 import icu.xuyijie.secureapi.annotation.DecryptParam;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
 import org.apache.poi.ss.formula.functions.T;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.RequestAttribute;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import javax.validation.Valid;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.text.SimpleDateFormat;
+import java.util.*;
 
 @RestController
 @RequestMapping("/app/tbindent")
 @Api(value = "订单", tags = {"订单"})
+@Slf4j
 public class AppTbIndentController {
-
+    @Autowired
+    private TransferRecordService transferRecordService;
     @Autowired
     private TbIndentService tbIndentService;
     @Autowired
@@ -243,9 +243,22 @@ public class AppTbIndentController {
     @Login
     @GetMapping(value = "findRiderIndent")
     @ApiOperation("骑手查看自己所有订单")
-    public Result findRiderIndent(@RequestAttribute Long userId, Integer page, Integer limit, String indentState) {
+    public Result findRiderIndent(@RequestAttribute Long userId, Integer page, Integer limit, String indentState, String keyword) {
+
+        return tbIndentService.findRiderIndent(userId, page, limit, indentState, keyword);
+    }
 
-        return tbIndentService.findRiderIndent(userId, page, limit, indentState);
+    @Login
+    @GetMapping(value = "findRiderIndentByIds")
+    @ApiOperation("骑手查看待转单订单")
+    public Result findRiderIndentByIds(@RequestAttribute Long userId, @RequestParam Integer page, @RequestParam Integer limit, String indentIds) {
+        if (StringUtils.isEmpty(indentIds)) {
+            IPage<queryOrderInfoVo> pages = new Page<>();
+            PageUtils pageUtils = new PageUtils(pages);
+            return Result.success().put("data", pageUtils);
+        }
+        List<String> result = Arrays.asList(indentIds.split(","));
+        return tbIndentService.findRiderIndentByIds(userId, page, limit, result);
     }
 
     @Login
@@ -282,7 +295,7 @@ public class AppTbIndentController {
     @Login
     @PutMapping(value = "delivery-img/{indentNumber}")
     @ApiOperation("骑手上传送达照片")
-    public Result riderUploadDeliveryImg(@RequestAttribute Long userId, @PathVariable @ApiParam("跑腿订单id") String indentNumber, @DecryptParam @ApiParam("图片地址") String imgs){
+    public Result riderUploadDeliveryImg(@RequestAttribute Long userId, @PathVariable @ApiParam("跑腿订单id") String indentNumber, @DecryptParam @ApiParam("图片地址") String imgs) {
         tbIndentService.riderUploadDeliveryImg(userId, indentNumber, imgs);
         return Result.success();
     }
@@ -359,6 +372,65 @@ public class AppTbIndentController {
         return Result.success();
     }
 
+    @Login
+    @ApiOperation("批量转单")
+    @PostMapping("/transferOfOrders")
+    public Result transferOfOrders(@RequestAttribute Long userId, @Valid RiderTransferOrdersDTO transferOrderDTO) {
+        if (userId.equals(transferOrderDTO.getRiderId())) {
+            throw new SqxException("不能转单给自己!");
+        }
+        //查看被转单骑手是否符合条件
+        queryRiderVo riderUser = tbIndentService.getNewRicherCheck(transferOrderDTO.getRiderId());
+        if(riderUser == null){
+            throw new SqxException("被转单骑手已失效");
+        }
+
+        //先查一遍订单 防止存在无效订单
+        List<TbIndent> datas = tbIndentService.findIndentsByIds(transferOrderDTO.getIndentIds());
+        for (TbIndent data : datas) {
+            if (!data.getRiderUserId().equals(userId)) {
+                throw new SqxException("不能操作非自己的订单");
+            }
+
+            if (!"3".equals(data.getIndentState())) {
+                throw new SqxException("订单状态发生变更,请刷新后重试!");
+            }
+
+            // 开始转单
+            data.setRiderUserId(transferOrderDTO.getRiderId());
+            data.setIsRider(1);
+        }
+
+        boolean transferOrders = tbIndentService.saveBatch(datas);
+        if(transferOrders){
+            String format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
+            List<TransferRecordEntity> trs = new ArrayList<>();
+            for (TbIndent data : datas) {
+                TransferRecordEntity tr = new TransferRecordEntity();
+                tr.setUserId(riderUser.getUserId());
+                tr.setUserName(riderUser.getUserName());
+                tr.setUserPhone(riderUser.getPhone());
+                tr.setOrderId(data.getOrderId());
+                tr.setReceveTime(format);
+                tr.setStationName(riderUser.getStationName());
+                tr.setDeleteFlag(0);
+                trs.add(tr);
+                // 消息通知
+                tbIndentService.noticeAfterTransfer(data,riderUser);
+            }
+            if(trs != null && trs.size() > 0){
+                boolean result = transferRecordService.insertBatchPrintInfo(trs);
+                if(!result){
+                    log.info("转单记录新增失败:"+ JSONUtil.toJsonStr(trs));
+                }
+            }
+        }else{
+            log.info("转单操作失败:"+ JSONUtil.toJsonStr(datas));
+        }
+
+        return Result.success();
+    }
+
     @ApiOperation("获取骑手工作时间段及时效信息")
     @GetMapping("work-time")
     public Result getWorkTime() {
@@ -390,12 +462,12 @@ public class AppTbIndentController {
         if (datas.getTotalCount() == 1) {
             //校验当前骑手是否能接单
             Result checkData = tbIndentService.checkIndent(userId, acquireCode);
-            if((int)checkData.get("code") != 0){
+            if ((int) checkData.get("code") != 0) {
                 return checkData;//Result.error("当前订单无法接单");
             }
         }
 
-        return Result.success().put("data",datas);
+        return Result.success().put("data", datas);
     }
     //endregion
 

+ 47 - 0
src/main/java/com/sqx/modules/errand/controller/app/TransferRecordController.java

@@ -0,0 +1,47 @@
+package com.sqx.modules.errand.controller.app;
+
+import cn.hutool.json.JSONUtil;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.sqx.common.exception.SqxException;
+import com.sqx.common.utils.PageUtils;
+import com.sqx.common.utils.Result;
+import com.sqx.modules.app.annotation.Login;
+import com.sqx.modules.app.entity.UserEntity;
+import com.sqx.modules.app.entity.queryRiderVo;
+import com.sqx.modules.app.service.UserService;
+import com.sqx.modules.common.service.CommonInfoService;
+import com.sqx.modules.errand.dto.*;
+import com.sqx.modules.errand.entity.*;
+import com.sqx.modules.errand.service.ErrandComplaintService;
+import com.sqx.modules.errand.service.TbIndentService;
+import com.sqx.modules.errand.service.TransferRecordService;
+import com.sqx.modules.errand.vo.queryOrderInfoVo;
+import icu.xuyijie.secureapi.annotation.DecryptParam;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.validation.Valid;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+@RestController
+@RequestMapping("/app/transferRecord")
+@Api(value = "转单记录", tags = {"转单记录"})
+@Slf4j
+public class TransferRecordController {
+    @Autowired
+    private TransferRecordService transferRecordService;
+
+    @Login
+    @GetMapping(value = "queryTransferRecords")
+    @ApiOperation("查看转单记录分页数据")
+    public Result queryTransferRecords(@RequestAttribute Long userId, @RequestParam Integer page, @RequestParam Integer limit, @RequestParam Integer orderId) {
+        return transferRecordService.transferRecordById(page, limit, orderId);
+    }
+}

+ 4 - 1
src/main/java/com/sqx/modules/errand/dao/TbIndentDao.java

@@ -10,6 +10,7 @@ import com.sqx.modules.errand.entity.ErrandAddress;
 import com.sqx.modules.errand.entity.ErrandRedPacket;
 import com.sqx.modules.errand.entity.TbIndent;
 import com.sqx.modules.errand.vo.ShopWaitAcceptOrderVO;
+import com.sqx.modules.errand.vo.queryOrderInfoVo;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -44,7 +45,9 @@ public interface TbIndentDao extends BaseMapper<TbIndent> {
 
     void orderIndentReceiv(Long userId, String orderId, String format,String state);
 
-    IPage<TbIndent> findRiderIndent(Page<TbIndent> pages, Long userId, String indentState);
+    IPage<TbIndent> findRiderIndent(Page<TbIndent> pages, Long userId, String indentState,String keyword);
+
+    IPage<queryOrderInfoVo> findRiderIndentByIds(Page<queryOrderInfoVo> pages, Long userId, List<String> indentIds);
 
     TbIndent indentRiderMessage(String indentNumber, double riderLng, double riderLat);
 

+ 25 - 0
src/main/java/com/sqx/modules/errand/dao/TransferRecordDao.java

@@ -0,0 +1,25 @@
+package com.sqx.modules.errand.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.sqx.modules.errand.entity.TransferRecordEntity;
+import com.sqx.modules.errand.entity.TransferRecordVo;
+import com.sqx.modules.errand.vo.queryOrderInfoVo;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author www.javacoder.top
+ * @since 2022-11-04
+ */
+@Mapper
+public interface TransferRecordDao extends BaseMapper<TransferRecordEntity> {
+
+    IPage<TransferRecordVo> queryTransferRecordPages(Page<TransferRecordVo> pages, Integer orderId);
+}

+ 22 - 0
src/main/java/com/sqx/modules/errand/dto/RiderTransferOrdersDTO.java

@@ -0,0 +1,22 @@
+package com.sqx.modules.errand.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
+import java.util.List;
+
+@Data
+@ApiModel("骑手转单dto")
+public class RiderTransferOrdersDTO {
+
+    @ApiModelProperty(value = "配送单集合id", required = true)
+    @NotEmpty(message = "配送单集合id不能为空")
+    private List<Long> indentIds;
+
+    @ApiModelProperty("待分配骑手ID")
+    private Long riderId;
+
+}

+ 54 - 0
src/main/java/com/sqx/modules/errand/entity/TransferRecordEntity.java

@@ -0,0 +1,54 @@
+package com.sqx.modules.errand.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+
+/**
+ * 用户
+ */
+@Data
+@ApiModel("转单记录")
+@TableName("transfer_record")
+public class TransferRecordEntity implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    @TableId(type = IdType.AUTO)
+    @ApiModelProperty("主键id")
+    private Integer id;
+
+    @ApiModelProperty("骑手id")
+    private Long userId;
+
+
+    @ApiModelProperty("骑手名称")
+    private String userName;
+
+
+    @ApiModelProperty("骑手手机号")
+    private String userPhone;
+
+
+    @ApiModelProperty("订单ID")
+    private Long orderId;
+
+
+    @ApiModelProperty("接单时间")
+    private String receveTime;
+
+
+    @ApiModelProperty("站点名称")
+    private String stationName;
+
+
+    @ApiModelProperty("是否删除(0:未删除;1:删除)")
+    private Integer deleteFlag;
+}

+ 43 - 0
src/main/java/com/sqx/modules/errand/entity/TransferRecordVo.java

@@ -0,0 +1,43 @@
+package com.sqx.modules.errand.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+
+/**
+ * 用户
+ */
+@Data
+@ApiModel("转单记录")
+public class TransferRecordVo implements Serializable {
+    @ApiModelProperty("主键id")
+    private Integer id;
+
+    @ApiModelProperty("骑手id")
+    private Long userId;
+
+    @ApiModelProperty("骑手名称")
+    private String userName;
+
+    @ApiModelProperty("骑手手机号")
+    private String userPhone;
+
+    @ApiModelProperty("订单ID")
+    private Long orderId;
+
+    @ApiModelProperty("接单时间")
+    private String receveTime;
+
+    @ApiModelProperty("支付时间")
+    private String payTime;
+
+    @ApiModelProperty("站点名称")
+    private String stationName;
+
+}

+ 21 - 9
src/main/java/com/sqx/modules/errand/service/TbIndentService.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import com.sqx.common.utils.PageUtils;
 import com.sqx.common.utils.Result;
 import com.sqx.modules.app.entity.UserEntity;
+import com.sqx.modules.app.entity.queryRiderVo;
 import com.sqx.modules.datacentre.query.DataCenterQuery;
 import com.sqx.modules.errand.dto.*;
 import com.sqx.modules.errand.entity.ErrandAddress;
@@ -16,6 +17,12 @@ import java.util.List;
 
 public interface TbIndentService extends IService<TbIndent> {
 
+    void noticeAfterTransfer(TbIndent indent,queryRiderVo user);
+
+    queryRiderVo getNewRicherCheck(Long riderUserId);
+
+    List<TbIndent> findIndentsByIds(List<Long> ids);
+
     TbIndent findIndentByPayOrdersNo(String ordersNo);
 
     void sendNewIndentMsg(TbIndent indent);
@@ -34,11 +41,13 @@ public interface TbIndentService extends IService<TbIndent> {
 
     Result riderBuyGoods(TbIndent tbIndent);
 
-    Result findRiderIndent(Long userId, Integer page, Integer limit, String indentState);
+    Result findRiderIndent(Long userId, Integer page, Integer limit, String indentState, String keyword);
+
+    Result findRiderIndentByIds(Long userId, Integer page, Integer limit, List<String> indentIds);
 
     TbIndent indentMessage(String indentNumber, double ol, double od);
 
-    Result riderCancleIndent(String indentNumber,Integer type);
+    Result riderCancleIndent(String indentNumber, Integer type);
 
     Result riderDelivery(Long userId, RiderDeliveryDTO deliveryDTO);
 
@@ -48,7 +57,7 @@ public interface TbIndentService extends IService<TbIndent> {
 
     Result userEvaluate(ErrandEvaluate errandEvaluate);
 
-    Result findallIndent(Integer page, Integer limit, Long userId, Long riderUserId, Long shopId,Integer indentType,String ordersNo,Integer status,String riderPhone);
+    Result findallIndent(Integer page, Integer limit, Long userId, Long riderUserId, Long shopId, Integer indentType, String ordersNo, Integer status, String riderPhone);
 
     void finshIndent(Long userId, String indentNumber);
 
@@ -72,9 +81,9 @@ public interface TbIndentService extends IService<TbIndent> {
 
     TbIndent findIndentByIndentNumber(String orderId);
 
-    Result findAllIndent(String indentType, String phone, String indentState, Integer page, Integer limit, String date, String dateType,String riderPhone);
+    Result findAllIndent(String indentType, String phone, String indentState, Integer page, Integer limit, String date, String dateType, String riderPhone);
 
-    Result findAllIndents(String indentType, String phone, String indentState, Integer page, Integer limit, String date, String dateType,String riderPhone);
+    Result findAllIndents(String indentType, String phone, String indentState, Integer page, Integer limit, String date, String dateType, String riderPhone);
 
     Result IndentCenter(Integer page, Integer limit, String indentType, String indentNumber, String indentState, String phone, String date, String dateType);
 
@@ -112,14 +121,16 @@ public interface TbIndentService extends IService<TbIndent> {
 
     /**
      * 骑手转单
-     * @param userId 当前用户id
+     *
+     * @param userId           当前用户id
      * @param transferOrderDTO dto
      */
     void transferOfOrder(Long userId, RiderTransferOrderDTO transferOrderDTO);
 
     /**
      * 骑手转单
-     * @param userId 当前用户id
+     *
+     * @param userId           当前用户id
      * @param transferOrderDTO dto
      */
     void transferByOrderId(Long userId, RiderTransferByOrderIdDTO transferOrderDTO);
@@ -135,9 +146,10 @@ public interface TbIndentService extends IService<TbIndent> {
 
     /**
      * 骑手上次签收照片
-     * @param userId 用户id
+     *
+     * @param userId       用户id
      * @param indentNumber 跑腿订单号
-     * @param imgs 图片地址
+     * @param imgs         图片地址
      */
     void riderUploadDeliveryImg(Long userId, String indentNumber, String imgs);
 }

+ 16 - 0
src/main/java/com/sqx/modules/errand/service/TransferRecordService.java

@@ -0,0 +1,16 @@
+package com.sqx.modules.errand.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.sqx.common.utils.Result;
+import com.sqx.modules.errand.entity.*;
+import com.sqx.modules.printInfo.entity.PrintInfo;
+
+import java.util.List;
+
+public interface TransferRecordService extends IService<TransferRecordEntity> {
+    int insertPrintInfo(TransferRecordEntity tr);
+
+    boolean insertBatchPrintInfo(List<TransferRecordEntity> trs);
+
+    Result transferRecordById(Integer page, Integer limit, Integer OrderId);
+}

+ 107 - 3
src/main/java/com/sqx/modules/errand/service/impl/TbIndentServiceImpl.java

@@ -21,6 +21,7 @@ import com.sqx.modules.address.entity.Address;
 import com.sqx.modules.app.dao.UserDao;
 import com.sqx.modules.app.entity.UserEntity;
 import com.sqx.modules.app.entity.UserMoneyDetails;
+import com.sqx.modules.app.entity.queryRiderVo;
 import com.sqx.modules.app.service.UserMoneyDetailsService;
 import com.sqx.modules.app.service.UserService;
 import com.sqx.modules.common.entity.CommonInfo;
@@ -28,6 +29,7 @@ import com.sqx.modules.common.service.CommonInfoService;
 import com.sqx.modules.datacentre.query.DataCenterQuery;
 import com.sqx.modules.errand.dao.ErrandEvaluateDao;
 import com.sqx.modules.errand.dao.TbIndentDao;
+import com.sqx.modules.errand.dao.TransferRecordDao;
 import com.sqx.modules.errand.dto.OrderRiderDeliveryDTO;
 import com.sqx.modules.errand.dto.RiderDeliveryDTO;
 import com.sqx.modules.errand.dto.RiderTransferByOrderIdDTO;
@@ -37,8 +39,10 @@ import com.sqx.modules.errand.entity.*;
 import com.sqx.modules.errand.service.TbIndentService;
 import com.sqx.modules.errand.service.TbIndentSmsSendLogService;
 import com.sqx.modules.errand.service.TbIndentSmsTemplateService;
+import com.sqx.modules.errand.service.TransferRecordService;
 import com.sqx.modules.errand.util.LonLatUtil;
 import com.sqx.modules.errand.vo.ShopWaitAcceptOrderVO;
+import com.sqx.modules.errand.vo.queryOrderInfoVo;
 import com.sqx.modules.goods.dao.GoodsShopDao;
 import com.sqx.modules.goods.dao.GoodsShopRelevancyDao;
 import com.sqx.modules.goods.entity.GoodsShop;
@@ -53,6 +57,7 @@ import com.sqx.modules.pay.controller.app.AliPayController;
 import com.sqx.modules.pay.dao.PayDetailsDao;
 import com.sqx.modules.pay.entity.PayDetails;
 import com.sqx.modules.pay.service.WxService;
+import com.sqx.modules.printInfo.entity.PrintInfo;
 import com.sqx.modules.shop.service.ShopMessageService;
 import com.sqx.modules.utils.HttpClientUtil;
 import com.sqx.modules.utils.SenInfoCheckUtil;
@@ -117,6 +122,8 @@ public class TbIndentServiceImpl extends ServiceImpl<TbIndentDao, TbIndent> impl
     private GoodsShopRelevancyDao goodsShopRelevancyDao;
     @Autowired
     private ShopMessageService shopMessageService;
+    @Autowired
+    private TransferRecordDao transferRecordDao;
 
     @Resource
     private TbIndentSmsTemplateService smsTemplateService;
@@ -926,9 +933,16 @@ public class TbIndentServiceImpl extends ServiceImpl<TbIndentDao, TbIndent> impl
     }
 
     @Override
-    public Result findRiderIndent(Long userId, Integer page, Integer limit, String indentState) {
+    public Result findRiderIndent(Long userId, Integer page, Integer limit, String indentState, String keyword) {
         Page<TbIndent> pages = new Page<>(page, limit);
-        PageUtils pageUtils = new PageUtils(tbIndentDao.findRiderIndent(pages, userId, indentState));
+        PageUtils pageUtils = new PageUtils(tbIndentDao.findRiderIndent(pages, userId, indentState, keyword));
+        return Result.success().put("data", pageUtils);
+    }
+
+    @Override
+    public Result findRiderIndentByIds(Long userId, Integer page, Integer limit, List<String> indentIds) {
+        Page<queryOrderInfoVo> pages = new Page<>(page, limit);
+        PageUtils pageUtils = new PageUtils(tbIndentDao.findRiderIndentByIds(pages, userId, indentIds));
         return Result.success().put("data", pageUtils);
     }
 
@@ -955,6 +969,17 @@ public class TbIndentServiceImpl extends ServiceImpl<TbIndentDao, TbIndent> impl
         indent.setIsRider(1);
         updateById(indent);
 
+        String format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
+        TransferRecordEntity tr = new TransferRecordEntity();
+        tr.setUserId(userEntity.getUserId());
+        tr.setUserName(userEntity.getUserName());
+        tr.setUserPhone(userEntity.getPhone());
+        tr.setOrderId(indent.getOrderId());
+        tr.setReceveTime(format);
+        tr.setStationName(userEntity.getStationName());
+        tr.setDeleteFlag(0);
+        transferRecordDao.insert(tr);
+
         // 消息通知
         noticeAfterTransfer(indent);
     }
@@ -1519,6 +1544,14 @@ public class TbIndentServiceImpl extends ServiceImpl<TbIndentDao, TbIndent> impl
     }
 
     @Override
+    public List<TbIndent> findIndentsByIds(List<Long> ids) {
+        QueryWrapper<TbIndent> queryWrapper = new QueryWrapper<>();
+        queryWrapper.in("indent_id",ids);
+        List<TbIndent> result = baseMapper.selectList(queryWrapper);
+        return result;
+    }
+
+    @Override
     public Result findIncome(Long userId, String date, String dateType, Integer page, Integer limit) {
         HashMap hashMap = new HashMap();
         //收益统计
@@ -1693,6 +1726,49 @@ public class TbIndentServiceImpl extends ServiceImpl<TbIndentDao, TbIndent> impl
      *
      * @param indent
      */
+    @Override
+    public void noticeAfterTransfer(TbIndent indent,queryRiderVo user) {
+        CommonInfo one = commonInfoService.findOne(335);
+        List<String> msgList = new ArrayList<>();
+        msgList.add(0, indent.getIndentNumber());
+        String indentState = indent.getIndentState();
+        if ("3".equals(indentState)) {
+            msgList.add(1, "已接单");
+        } else if ("4".equals(indentState)) {
+            msgList.add(1, "已取货");
+        } else {
+            msgList.add(1, "进行中");
+        }
+        msgList.add(2, "骑手已更换,新骑手将尽快为您送达");
+        msgList.add(3, DateUtils.format(new Date()));
+        if (StrUtil.isNotEmpty(user.getOpenId())) {
+            MyGlobalThreadPool.execute(() -> {
+                try {
+                    SenInfoCheckUtil.sendMsg(user.getOpenId(), one.getValue(), msgList, 5);
+                } catch (Exception e) {
+                    log.error("订单:{},转单成功通知发送失败,失败原因:{}", e);
+                }
+            });
+
+        }
+
+        if (StrUtil.isNotEmpty(user.getOpenId())) {
+            MyGlobalThreadPool.execute(() -> {
+                try {
+                    userService.pushToSingle("更换骑手", "骑手已更换,新骑手将尽快为您送达", user.getClientid());
+                } catch (Exception e) {
+                    log.error("订单:{},骑手已更换通知发送失败,失败原因:{}", e);
+                }
+            });
+
+        }
+    }
+
+    /**
+     * 转单后通知
+     *
+     * @param indent
+     */
     private void noticeAfterTransfer(TbIndent indent) {
         CommonInfo one = commonInfoService.findOne(335);
         UserEntity user = userService.getById(indent.getUserId());
@@ -1773,7 +1849,7 @@ public class TbIndentServiceImpl extends ServiceImpl<TbIndentDao, TbIndent> impl
         } else {
             List<UserEntity> userEntities = userService.queryByRealName(realName);
             if (userEntities.size() > 1) {
-                throw new SqxException("根据姓名查到了多个骑手,输入手机号码精确查询");
+                throw new SqxException("根据姓名查到了多个骑手,输入手机号码精确查询");
             }
             if (userEntities.size() == 1) {
                 userEntity = userEntities.get(0);
@@ -1802,6 +1878,34 @@ public class TbIndentServiceImpl extends ServiceImpl<TbIndentDao, TbIndent> impl
         return userEntity;
     }
 
+    /**
+     * 获取新骑手
+     *
+     * @param riderUserId    被转单骑手id
+     * @return 新骑手
+     */
+    @Override
+    public queryRiderVo getNewRicherCheck(Long riderUserId) {
+        queryRiderVo userEntity = userService.queryRider(riderUserId);
+
+        if (userEntity == null) {
+            throw new SqxException("用户不存在");
+        }
+
+        // 校验当前骑手实名认证、保证金等信息
+        CommonInfo one1 = commonInfoService.findOne(273);
+        Double cashDeposit = Double.parseDouble(one1.getValue());
+        if (!"1".equals(userEntity.getCheckCertification())) {
+            throw new SqxException("骑手未进行实名认证!");
+        }
+
+        if (userEntity.getCashDeposit().doubleValue() < cashDeposit) {
+            throw new SqxException("骑手保证金不足!");
+        }
+
+        return userEntity;
+    }
+
     @Override
     public PageUtils selectIndentPage(Integer page, Integer limit, String acquireCode, Long userId) {
         List<Integer> states = new ArrayList<>();

+ 47 - 0
src/main/java/com/sqx/modules/errand/service/impl/TransferRecordServiceImpl.java

@@ -0,0 +1,47 @@
+package com.sqx.modules.errand.service.impl;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.sqx.common.utils.PageUtils;
+import com.sqx.common.utils.Result;
+import com.sqx.modules.errand.dao.TbIndentDao;
+import com.sqx.modules.errand.dao.TransferRecordDao;
+import com.sqx.modules.errand.entity.*;
+import com.sqx.modules.errand.service.TransferRecordService;
+import com.sqx.modules.errand.vo.queryOrderInfoVo;
+import com.sqx.modules.printInfo.entity.PrintInfo;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+
+@Service
+public class TransferRecordServiceImpl extends ServiceImpl<TransferRecordDao, TransferRecordEntity> implements TransferRecordService {
+
+    @Autowired
+    private TransferRecordDao transferRecordDao;
+
+    @Override
+    public int insertPrintInfo(TransferRecordEntity tr) {
+        int result = baseMapper.insert(tr);
+
+        return result;
+    }
+
+    @Override
+    public boolean insertBatchPrintInfo(List<TransferRecordEntity> trs) {
+        boolean result = this.saveBatch(trs);
+
+        return result;
+    }
+
+    @Override
+    public Result transferRecordById(Integer page, Integer limit, Integer orderId) {
+        Page<TransferRecordVo> pages = new Page<>(page, limit);
+        PageUtils pageUtils = new PageUtils(transferRecordDao.queryTransferRecordPages(pages, orderId));
+        return Result.success().put("data", pageUtils);
+    }
+}

+ 55 - 0
src/main/java/com/sqx/modules/errand/vo/queryOrderInfoVo.java

@@ -0,0 +1,55 @@
+package com.sqx.modules.errand.vo;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @Author: xwt
+ * @Date: 2025/4/1 星期二 14:19
+ * @Description: com.sqx.modules.errand.vo
+ * @Version: 1.0
+ */
+@Data
+@ApiModel("获取待转单订单数据")
+public class queryOrderInfoVo {
+    @ApiModelProperty("主键id")
+    private Long indentId;
+    //店铺名
+    @ApiModelProperty("店铺名称")
+    private String shopName;
+    //订单序号
+    @ApiModelProperty("订单支付顺序号")
+    private String orderPaySequence;
+    //收货人名称
+    //收货人手机号
+    //收货地址
+    @ApiModelProperty("收货人姓名")
+    private String userName;
+
+    @ApiModelProperty("收货人手机")
+    private String userPhone;
+
+    @ApiModelProperty("收货人地址(省)")
+    private String userProvince;
+
+    @ApiModelProperty("收货人地址(市)")
+    private String userCity;
+
+    @ApiModelProperty("收货人地址(区)")
+    private String userDistrict;
+
+    @ApiModelProperty("收货地址经度")
+    private Double userLng;
+
+    @ApiModelProperty("收货地址维度")
+    private Double userLat;
+
+    @ApiModelProperty("收货人详细地址")
+    private String userAddressDetail;
+}

+ 22 - 1
src/main/resources/mapper/app/UserDao.xml

@@ -42,6 +42,27 @@
         </if>
         order by create_time desc
     </select>
+
+
+    <select id="queryRider" resultType="com.sqx.modules.app.entity.queryRiderVo">
+        select u.user_id,u.clientid,u.open_id,u.rider_open_id,u.user_name,u.phone,u.cash_deposit,u.check_certification,r.station_name
+        from tb_user u
+        left join rider_station r on r.id = u.rider_station_id
+        where  u.user_id != #{userId}
+    </select>
+
+    <select id="queryRiders" resultType="com.sqx.modules.app.entity.queryRidersVo">
+        select u.user_id,u.user_name,u.phone,r.station_name
+        from tb_user u
+        left join rider_station r on r.id = u.rider_station_id
+        where u.user_type = 2 and u.on_line_flag = 1
+        and u.rider_station_id = #{riderStationId} and u.user_id != #{userId}
+        <if test="keyword != null and keyword != ''">
+            and (u.phone like concat('%',#{keyword},'%') or u.user_name like concat('%',#{keyword},'%'))
+        </if>
+    </select>
+
+
     <select id="queryInviterCount" resultType="int">
         select count(*) from tb_user
         where inviter_code=#{inviterCode}
@@ -411,4 +432,4 @@
     </select>
 
 
-</mapper>
+</mapper>

+ 48 - 24
src/main/resources/mapper/errand/TbIndentMapper.xml

@@ -24,14 +24,17 @@
     <select id="findNewIndentByDistances" resultType="com.sqx.modules.errand.entity.TbIndent">
         select * from (
         select ti.*,
-        (st_distance (point (ti.shop_lng,ti.shop_lat),point(#{queryDTO.riderLng},#{queryDTO.riderLat}) ) * 111195) AS distancess,
-        (st_distance (point (ti.user_lng,ti.user_lat),point(#{queryDTO.riderLng},#{queryDTO.riderLat}) ) * 111195) AS distancessd
+        (st_distance (point (ti.shop_lng,ti.shop_lat),point(#{queryDTO.riderLng},#{queryDTO.riderLat}) ) * 111195) AS
+        distancess,
+        (st_distance (point (ti.user_lng,ti.user_lat),point(#{queryDTO.riderLng},#{queryDTO.riderLat}) ) * 111195) AS
+        distancessd
         from tb_indent ti
         where ti.indent_state = 2
         ) a
         <where>
             <if test="queryDTO.distances!= null">
-                and ((distancess is not null and distancess &lt;= #{queryDTO.distances}) or (distancess is null and distancessd &lt;= #{queryDTO.distances}))
+                and ((distancess is not null and distancess &lt;= #{queryDTO.distances}) or (distancess is null and
+                distancessd &lt;= #{queryDTO.distances}))
             </if>
             <if test="queryDTO.indentType != null and queryDTO.indentType != ''">
                 and indent_type = #{queryDTO.indentType}
@@ -48,17 +51,20 @@
 
     <select id="findNewIndentByDistancesGroupByShop" resultType="com.sqx.modules.errand.vo.ShopWaitAcceptOrderVO">
         select shop_id, shop_name, count(indent_id) as countOfWaitAccept from (
-            select
-                shop_id, shop_name, indent_id,
-                (st_distance(point(shop_lng,shop_lat), point(#{queryDTO.riderLng}, #{queryDTO.riderLat})) * 111195) AS distancess,
-                (st_distance(point(user_lng,user_lat), point(#{queryDTO.riderLng}, #{queryDTO.riderLat})) * 111195) AS distancessd
-            from
-                tb_indent
-            where indent_state = 2
+        select
+        shop_id, shop_name, indent_id,
+        (st_distance(point(shop_lng,shop_lat), point(#{queryDTO.riderLng}, #{queryDTO.riderLat})) * 111195) AS
+        distancess,
+        (st_distance(point(user_lng,user_lat), point(#{queryDTO.riderLng}, #{queryDTO.riderLat})) * 111195) AS
+        distancessd
+        from
+        tb_indent
+        where indent_state = 2
         ) a
         <where>
             <if test="queryDTO.distances!= null">
-                and ((distancess is not null and distancess &lt;= #{queryDTO.distances}) or (distancess is null and distancessd &lt;= #{queryDTO.distances}))
+                and ((distancess is not null and distancess &lt;= #{queryDTO.distances}) or (distancess is null and
+                distancessd &lt;= #{queryDTO.distances}))
             </if>
             <if test="queryDTO.indentType != null and queryDTO.indentType != ''">
                 and indent_type = #{queryDTO.indentType}
@@ -71,9 +77,9 @@
             </if>
         </where>
         group by
-            shop_id, shop_name
+        shop_id, shop_name
         order by
-            distancess asc
+        distancess asc
     </select>
 
     <select id="findNewIndentcity" resultType="com.sqx.modules.errand.entity.TbIndent">
@@ -95,8 +101,10 @@
     <select id="findNewIndentByCity" resultType="com.sqx.modules.errand.entity.TbIndent">
         select * from (
         select ti.*,
-        (st_distance (point (ti.shop_lng,ti.shop_lat),point(#{queryDTO.riderLng},#{queryDTO.riderLat}) ) * 111195) AS distancess,
-        (st_distance (point (ti.user_lng,ti.user_lat),point(#{queryDTO.riderLng},#{queryDTO.riderLat}) ) * 111195) AS distancessd
+        (st_distance (point (ti.shop_lng,ti.shop_lat),point(#{queryDTO.riderLng},#{queryDTO.riderLat}) ) * 111195) AS
+        distancess,
+        (st_distance (point (ti.user_lng,ti.user_lat),point(#{queryDTO.riderLng},#{queryDTO.riderLat}) ) * 111195) AS
+        distancessd
         from tb_indent ti
         where ti.indent_state = 2
         ) a
@@ -116,13 +124,13 @@
 
     <select id="findNewIndentByCityGroupByShop" resultType="com.sqx.modules.errand.vo.ShopWaitAcceptOrderVO">
         select
-            shop_id, shop_name, count(indent_id) as countOfWaitAccept,
-            (st_distance_sphere (point (shop_lng,shop_lat),point(115.82770500,28.70783200))) AS distancess
+        shop_id, shop_name, count(indent_id) as countOfWaitAccept,
+        (st_distance_sphere (point (shop_lng,shop_lat),point(115.82770500,28.70783200))) AS distancess
         from
-            tb_indent
+        tb_indent
         where
-            indent_state = 2
-            and shop_city like concat('%',#{queryDTO.city},'%')
+        indent_state = 2
+        and shop_city like concat('%',#{queryDTO.city},'%')
         <if test="queryDTO.indentType!=null and queryDTO.indentType!=''">
             and indent_type = #{queryDTO.indentType}
         </if>
@@ -133,9 +141,9 @@
             and shop_id = #{queryDTO.shopId}
         </if>
         group by
-            shop_id, shop_name, shop_lng, shop_lat
+        shop_id, shop_name, shop_lng, shop_lat
         order by
-            distancess asc
+        distancess asc
     </select>
 
     <select id="findIndentByNumber" resultType="com.sqx.modules.errand.entity.TbIndent">
@@ -190,6 +198,9 @@
 
     <select id="findRiderIndent" resultType="com.sqx.modules.errand.entity.TbIndent">
         select * from tb_indent where rider_user_id = #{userId}
+        <if test="keyword != null and keyword != ''">
+            and (user_phone like concat('%',#{keyword},'%') or user_address_detail like concat('%',#{keyword},'%'))
+        </if>
         <if test="indentState!=''">
             <if test="indentState==0">
                 and indent_state = 0
@@ -216,6 +227,18 @@
         order by receiving_time desc
     </select>
 
+    <select id="findRiderIndentByIds" resultType="com.sqx.modules.errand.vo.queryOrderInfoVo">
+        select indent_id,shop_name,order_pay_sequence,user_name,user_phone,user_province,user_city,user_district,user_lng,user_lat,user_address_detail
+         from tb_indent where rider_user_id = #{userId}
+        <if test="indentIds != null and indentIds.size() > 0">
+            and indent_id in
+            <foreach collection="indentIds" item="indentId" index="index" open="(" separator="," close=")">
+                #{indentId}
+            </foreach>
+        </if>
+        order by receiving_time desc
+    </select>
+
     <select id="indentRiderMessage" resultType="com.sqx.modules.errand.entity.TbIndent">
         select ti.*,
                (st_distance(point(ti.shop_lng, ti.shop_lat), point(#{riderLng}, #{riderLat})) * 111195) AS distancess,
@@ -730,8 +753,9 @@
     </select>
 
     <select id="findUserIndent" resultType="com.sqx.modules.errand.entity.TbIndent">
-        select t.*,(select count(*) from errand_evaluate e where e.user_id=#{userId} and t.indent_number=e.indent_number) as evaluateMessage
-        from tb_indent t  where t.user_id = #{userId} and t.indent_type != 5
+        select t.*,(select count(*) from errand_evaluate e where e.user_id=#{userId} and
+        t.indent_number=e.indent_number) as evaluateMessage
+        from tb_indent t where t.user_id = #{userId} and t.indent_type != 5
         <if test="indentState==1">
             and t.indent_state in ("0", "2", "3", "4", "6", "8", "9", "10")
         </if>

+ 13 - 0
src/main/resources/mapper/errand/TransferRecordDao.xml

@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.sqx.modules.errand.dao.TransferRecordDao">
+
+    <select id="queryTransferRecordPages" resultType="com.sqx.modules.errand.entity.TransferRecordVo">
+        select tr.id,tr.user_id,tr.order_id,tr.user_name,tr.user_phone,tr.receve_time,tr.station_name,tor.pay_time
+        from transfer_record tr
+        left join tb_order tor on tr.order_id = tor.order_id
+        where tr.order_id = #{orderId}
+        order by tr.receve_time desc
+    </select>
+
+</mapper>