Pu Zhibing
2024-12-06 7dc4502634b3b5a982a9899dbf8e36d0b016231c
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java
@@ -1,5 +1,6 @@
package com.ruoyi.order.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -14,6 +15,8 @@
import com.ruoyi.order.enums.OrderType;
import com.ruoyi.order.mapper.OrderGoodMapper;
import com.ruoyi.order.mapper.OrderMapper;
import com.ruoyi.order.model.Order;
import com.ruoyi.order.model.OrderGood;
import com.ruoyi.order.service.OrderService;
import com.ruoyi.order.vo.OrderDetailVO;
import com.ruoyi.order.vo.OrderGoodsVO;
@@ -22,17 +25,13 @@
import com.ruoyi.other.api.domain.Goods;
import com.ruoyi.other.api.domain.OrderActivityInfo;
import com.ruoyi.other.api.domain.Technician;
import com.ruoyi.other.api.feignClient.GoodsClient;
import com.ruoyi.other.api.feignClient.TechnicianClient;
import com.ruoyi.system.api.model.LoginUser;
import model.Order;
import model.OrderGood;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@@ -58,7 +57,8 @@
    @Resource
    private TechnicianClient technicianClient;
    @Resource
    private RedisTemplate<String, String> redisTemplate;
    private GoodsClient goodsClient;
    @Override
    public List<OrderVO> selectOrderListByUserId(Integer status, Long userId) {
@@ -74,6 +74,7 @@
        if (order == null){
            throw new ServiceException("订单不存在");
        }
        // 商品
        List<OrderGood> orderGoods = orderGoodMapper.selectList(new LambdaQueryWrapper<OrderGood>()
                .eq(OrderGood::getOrderId, orderId));
@@ -85,14 +86,17 @@
            OrderGoodsVO orderGoodsVO = new OrderGoodsVO();
            orderGoodsVO.setGoodsId(orderGood.getGoodsId());
            orderGoodsVO.setGoodsName(goods.getName());
            orderGoodsVO.setType(goods.getType());
            orderGoodsVO.setNum(orderGood.getNum());
            orderGoodsVO.setGoodsPic(goods.getHomePagePicture());
            orderGoodsVO.setSellingPrice(goods.getSellingPrice());
            orderGoodsVO.setOriginalPrice(goods.getOriginalPrice());
            if (goods != null){
                orderGoodsVO.setGoodsName(goods.getName());
                orderGoodsVO.setType(goods.getType());
                orderGoodsVO.setGoodsPic(goods.getHomePagePicture());
                orderGoodsVO.setSellingPrice(goods.getSellingPrice());
                orderGoodsVO.setOriginalPrice(goods.getOriginalPrice());
            }
            goodsList.add(orderGoodsVO);
        }
        // 收货地址
@@ -118,7 +122,17 @@
        }
        OrderDetailVO orderDetailVO = new OrderDetailVO();
        if (CollectionUtil.isNotEmpty(orderGoods)){
            String goodJson = orderGoods.get(0).getGoodJson();
            Goods goods = JSONObject.parseObject(goodJson, Goods.class);
            orderDetailVO.setDistributionMode(goods.getDistributionMode());
        }
        orderDetailVO.setId(order.getId());
        orderDetailVO.setOrderStatus(order.getOrderStatus());
        orderDetailVO.setPoint(order.getPoint());
        orderDetailVO.setAddressId(userAddress.getId());
        orderDetailVO.setRecieveName(userAddress.getRecieveName());
@@ -191,15 +205,9 @@
    }
    /**
     * 返佣延迟队列
     *
     * @param orderId           订单ID
     * @param afterSalesDeadline 售后截止日期(计算日期)
     */
    private void addToCommissionDelayQueue(Long orderId, LocalDateTime afterSalesDeadline) {
        // 获取订单售后截止日期时间戳(秒)
        long deadlineTimestamp = afterSalesDeadline.atZone(ZoneId.systemDefault()).toEpochSecond();
        redisTemplate.opsForZSet().add("delay_queue:commission", orderId.toString(), deadlineTimestamp);
    @Override
    public void commission(Long orderId) {
    }
}