package com.aoyang.tms.service.impl;
import com.aoyang.tms.controller.vo.TmsOtherFeeListVO;
import com.aoyang.tms.entity.TmsOtherFee;
import com.aoyang.tms.mapper.TmsOtherFeeMapper;
import com.aoyang.tms.service.TmsOtherFeeService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
/**
*
* 其他费用表 服务实现类
*
*
* @author liujiren
* @since 2022-04-23
*/
@Service
public class TmsOtherFeeServiceImpl extends ServiceImpl implements TmsOtherFeeService {
@Override
public List list(TmsOtherFee param) {
QueryWrapper queryWrapper = new QueryWrapper<>();
if (param.getCycleId() != null) {
queryWrapper.eq("cycle_id", param.getCycleId());
}
if (param.getTruckId() != null) {
queryWrapper.eq("truck_id", param.getTruckId());
}
List list = list(queryWrapper.orderByAsc("create_date"));
List listVOS = new ArrayList<>();
for (TmsOtherFee tmsOtherFee : list) {
TmsOtherFeeListVO tmsOtherFeeListVO = new TmsOtherFeeListVO();
tmsOtherFeeListVO.setOtherFeeId(tmsOtherFee.getId());
tmsOtherFeeListVO.setOtherFeeSum(feeSum(tmsOtherFee));
listVOS.add(tmsOtherFeeListVO);
}
return listVOS;
}
@Override
public BigDecimal feeSum(TmsOtherFee param) {
BigDecimal feeSum = BigDecimal.ZERO;
if (param.getButterFee() != null) {
feeSum = feeSum.add(param.getButterFee());
}
if (param.getMaintenanceFee() != null) {
feeSum = feeSum.add(param.getMaintenanceFee());
}
if (param.getRepairFee() != null) {
feeSum = feeSum.add(param.getRepairFee());
}
if (param.getSaveFee() != null) {
feeSum = feeSum.add(param.getSaveFee());
}
if (param.getTireFee() != null) {
feeSum = feeSum.add(param.getTireFee());
}
if (param.getCarReviewFee() != null) {
feeSum = feeSum.add(param.getCarReviewFee());
}
if (param.getOilChangeFee() != null) {
feeSum = feeSum.add(param.getOilChangeFee());
}
if (param.getWeighingPassingOtherFee() != null) {
feeSum = feeSum.add(param.getWeighingPassingOtherFee());
}
return feeSum;
}
}