毕设验收前一周,导师却要求增加功能?《护肤品推荐系统》模块化设计让你从容应对|基于springboot的护肤品推荐系统|毕业设计

38 阅读5分钟

一、个人简介

💖💖作者:计算机编程果茶熊 💙💙个人简介:曾长期从事计算机专业培训教学,担任过编程老师,同时本人也热爱上课教学,擅长Java、微信小程序、Python、Golang、安卓Android等多个IT方向。会做一些项目定制化开发、代码讲解、答辩教学、文档编写、也懂一些降重方面的技巧。平常喜欢分享一些自己开发中遇到的问题的解决办法,也喜欢交流技术,大家有技术代码这一块的问题可以问我! 💛💛想说的话:感谢大家的关注与支持! 💜💜 网站实战项目 安卓/小程序实战项目 💕💕文末获取源码联系计算机编程果茶熊 二、前言

开发语言:Java+Python 数据库:MySQL 系统架构:B/S 后端框架:SpringBoot(Spring+SpringMVC+Mybatis)+Django 前端:Vue+HTML+CSS+JavaScript+jQuery

《护肤品推荐系统》是一款基于B/S架构的综合性护肤品管理与推荐平台,采用Java/Python双版本支持,分别基于Spring Boot(Spring+SpringMVC+Mybatis)和Django框架开发,前端使用Vue+ElementUI+HTML技术栈,数据库采用MySQL。系统功能丰富完善,包括系统首页、个人中心、用户管理、皮肤医生管理、护肤品类型管理、护肤品管理、线上问诊管理、问诊回复管理、留言板、护肤论坛、系统管理和订单管理等十二大核心模块。该系统通过整合专业皮肤医生资源与多样化护肤品信息,为用户提供个性化的护肤方案和产品推荐,同时支持线上问诊功能,使用户能够便捷地获取专业护肤建议。系统还设有护肤论坛和留言板功能,促进用户之间的交流与分享,形成良好的社区氛围。后台管理系统则实现了对用户、医生、护肤品及订单的全方位管理,保证了平台的高效运营和良好用户体验。整体架构清晰,功能模块划分合理,技术实现稳定可靠,是一个集护肤咨询、产品推荐、社区交流和电子商务于一体的综合性护肤服务平台。 三、基于springboot的护肤品推荐系统-视频解说

毕设验收前一周,导师却要求增加功能?《护肤品推荐系统》模块化设计让你从容应对|基于springboot的护肤品推荐系统|毕业设计

四、基于springboot的护肤品推荐系统-功能介绍

以下仅展示部分功能: 首页 护肤品推荐 个人中心 商品详情 皮肤医生 皮肤医生 购物车模块 充值 信息公告 后台管理 五、基于springboot的护肤品推荐系统-代码展示

以下仅展示部分代码:

// 核心功能1: 护肤品智能推荐服务 @Service public class SkinCareRecommendationService {

@Autowired
private SkinCareProductRepository productRepository;

@Autowired
private UserProfileRepository userProfileRepository;

@Autowired
private SkinTypeRepository skinTypeRepository;

/**
 * 基于用户皮肤类型和问题推荐护肤品
 */
public List<SkinCareProductDTO> recommendProducts(Long userId, List<String> skinConcerns) {
    UserProfile userProfile = userProfileRepository.findById(userId)
            .orElseThrow(() -> new ResourceNotFoundException("用户不存在"));
    
    SkinType userSkinType = skinTypeRepository.findById(userProfile.getSkinTypeId())
            .orElseThrow(() -> new ResourceNotFoundException("皮肤类型不存在"));
    
    // 根据用户皮肤类型筛选适合的产品
    List<SkinCareProduct> suitableProducts = productRepository.findBySkinTypeAndActive(
            userSkinType.getTypeName(), true);
    
    // 根据用户关注的皮肤问题进行二次筛选
    Map<SkinCareProduct, Integer> productScores = new HashMap<>();
    
    for (SkinCareProduct product : suitableProducts) {
        int matchScore = 0;
        for (String concern : skinConcerns) {
            if (product.getEffects().contains(concern)) {
                matchScore += 2;
            }
            if (product.getIngredients().stream()
                    .anyMatch(i -> i.getTargetConcerns().contains(concern))) {
                matchScore += 1;
            }
        }
        
        // 考虑用户历史购买和评价
        if (userProfile.getPurchaseHistory().contains(product.getId())) {
            // 如果用户之前购买过且评价高,提高分数
            Optional<ProductRating> rating = userProfile.getProductRatings().stream()
                    .filter(r -> r.getProductId().equals(product.getId()))
                    .findFirst();
            
            if (rating.isPresent() && rating.get().getRating() >= 4) {
                matchScore += 3;
            }
        }
        
        productScores.put(product, matchScore);
    }
    
    // 按匹配分数排序并转换为DTO
    return productScores.entrySet().stream()
            .sorted(Map.Entry.<SkinCareProduct, Integer>comparingByValue().reversed())
            .limit(10)
            .map(entry -> convertToDTO(entry.getKey()))
            .collect(Collectors.toList());
}

