赛亿提成统计系统

Commission.php 2.1KB

    <?php namespace app\index\controller; use daswork\Controller; use daswork\lib\Config; use app\index\model\MonthPicker; use app\index\model\Commission as CommissionModel; use app\index\model\Company; class Commission extends Controller { public $maonth_picker; public $model; protected $params; public function __construct() { parent::__construct(); $this->maonth_picker = new MonthPicker(); $this->model = new CommissionModel(); $this->params = escapeString($_POST); } public function index() { $slect_time = isset($_GET['select_time']) ? $_GET['select_time'] : ''; if ($slect_time != '') { $this->maonth_picker->cur_month = $slect_time; } $this->assign('maonth_picker', $this->maonth_picker); $c_type = isset($_GET['c_type']) ? $_GET['c_type'] : ''; if ($c_type != '') { $c_type = intval($c_type); } $this->assign('c_type', $c_type); $company = new Company(); $data_company = $company->listByName(); // var_dump($data_company); $this->assign('data_company', $data_company); // $where = " where month='". $this->maonth_picker->cur_month . "' "; // if ($c_type !=='') { // $where .= " and type=$c_type "; // } // $where .= " order by id desc"; // $data = $this->model->list($where); // $this->assign('data', $data); $this->fetch(); } public function perbalance() { $company = $this->params['company']; $sql = "select sum(receive_money - contract_value) as pb from commission where company='$company';" ; $sqlinitbalance = "select initial_balance from company where name='$company';"; $result = $this->model->query($sql); $data = $result->fetchArray(SQLITE3_ASSOC); $result2 = $this->model->query($sqlinitbalance); $data2 = $result2->fetchArray(SQLITE3_ASSOC); $perbalance = $data['pb']; $initbalance = $data2['initial_balance']; echo json_encode(['code'=>0, 'data'=>$perbalance + $initbalance]); } }