<?php
/**
 * Created by PhpStorm.
 * User: tandunzhao
 * Date: 2017/12/4
 * Time: 上午10:14
 */

namespace App\Modules\Finance\Services;


use App\Modules\Channel\Services\ChannelService;
use App\Modules\Finance\Models\Bill;

class BillService
{

    /**
     * 获取结算列表
     * @param $params[]
     *                  channel_id:渠道ID 可选
     *                  channel_name:渠道名称 可选
     *                  search_name: 搜索名称 可选
     *                  start_date:开始时间 可选
     *                  end_date:结束时间 可选
     * * @param bool $is_all
     * @return mixed
     */
    public static function getBillList($params = [], $is_all=false) {
        $result = Bill::getBillList($params, $is_all);
        return $result;
    }

    /**
     *
     * @param $channelId 渠道ID
     * @param $rechargeAmount 渠道充值总额
     */
    public static function addBill($channelId, $rechargeAmount) {
        $channelName = ChannelService::getChannelNicknameById($channelId);
        Bill::makeBill($channelId, $channelName, $rechargeAmount);
    }

    /**
     * 获取当前渠道当前结算比例
     * @param $channelId
     * @return float
     */
    public static function getRate($channelId) {
        return Bill::getRate($channelId);
    }
    
    public static function getOne($channelId,$date){
        return Bill::getOne($channelId,$date);
    }
}