package com.ruoyi.bst.feeLog.service.impl;

import org.springframework.stereotype.Service;

import com.ruoyi.bst.feeLog.domain.FeeLog;
import com.ruoyi.bst.feeLog.domain.FeeLogInfo;
import com.ruoyi.bst.feeLog.service.FeeLogConverter;
import com.ruoyi.bst.order.domain.Order;
import com.ruoyi.bst.order.domain.dto.OrderUpdatePriceDTO;

@Service
public class FeeLogConverterImpl implements FeeLogConverter {
    
    @Override
    public FeeLogInfo toFeeLogInfo(Order order) {
        if (order == null) {
            return null;
        }
        FeeLogInfo info = new FeeLogInfo();
        info.setRidingFee(order.getRidingFee());
        info.setDispatchFee(order.getDispatchFee());
        info.setManageFee(order.getManageFee());
        return info;
    }

    @Override
    public FeeLogInfo toFeeLogInfo(OrderUpdatePriceDTO dto) {
        if (dto == null) {
            return null;
        }
        FeeLogInfo info = new FeeLogInfo();
        info.setRidingFee(dto.getRidingFee());
        info.setDispatchFee(dto.getDispatchFee());  
        info.setManageFee(dto.getManageFee());
        return info;
    }
    
    @Override
    public FeeLog toPo(OrderUpdatePriceDTO dto, Order order) {
        if (dto == null || order == null) {
            return null;
        }

        FeeLog po = new FeeLog();
        po.setOrderId(order.getId());
        po.setBeforeFee(this.toFeeLogInfo(order));
        po.setAfterFee(this.toFeeLogInfo(dto));
        po.setUserId(dto.getUserId());
        po.setReason(dto.getReason());
        po.setAreaId(order.getAreaId());
        return po;
    }
    
}
