Browse Source

add 骑手添加附件

tea 3 months ago
parent
commit
4a81bc5997

+ 49 - 0
kxmall-admin-api/src/main/java/com/kxmall/web/controller/rider/KxRiderAuthAttachmentController.java

@@ -0,0 +1,49 @@
+package com.kxmall.web.controller.rider;
+
+import cn.dev33.satoken.annotation.SaCheckPermission;
+import com.kxmall.common.annotation.Log;
+import com.kxmall.common.core.controller.BaseController;
+import com.kxmall.common.core.domain.R;
+import com.kxmall.common.enums.BusinessType;
+import com.kxmall.rider.domain.KxRiderAuthAttachment;
+import com.kxmall.web.controller.rider.service.IKxRiderAuthAttachmentService;
+import lombok.RequiredArgsConstructor;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * 骑手附件认证
+ *
+ * @author kxmall
+ * @date 2025-01-27
+ */
+@Validated
+@RequiredArgsConstructor
+@RestController
+@RequestMapping("/rider/attachment")
+public class KxRiderAuthAttachmentController extends BaseController {
+
+    private final IKxRiderAuthAttachmentService attachmentService;
+
+    /**
+     * 根据骑手ID查询附件列表
+     */
+    @SaCheckPermission("rider:rider:query")
+    @GetMapping("/list/{riderId}")
+    public R<List<KxRiderAuthAttachment>> getAttachmentsByRiderId(@PathVariable Long riderId) {
+        List<KxRiderAuthAttachment> attachments = attachmentService.getAttachmentsByRiderId(riderId);
+        return R.ok(attachments);
+    }
+
+    /**
+     * 删除单个附件
+     */
+    @SaCheckPermission("rider:rider:edit")
+    @Log(title = "骑手附件", businessType = BusinessType.DELETE)
+    @DeleteMapping("/{attachmentId}")
+    public R<Void> deleteAttachment(@PathVariable Long attachmentId) {
+        return toAjax(attachmentService.deleteAttachment(attachmentId));
+    }
+}

+ 11 - 7
kxmall-admin-api/src/main/java/com/kxmall/web/controller/rider/KxRiderController.java

@@ -49,25 +49,31 @@ public class KxRiderController extends BaseController {
         return R.ok(iKxRiderService.getRiderByStorageId(storageId));
     }
 
-
-    // 获取骑手银行信息
+    // 获取骑手银行信息(保留兼容)
     @GetMapping("/bankInfo/{riderId}")
     public R<Map<String, Object>> getRiderBankInfo(@PathVariable Long riderId) {
         KxRider rider = iKxRiderService.getById(riderId);
         if (rider == null) {
             return R.fail("骑手不存在");
         }
-
-        // 只返回银行相关字段
         Map<String, Object> bankInfo = new HashMap<>();
         bankInfo.put("bankName", rider.getBankName());
         bankInfo.put("bankAccount", rider.getBankAccount());
         bankInfo.put("accountHolder", rider.getAccountHolder());
         bankInfo.put("idCardNumber", rider.getIdCardNumber());
-
         return R.ok(bankInfo);
     }
 
+    /**
+     * 重置骑手登录密码
+     */
+    @SaCheckPermission("rider:rider:edit")
+    @Log(title = "配送-重置密码", businessType = BusinessType.UPDATE)
+    @PostMapping("/resetPassword/{riderId}")
+    public R<Void> resetRiderPassword(@PathVariable Long riderId) {
+        return toAjax(iKxRiderService.resetRiderPassword(riderId));
+    }
+
     /**
      * 查询配送列表
      */
@@ -138,7 +144,6 @@ public class KxRiderController extends BaseController {
         return toAjax(iKxRiderService.deleteWithValidByIds(Arrays.asList(ids), true));
     }
 
-
     /**
      * 配送员工作状态批量更新为休息中
      */
@@ -171,7 +176,6 @@ public class KxRiderController extends BaseController {
         return R.ok(iKxRiderService.updateStateToNomral(ids));
     }
 
-
     /**
      * 获取指定骑手的推送订阅二维码
      */

+ 34 - 0
kxmall-admin-api/src/main/java/com/kxmall/web/controller/rider/service/IKxRiderAuthAttachmentService.java

