<?php
namespace Agent\Controller;
use Api\Model\OrderModel;

/**
 * 收入控制器
 */
class IncomeController extends AdminController {


    /**
     * 列表页
     */
    public function index(){

        $map['mid'] = UID;
        $map['is_fault'] = 0;
        
        $obj = M('OrderFinish');
        $income_total1 = $obj->where($map)->sum('total_fee');
        $income_total2 = $obj->where($map)->sum('pay_plus');
        $income_total = $income_total1 + $income_total2;
        
        $yestoday = strtotime(date('Y-m-d'));
        $map['createtime'] = array('elt',$yestoday);
        
        $income_fetch1 = $obj->where($map)->sum('total_fee');
        $income_fetch2 = $obj->where($map)->sum('pay_plus');
        $income_fetch = $income_fetch1 + $income_fetch2;
        
        $can_fetch = 0;
        $day = date('w');
        $time_1 = $yestoday+3600*9;
        $time_2 = $yestoday+3600*17;
        $now = time();
        if($day==1 && ($now>=$time_1 && $now<=$time_2 )){
            $can_fetch = 1;
        }
        
        $this->assign('income_total',$income_total);
        $this->assign('income_fetch',$income_fetch);
        $this->assign('can_fetch',$can_fetch);
        $this->meta_title = 'My income';
        $this->display();
    }



}