package com.ruoyi.ss.order.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.ruoyi.ss.order.domain.OrderVO;
import com.ruoyi.ss.order.service.IOrderAssembler;
import com.ruoyi.ss.orderOper.domain.OrderOper;
import com.ruoyi.ss.orderOper.service.IOrderOperService;
import com.ruoyi.ss.payBill.domain.PayBillVO;
import com.ruoyi.ss.payBill.service.PayBillService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * 订单组装器
 *
 * @author qzz
 * @date 2024-09-19
 */
@Service
public class OrderAssemblerImpl implements IOrderAssembler {

    @Autowired
    private PayBillService paymentService;

    @Autowired
    private IOrderOperService orderOperService;

    /**
     * 拼接后台需要的订单信息
     * @param order 房间对象
     */
    @Override
    public void assembleOrderInfo(OrderVO order) {

        // 支付单信息
        PayBillVO payBillVO = paymentService.selectPayBillByPayId(order.getPayId());
        if(!ObjectUtil.isNull(payBillVO)){
            order.setPayNo(payBillVO.getPayNo());
            order.setPayBillVO(payBillVO);
        }

        // 操作履历
        OrderOper orderOper = new OrderOper();
        orderOper.setOrderNo(order.getOrderNo());
        List<OrderOper> list = orderOperService.selectRlOrderOperList(orderOper);
        order.setOrderOpers(list);
    }
}
