Quellcode durchsuchen

智能柜项目提交

skyline vor 3 Monaten
Ursprung
Commit
d87cbea4f6

+ 24 - 4
haha-entity/src/main/java/com/haha/entity/Order.java

@@ -1,6 +1,7 @@
 package com.haha.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 lombok.Data;
@@ -15,10 +16,10 @@ public class Order implements Serializable {
     public static final String PAY_STATUS_已支付 = "PAID";
     public static final String PAY_STATUS_已退款 = "REFUND";
 
-    // 订单状态:0-待支付,1-已完成,0-已取消,3-已关闭
-    public static final int ORDER_STATUS_待支付 = 0;
-    public static final int ORDER_STATUS_已完成 = 1;
-    public static final int ORDER_STATUS_已取消 = 2;
+    // 订单状态:0-已取消,1-待支付,2-已完成,3-已关闭
+    public static final int ORDER_STATUS_已取消 = 0;
+    public static final int ORDER_STATUS_待支付 = 1;
+    public static final int ORDER_STATUS_已完成 = 2;
     public static final int ORDER_STATUS_已关闭 = 3;
 
     private static final long serialVersionUID = 1L;
@@ -49,4 +50,23 @@ public class Order implements Serializable {
     private LocalDateTime payTime;
 
     private Integer status;
+    
+    // 非数据库字段 - 用于前端展示
+    @TableField(exist = false)
+    private String statusLabel;
+    
+    @TableField(exist = false)
+    private String payStatusLabel;
+    
+    @TableField(exist = false)
+    private String userName;
+    
+    @TableField(exist = false)
+    private String phone;
+    
+    @TableField(exist = false)
+    private String deviceName;
+    
+    @TableField(exist = false)
+    private String storeName;
 }

+ 41 - 40
haha-service/src/main/java/com/haha/service/impl/AdminServiceImpl.java

@@ -22,12 +22,12 @@ import java.util.Map;
 @Slf4j
 @Service
 public class AdminServiceImpl extends ServiceImpl<AdminMapper, Admin> implements AdminService {
-    
+
     @Override
     public Result<IPage<Admin>> getAdminList(int page, int pageSize, String username, String phone, Long roleId, Integer status) {
         try {
             LambdaQueryWrapper<Admin> wrapper = new LambdaQueryWrapper<>();
-            
+
             // 条件查询
             if (StringUtils.hasText(username)) {
                 wrapper.and(w -> w.like(Admin::getUsername, username)
@@ -37,66 +37,67 @@ public class AdminServiceImpl extends ServiceImpl<AdminMapper, Admin> implements
                 wrapper.eq(Admin::getPhone, phone);
             }
             if (roleId != null) {
-                wrapper.eq(Admin::getRoleId, roleId);
+                // roleIds是逗号分隔的字符串,使用like模糊匹配
+                wrapper.like(Admin::getRoleIds, roleId.toString());
             }
             if (status != null) {
                 wrapper.eq(Admin::getStatus, status);
             }
-            
+
             // 按创建时间倒序
             wrapper.orderByDesc(Admin::getCreateTime);
-            
+
             // 分页查询
             Page<Admin> pageObj = new Page<>(page, pageSize);
             IPage<Admin> result = this.page(pageObj, wrapper);
-            
+
             // 密码字段置空
             result.getRecords().forEach(admin -> admin.setPassword(null));
-            
+
             return Result.success("查询成功", result);
-            
+
         } catch (Exception e) {
             log.error("查询管理员列表失败", e);
             return Result.error(500, "查询失败: " + e.getMessage());
         }
     }
-    
+
     @Override
     public Result<Void> addAdmin(Admin admin) {
         try {
             // 检查用户名是否已存在
-            Admin existAdmin = baseMapper.selectByUsername(admin.getUsername());
+            Admin existAdmin = lambdaQuery().eq(Admin::getUsername, admin.getUsername()).one();
             if (existAdmin != null) {
                 return Result.error(400, "用户名已存在");
             }
-            
+
             // 检查手机号是否已存在
             if (StringUtils.hasText(admin.getPhone())) {
-                existAdmin = baseMapper.selectByPhone(admin.getPhone());
+                existAdmin = lambdaQuery().eq(Admin::getPhone, admin.getPhone()).one();
                 if (existAdmin != null) {
                     return Result.error(400, "手机号已存在");
                 }
             }
-            
+
             // 设置默认值
             admin.setStatus(1); // 默认正常状态
             admin.setCreateTime(LocalDateTime.now());
             admin.setUpdateTime(LocalDateTime.now());
-            
+
             // 临时方案:密码明文存储,生产环境需要加密
             if (!StringUtils.hasText(admin.getPassword())) {
                 admin.setPassword("123456"); // 默认密码
             }
-            
+
             boolean success = this.save(admin);
             return success ? Result.success("添加成功", null) : Result.error(500, "添加失败");
-            
+
         } catch (Exception e) {
             log.error("添加管理员失败", e);
             return Result.error(500, "添加失败: " + e.getMessage());
         }
     }
-    
+
     @Override
     public Result<Void> updateAdmin(Admin admin) {
         try {
@@ -105,36 +106,36 @@ public class AdminServiceImpl extends ServiceImpl<AdminMapper, Admin> implements
             if (existAdmin == null) {
                 return Result.error(404, "管理员不存在");
             }
-            
+
             // 如果修改了用户名,检查是否重复
             if (!existAdmin.getUsername().equals(admin.getUsername())) {
-                Admin checkAdmin = baseMapper.selectByUsername(admin.getUsername());
+                Admin checkAdmin = lambdaQuery().eq(Admin::getUsername, admin.getUsername()).one();
                 if (checkAdmin != null) {
                     return Result.error(400, "用户名已存在");
                 }
             }
-            
+
             // 如果修改了手机号,检查是否重复
             if (StringUtils.hasText(admin.getPhone()) && !admin.getPhone().equals(existAdmin.getPhone())) {
-                Admin checkAdmin = baseMapper.selectByPhone(admin.getPhone());
+                Admin checkAdmin = lambdaQuery().eq(Admin::getPhone, admin.getPhone()).one();
                 if (checkAdmin != null) {
                     return Result.error(400, "手机号已存在");
                 }
             }
-            
+
             admin.setUpdateTime(LocalDateTime.now());
             // 不允许通过此接口修改密码
             admin.setPassword(null);
-            
+
             boolean success = this.updateById(admin);
             return success ? Result.success("更新成功", null) : Result.error(500, "更新失败");
-            
+
         } catch (Exception e) {
             log.error("更新管理员失败", e);
             return Result.error(500, "更新失败: " + e.getMessage());
         }
     }
-    
+
     @Override
     public Result<Void> deleteAdmin(Long id) {
         try {
@@ -143,18 +144,18 @@ public class AdminServiceImpl extends ServiceImpl<AdminMapper, Admin> implements
             if (admin == null) {
                 return Result.error(404, "管理员不存在");
             }
-            
+
             // TODO: 检查是否可以删除(如果是超级管理员则不允许删除)
-            
+
             boolean success = this.removeById(id);
             return success ? Result.success("删除成功", null) : Result.error(500, "删除失败");
-            
+
         } catch (Exception e) {
             log.error("删除管理员失败", e);
             return Result.error(500, "删除失败: " + e.getMessage());
         }
     }
-    
+
     @Override
     public Result<Void> resetPassword(Long id, String newPassword) {
         try {
@@ -162,45 +163,45 @@ public class AdminServiceImpl extends ServiceImpl<AdminMapper, Admin> implements
             if (admin == null) {
                 return Result.error(404, "管理员不存在");
             }
-            
+
             // 临时方案:密码明文存储,生产环境需要加密
             if (!StringUtils.hasText(newPassword)) {
                 newPassword = "123456"; // 默认密码
             }
-            
+
             admin.setPassword(newPassword);
             admin.setUpdateTime(LocalDateTime.now());
-            
+
             boolean success = this.updateById(admin);
             return success ? Result.success("密码重置成功", null) : Result.error(500, "密码重置失败");
-            
+
         } catch (Exception e) {
             log.error("重置密码失败", e);
             return Result.error(500, "重置密码失败: " + e.getMessage());
         }
     }
-    
+
     @Override
     public Result<Map<String, Object>> getStatistics() {
         try {
             Map<String, Object> statistics = new HashMap<>();
-            
+
             // 总管理员数
             long totalUsers = this.count();
             statistics.put("totalUsers", totalUsers);
-            
+
             // 正常状态管理员数
             long activeUsers = this.count(new LambdaQueryWrapper<Admin>().eq(Admin::getStatus, 1));
             statistics.put("activeUsers", activeUsers);
-            
+
             // 在线用户数(暂时返回0,后续可通过Redis统计)
             statistics.put("onlineUsers", 0);
-            
+
             // 今日新增
             statistics.put("todayNew", 0);
-            
+
             return Result.success("获取成功", statistics);
-            
+
         } catch (Exception e) {
             log.error("获取统计数据失败", e);
             return Result.error(500, "获取统计数据失败: " + e.getMessage());