<?php
/**
 * Created by PhpStorm.
 * User: z-yang
 * Date: 2018/6/29
 * Time: 15:48
 */

namespace App\Http\Controllers\Finance;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use DB;
class OfficialBillController extends Controller
{

    public function __construct()
    {
        $this->middleware(['official_finance']);
    }

    public function BillLists(){
        $uid = session('finance_manage_channel_uer_id');
        $data = DB::table('distribution_channels')
            ->join('official_accounts','distribution_channels.id','=','official_accounts.distribution_channel_id')
            ->join('official_account_day_sub_stats as a','a.appid','=','official_accounts.appid')
            ->where('distribution_channels.channel_user_id',$uid)
            ->select('a.appid','a.official_account_name',DB::raw('sum(a.reward_balance) as reward_balance'),DB::raw('sum(a.charge_balance) charge_balance'),DB::raw('sum(a.fee) as fee'),'a.month')
            ->groupBy('a.month','a.appid','a.official_account_name')
            ->paginate(30);
        return view('finance.fiance.lists',['data'=>$data]);
    }
}