package com.sifang.modules.site.financial.service;

import com.jfinal.plugin.activerecord.Record;
import com.sifang.modules.site.financial.dao.FinancialManageDao;
import com.sifang.modules.sys.common.service.BaseService;
import com.sifang.modules.sys.common.utils.MathUtils;
import com.sifang.modules.sys.util.LayuiPage;
import com.sifang.modules.sys.util.TrimStrMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;

@Repository
public class FinancialManageService extends BaseService {

    @Autowired
    private FinancialManageDao financialManageDao;

    /**
     * 获取列表数据
     *
     * @return
     */
    public void getListData(TrimStrMap parasMap, LayuiPage<Record> page, String siteId) {
        financialManageDao.getListData(parasMap, page, siteId);
    }

    /**
     * 获取当前服务商id
     *
     * @param userId
     * @return
     */
    public String getSiteId(String userId) {
        return financialManageDao.getSiteId(userId);
    }

    /**
     * 工单结算计算工单结算总金额。
     */
    public BigDecimal calcOrderTotalCosts(Record settlement) {
        return MathUtils.sumBigDecimal(settlement.getBigDecimal("service_costs"), settlement.getBigDecimal("reward_costs"), settlement.getBigDecimal("other_cost"), settlement.getBigDecimal("mileage_cost"), settlement.getBigDecimal("exigency_costs"));
    }


}