@@ -0,0 +1,34 @@
+package com.kxmall.web.controller.rider.service;
+
+import com.kxmall.rider.domain.KxRiderAuthAttachment;
+
+import java.util.List;
+
+/**
+ * 骑手附件认证Service接口
+ *
+ * @author kxmall
+ * @date 2025-01-27
+ */
+public interface IKxRiderAuthAttachmentService {
+
+    /**
+     * 根据骑手ID查询附件列表
+     */
+    List<KxRiderAuthAttachment> getAttachmentsByRiderId(Long riderId);
+
+    /**
+     * 批量保存骑手附件
+     */
+    Boolean saveAttachments(Long riderId, List<KxRiderAuthAttachment> attachments);
+
+    /**
+     * 删除骑手的所有附件
+     */
+    Boolean deleteAttachmentsByRiderId(Long riderId);
+
+    /**
+     * 删除单个附件
+     */
+    Boolean deleteAttachment(Long attachmentId);
+}

+ 7 - 0
kxmall-admin-api/src/main/java/com/kxmall/web/controller/rider/service/IKxRiderService.java

@@ -103,4 +103,11 @@ public interface IKxRiderService {
      * @return
      */
     KxRider getById(Long riderId);
+
+    /**
+     * 重置骑手登录密码为默认值
+     * @param riderId
+     * @return
+     */
+    Boolean resetRiderPassword(Long riderId);
 }

+ 63 - 0
kxmall-admin-api/src/main/java/com/kxmall/web/controller/rider/service/impl/KxRiderAuthAttachmentServiceImpl.java