private SkinCareProductDTO convertToDTO(SkinCareProduct product) {
    // 转换逻辑
    return new SkinCareProductDTO(product);
}

}

// 核心功能2: 线上问诊管理服务 @Service public class OnlineConsultationService {

@Autowired
private ConsultationRepository consultationRepository;

@Autowired
private DoctorRepository doctorRepository;

@Autowired
private UserRepository userRepository;

@Autowired
private NotificationService notificationService;

/**
 * 创建新的问诊记录并分配医生
 */
@Transactional
public ConsultationDTO createConsultation(ConsultationRequest request) {
    // 验证用户
    User user = userRepository.findById(request.getUserId())
            .orElseThrow(() -> new ResourceNotFoundException("用户不存在"));
    
    // 创建问诊记录
    Consultation consultation = new Consultation();
    consultation.setUser(user);
    consultation.setTitle(request.getTitle());
    consultation.setDescription(request.getDescription());
    consultation.setSkinPhotos(request.getSkinPhotoUrls());
    consultation.setStatus(ConsultationStatus.PENDING);
    consultation.setCreatedAt(LocalDateTime.now());
    
    // 根据用户问题和医生专长自动分配最合适的医生
    List<Doctor> availableDoctors = doctorRepository.findByStatusAndSpecialization(
            DoctorStatus.ACTIVE, 
            extractSpecialization(request.getDescription()));
    
    // 如果找不到专科医生,则分配给通用皮肤科医生
    if (availableDoctors.isEmpty()) {
        availableDoctors = doctorRepository.findByStatusAndSpecializationGeneral(
                DoctorStatus.ACTIVE);
    }
    
    // 根据医生当前工作量和评分进行排序
    Doctor assignedDoctor = availableDoctors.stream()
            .sorted(Comparator
                    .comparing(Doctor::getCurrentWorkload)
                    .thenComparing(Doctor::getRating, Comparator.reverseOrder()))
            .findFirst()
            .orElseThrow(() -> new ServiceException("当前没有可用的医生"));
    
    consultation.setDoctor(assignedDoctor);
    
    // 更新医生工作量
    assignedDoctor.setCurrentWorkload(assignedDoctor.getCurrentWorkload() + 1);
    doctorRepository.save(assignedDoctor);
    
    // 保存问诊记录
    Consultation savedConsultation = consultationRepository.save(consultation);
    
    // 发送通知给医生和用户
    notificationService.sendDoctorConsultationNotification(assignedDoctor.getId(), 
            savedConsultation.getId(), user.getName());
    notificationService.sendUserConsultationNotification(user.getId(),
            savedConsultation.getId(), assignedDoctor.getName());
    
    return convertToDTO(savedConsultation);
}

/**
 * 从问诊描述中提取可能的专科领域
 */
private String extractSpecialization(String description) {
    Map<String, Integer> specializationScores = new HashMap<>();
    specializationScores.put("痤疮", countKeywords(description, Arrays.asList("痤疮", "青春痘", "粉刺", "暗疮")));
    specializationScores.put("敏感肌", countKeywords(description, Arrays.asList("敏感", "泛红", "刺痛", "过敏")));
    specializationScores.put("色斑", countKeywords(description, Arrays.asList("色斑", "黄褐斑", "雀斑", "晒斑")));
    specializationScores.put("抗衰老", countKeywords(description, Arrays.asList("皱纹", "松弛", "衰老", "细纹")));
    
    return specializationScores.entrySet().stream()
            .max(Map.Entry.comparingByValue())
            .map(Map.Entry::getKey)
            .orElse("一般皮肤问题");
}

private int countKeywords(String text, List<String> keywords) {
    int count = 0;
    for (String keyword : keywords) {
        if (text.contains(keyword)) {
            count++;
        }
    }
    return count;
}

private ConsultationDTO convertToDTO(Consultation consultation) {
    // 转换逻辑
    return new ConsultationDTO(consultation);
}

}

// 核心功能3: 订单管理服务 @Service public class OrderManagementService {

@Autowired
private OrderRepository orderRepository;

@Autowired
private ProductRepository productRepository;

@Autowired
private UserRepository userRepository;

@Autowired
private InventoryService inventoryService;

@Autowired
private PaymentService paymentService;

/**
 * 创建并处理新订单
 */
@Transactional
public OrderDTO createOrder(OrderRequest orderRequest) {
    // 验证用户
    User user = userRepository.findById(orderRequest.getUserId())
            .orElseThrow(() -> new ResourceNotFoundException("用户不存在"));
    
    // 创建订单
    Order order = new Order();
    order.setUser(user);
    order.setOrderNumber(generateOrderNumber());
    order.setStatus(OrderStatus.PENDING);
    order.setCreatedAt(LocalDateTime.now());
    order.setShippingAddress(orderRequest.getShippingAddress());
    order.setContactPhone(orderRequest.getContactPhone());
    
    // 计算订单总金额和处理订单项
    BigDecimal totalAmount = BigDecimal.ZERO;
    List<OrderItem> orderItems = new ArrayList<>();
    
    for (OrderItemRequest itemRequest : orderRequest.getItems()) {
        SkinCareProduct product = productRepository.findById(itemRequest.getProductId())
                .orElseThrow(() -> new ResourceNotFoundException("产品不存在"));
        
        // 检查库存
        if (!inventoryService.checkInventory(product.getId(), itemRequest.getQuantity())) {
            throw new InsufficientInventoryException("产品 " + product.getName() + " 库存不足");
        }
        
        // 创建订单项
        OrderItem orderItem = new OrderItem();
        orderItem.setOrder(order);
        orderItem.setProduct(product);
        orderItem.setQuantity(itemRequest.getQuantity());
        orderItem.setUnitPrice(product.getPrice());
        
        // 应用促销折扣(如果有)
        if (product.getPromotion() != null && product.getPromotion().isActive()) {
            BigDecimal discountRate = product.getPromotion().getDiscountRate();
            BigDecimal discountedPrice = product.getPrice().multiply(
                    BigDecimal.ONE.subtract(discountRate));
            orderItem.setDiscountedPrice(discountedPrice);
            orderItem.setSubtotal(discountedPrice.multiply(BigDecimal.valueOf(itemRequest.getQuantity())));
        } else {
            orderItem.setDiscountedPrice(product.getPrice());
            orderItem.setSubtotal(product.getPrice().multiply(BigDecimal.valueOf(itemRequest.getQuantity())));
        }
        
        orderItems.add(orderItem);
        totalAmount = totalAmount.add(orderItem.getSubtotal());
    }
    
    // 应用运费计算
    BigDecimal shippingFee = calculateShippingFee(orderItems, orderRequest.getShippingAddress());
    order.setShippingFee(shippingFee);
    
    // 设置订单总额
    totalAmount = totalAmount.add(shippingFee);
    order.setTotalAmount(totalAmount);
    
    // 保存订单和订单项
    order.setOrderItems(orderItems);
    Order savedOrder = orderRepository.save(order);
    
    // 预扣库存
    for (OrderItem item : orderItems) {
        inventoryService.reserveInventory(item.getProduct().getId(), item.getQuantity());
    }
    
    // 创建支付记录
    PaymentResult paymentResult = paymentService.initiatePayment(
            savedOrder.getId(), 
            savedOrder.getTotalAmount(),
            orderRequest.getPaymentMethod());
    
    // 更新订单支付信息
    savedOrder.setPaymentId(paymentResult.getPaymentId());
    savedOrder.setPaymentStatus(paymentResult.getStatus());
    if (PaymentStatus.COMPLETED.equals(paymentResult.getStatus())) {
        savedOrder.setStatus(OrderStatus.PAID);
        savedOrder.setPaidAt(LocalDateTime.now());
    }
    
    orderRepository.save(savedOrder);
    
    return convertToDTO(savedOrder);
}

/**
 * 计算运费
 */
private BigDecimal calculateShippingFee(List<OrderItem> items, Address shippingAddress) {
    // 计算商品总重量
    double totalWeight = items.stream()
            .mapToDouble(item -> item.getProduct().getWeight() * item.getQuantity())
            .sum();
    
    // 基础运费
    BigDecimal baseFee = BigDecimal.valueOf(10.0);
    
    // 根据重量调整
    if (totalWeight > 2.0) {
        baseFee = baseFee.add(BigDecimal.valueOf((totalWeight - 2.0) * 5.0));
    }
    
    // 根据地区调整
    String province = shippingAddress.getProvince();
    if (Arrays.asList("西藏", "新疆", "内蒙古", "青海").contains(province)) {
        baseFee = baseFee.multiply(BigDecimal.valueOf(1.5));
    }
    
    // 订单满200免运费
    BigDecimal orderSubtotal = items.stream()
            .map(OrderItem::getSubtotal)
            .reduce(BigDecimal.ZERO, BigDecimal::add);
    
    if (orderSubtotal.compareTo(BigDecimal.valueOf(200)) >= 0) {
        return BigDecimal.ZERO;
    }
    
    return baseFee;
}

private String generateOrderNumber() {
    return "ORD" + System.currentTimeMillis() + new Random().nextInt(1000);
}

private OrderDTO convertToDTO(Order order) {
    // 转换逻辑
    return new OrderDTO(order);
}

六、基于springboot的护肤品推荐系统-文档展示

以下仅展示部分文档:

部分文档.png

七、END

💕💕文末获取源码联系计算机编程果茶熊