@@ -0,0 +1,63 @@
+package com.kxmall.web.controller.rider.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.kxmall.rider.domain.KxRiderAuthAttachment;
+import com.kxmall.rider.mapper.KxRiderAuthAttachmentMapper;
+import com.kxmall.web.controller.rider.service.IKxRiderAuthAttachmentService;
+import lombok.RequiredArgsConstructor;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+
+/**
+ * 骑手附件认证Service业务层处理
+ *
+ * @author kxmall
+ * @date 2025-01-27
+ */
+@RequiredArgsConstructor
+@Service
+public class KxRiderAuthAttachmentServiceImpl implements IKxRiderAuthAttachmentService {
+
+    private final KxRiderAuthAttachmentMapper attachmentMapper;
+
+    @Override
+    public List<KxRiderAuthAttachment> getAttachmentsByRiderId(Long riderId) {
+        LambdaQueryWrapper<KxRiderAuthAttachment> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(KxRiderAuthAttachment::getRiderId, riderId);
+        wrapper.orderByAsc(KxRiderAuthAttachment::getSortNo);
+        return attachmentMapper.selectList(wrapper);
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public Boolean saveAttachments(Long riderId, List<KxRiderAuthAttachment> attachments) {
+        if (attachments == null || attachments.isEmpty()) {
+            return true;
+        }
+        
+        // 先删除原有附件
+        deleteAttachmentsByRiderId(riderId);
+        
+        // 批量插入新附件
+        for (KxRiderAuthAttachment attachment : attachments) {
+            attachment.setRiderId(riderId);
+            attachmentMapper.insert(attachment);
+        }
+        
+        return true;
+    }
+
+    @Override
+    public Boolean deleteAttachmentsByRiderId(Long riderId) {
+        LambdaQueryWrapper<KxRiderAuthAttachment> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(KxRiderAuthAttachment::getRiderId, riderId);
+        return attachmentMapper.delete(wrapper) >= 0;
+    }
+
+    @Override
+    public Boolean deleteAttachment(Long attachmentId) {
+        return attachmentMapper.deleteById(attachmentId) > 0;
+    }
+}

+ 45 - 2
kxmall-admin-api/src/main/java/com/kxmall/web/controller/rider/service/impl/KxRiderServiceImpl.java

@@ -14,17 +14,18 @@ import com.kxmall.common.enums.RiderWorkStateType;
 import com.kxmall.common.exception.ServiceException;
 import com.kxmall.common.utils.StringUtils;
 import com.kxmall.common.utils.file.FileUtils;
-import com.kxmall.group.domain.KxGroupShop;
 import com.kxmall.rider.domain.KxRider;
 import com.kxmall.rider.domain.KxRiderCycle;
 import com.kxmall.rider.domain.bo.KxRiderBo;
 import com.kxmall.rider.domain.vo.KxRiderVo;
 import com.kxmall.rider.mapper.KxRiderCycleMapper;
 import com.kxmall.rider.mapper.KxRiderMapper;
+import com.kxmall.rider.domain.KxRiderAuthAttachment;
 import com.kxmall.storage.domain.KxStorage;
 import com.kxmall.storage.mapper.KxStorageMapper;
 import com.kxmall.system.service.ISysConfigService;
 import com.kxmall.web.controller.rider.service.IKxRiderService;
+import com.kxmall.web.controller.rider.service.IKxRiderAuthAttachmentService;
 import com.kxmall.wechat.WxMpConfiguration;
 import lombok.RequiredArgsConstructor;
 import me.chanjar.weixin.mp.bean.result.WxMpQrCodeTicket;
@@ -59,6 +60,8 @@ public class KxRiderServiceImpl implements IKxRiderService {
 
     private final ISysConfigService configService;
 
+    private final IKxRiderAuthAttachmentService attachmentService;
+
     // 初始密码
     private static final String ININT_PASSWORD = "123456";
 
@@ -76,6 +79,11 @@ public class KxRiderServiceImpl implements IKxRiderService {
             if (riderCycles != null && riderCycles.size() > 0) {
                 riderVo.setWeekNumberIds(riderCycles.stream().map(KxRiderCycle::getWeekNumber).collect(Collectors.toList()));
             }
+            
+            // 查询骑手附件
+            List<KxRiderAuthAttachment> attachments = attachmentService.getAttachmentsByRiderId(id);
+            riderVo.setAttachments(attachments);
+            
             return riderVo;
         }
         throw new ServiceException("配送员不存在");
@@ -153,9 +161,15 @@ public class KxRiderServiceImpl implements IKxRiderService {
         add.setUpdateTime(now);
         add.setLoginType(0);
         if (baseMapper.insert(add) > 0) {
+            Long riderDOId = add.getId();
+            
+            // 保存骑手附件
+            if (bo.getAttachments() != null && !bo.getAttachments().isEmpty()) {
+                attachmentService.saveAttachments(riderDOId, bo.getAttachments());
+            }
+            
             List<Long> weekNumberIds = bo.getWeekNumberIds();
             if (weekNumberIds != null && weekNumberIds.size() > 0) {
-                Long riderDOId = add.getId();
                 KxRiderCycle riderCycle;
                 List<KxRiderCycle> riderCycleDOList = new ArrayList<>();
                 for (Long weekNumber : weekNumberIds) {
@@ -200,6 +214,12 @@ public class KxRiderServiceImpl implements IKxRiderService {
 
         if (baseMapper.updateById(update) > 0) {
             Long riderDOId = bo.getId();
+            
+            // 更新骑手附件
+            if (bo.getAttachments() != null) {
+                attachmentService.saveAttachments(riderDOId, bo.getAttachments());
+            }
+            
             QueryWrapper<KxRiderCycle> queryWrapper = new QueryWrapper<>();
             queryWrapper.eq("rider_id", riderDOId);
             riderCycleMapper.delete(queryWrapper);
@@ -411,4 +431,27 @@ public class KxRiderServiceImpl implements IKxRiderService {
     public KxRider getById(Long riderId) {
         return baseMapper.selectById(riderId);
     }
+
+    /**
+     * 重置骑手登录密码
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public Boolean resetRiderPassword(Long riderId) {
+        KxRider rider = baseMapper.selectById(riderId);
+        if (rider == null) {
+            throw new ServiceException("骑手不存在");
+        }
+        String phone = rider.getPhone();
+        if (StringUtils.isEmpty(phone)) {
+            throw new ServiceException("骑手手机号不存在,无法重置密码");
+        }
+        String saltSource = phone.length() >= 7 ? phone.substring(0, 7) : phone;
+        String cryptPassword = Md5Crypt.md5Crypt(ININT_PASSWORD.getBytes(), "$1$" + saltSource);
+        KxRider update = new KxRider();
+        update.setId(riderId);
+        update.setPassword(cryptPassword);
+        update.setUpdateTime(new Date());
+        return baseMapper.updateById(update) > 0;
+    }
 }

+ 5 - 0
kxmall-generator/pom.xml

@@ -35,6 +35,11 @@
             <version>3.5.3.1</version>
         </dependency>
 
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+        </dependency>
+
     </dependencies>
 
 </project>

+ 3 - 6
kxmall-generator/src/test/java/Gen.java

@@ -1,6 +1,5 @@
 import com.baomidou.mybatisplus.generator.FastAutoGenerator;
 import com.baomidou.mybatisplus.generator.config.OutputFile;
-import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
 
 import java.util.Arrays;
 import java.util.Collections;
@@ -24,14 +23,12 @@ public class Gen {
                 })
                 .packageConfig(builder ->
                         builder
-                                .moduleName("system") // 设置父包模块名
-                                .pathInfo(Collections.singletonMap(OutputFile.xml, "D://")) // 设置mapperXml生成路径
+                                .parent("system")
+                                .pathInfo(Collections.singletonMap(OutputFile.xml, "D://gen")) // 设置mapperXml生成路径
                 )
                 .strategyConfig(builder ->
-                        builder.addInclude("t_simple") // 设置需要生成的表名
-                                .addTablePrefix("t_", "c_") // 设置过滤表前缀
+                        builder.addInclude("kx_rider_auth_attachment").entityBuilder().enableLombok()
                 )
-                .templateEngine(new FreemarkerTemplateEngine()) // 使用Freemarker引擎模板,默认的是Velocity引擎模板
                 .execute();
     }
 

+ 50 - 0
kxmall-system/src/main/java/com/kxmall/rider/domain/KxRiderAuthAttachment.java

@@ -0,0 +1,50 @@
+package com.kxmall.rider.domain;
+
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.io.Serializable;
+
+/**
+ * <p>
+ * 师傅证件表
+ * </p>
+ *
+ * @author tea
+ * @since 2025-09-03
+ */
+@Getter
+@Setter
+@TableName("kx_rider_auth_attachment")
+public class KxRiderAuthAttachment implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * id
+     */
+    @TableId(value = "id")
+    private Long id;
+
+    /**
+     * 师傅id
+     */
+    private Long riderId;
+
+    /**
+     * 字典:auth_attachment_type
+     */
+    private Byte authAttachmentType;
+
+    /**
+     * 证件url
+     */
+    private String attachmentUrl;
+
+    /**
+     * 排序号
+     */
+    private Integer sortNo;
+}

+ 6 - 0
kxmall-system/src/main/java/com/kxmall/rider/domain/bo/KxRiderBo.java

@@ -2,6 +2,7 @@ package com.kxmall.rider.domain.bo;
 
 import com.kxmall.common.core.domain.BaseEntity;
 import com.kxmall.common.core.validate.EditGroup;
+import com.kxmall.rider.domain.KxRiderAuthAttachment;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import javax.validation.constraints.*;
@@ -113,4 +114,9 @@ public class KxRiderBo extends BaseEntity {
      * 仓库权限参数
      */
     private Set<Long> storageIds;
+
+    /**
+     * 骑手附件列表
+     */
+    private List<KxRiderAuthAttachment> attachments;
 }

+ 5 - 1
kxmall-system/src/main/java/com/kxmall/rider/domain/vo/KxRiderVo.java

@@ -2,6 +2,7 @@ package com.kxmall.rider.domain.vo;
 
 import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
 import com.alibaba.excel.annotation.ExcelProperty;
+import com.kxmall.rider.domain.KxRiderAuthAttachment;
 import lombok.Data;
 
 import java.math.BigDecimal;
@@ -134,5 +135,8 @@ public class KxRiderVo {
 
     private BigDecimal longitude;
 
-
+    /**
+     * 骑手附件列表
+     */
+    private List<KxRiderAuthAttachment> attachments;
 }

+ 16 - 0
kxmall-system/src/main/java/com/kxmall/rider/mapper/KxRiderAuthAttachmentMapper.java

@@ -0,0 +1,16 @@
+package com.kxmall.rider.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.kxmall.rider.domain.KxRiderAuthAttachment;
+
+/**
+ * <p>
+ * 师傅证件表 Mapper 接口
+ * </p>
+ *
+ * @author tea
+ * @since 2025-09-03
+ */
+public interface KxRiderAuthAttachmentMapper extends BaseMapper<KxRiderAuthAttachment> {
+
+}