Files
liche/api/controllers/wxapp/licheb/Finance.php
T
2021-09-09 21:25:32 +08:00

97 lines
3.1 KiB
PHP

<?php
defined('WXAPP_APP') OR exit('No direct script access allowed');
/**
* Created by Vim
* User: lcc
* Date: 2021/09/09
* Time: 14:08
*/
require_once APPPATH.'controllers/wxapp/Wxapp.php';
class Finance extends Wxapp{
public function __construct($inputs, $app_key){
parent::__construct($inputs, $app_key);
$this->login_white = array();//登录白名单
$this->check_status = array();//用户状态校验
$this->check_mobile = array();//需要手机号
$this->check_headimg =array();//授权微信信息
$this->load->model('auto/auto_series_model');
$this->load->model('auto/auto_cars_model');
$this->load->model('auto/auto_finance_model');
$this->load->model('sys/sys_finance_model');
}
protected function get(){
$page = $this->input_param('page');
$size = $this->input_param('size');
!$page && $page = 1;
!$size && $size = 10;
$where = [
'status' => 1
];
$count = $this->sys_finance_model->count($where);
$lists = [];
if($count){
$rows = $this->sys_finance_model->select($where,'id desc',$page,$size,'id,title');
foreach($rows as $key => $val){
$lists[] = $val;
}
}
$data = [
'list' => $lists,
'total' => $count
];
return $data;
}
protected function get_nums(){
$car_id = $this->input_param('car_id');
$color_id = $this->input_param('color_id');
$incolor_id = $this->input_param('incolor_id');
$v_id = $this->input_param('v_id');
$finance_id = $this->input_param('finance_id');
$page = $this->input_param('page');
$size = $this->input_param('size');
!$page && $page = 1;
!$size && $size = 10;
$series_row = $this->auto_series_model->get(['id'=>$car_id],'id,brand_id');
$row = $this->auto_finance_model->get(['id'=>$finance_id],'id');
if(!$series_row || !$row){
throw new Exception('参数错误', ERR_PARAMS_ERROR);
}
$car_row = $this->auto_cars_model->get(['brand_id'=>$series_row['brand_id'],'s_id'=>$series_row['id'],'v_id'=>$v_id,'cor_id'=>$color_id,'incor_id'=>$incolor_id],'id,price_car');
$where = [
'car_id' => $car_row['id'],
'fin_id' => $row['id'],
'status' => 1
];
$count = $this->auto_finance_model->count($where);
$lists = [];
if($count){
$rows = $this->auto_finance_model->select($where,'id desc',$page,$size,'id,num,first_pay,month_pay');
foreach($rows as $key => $val){
$loan_money = $car_row['price_car'] - $val['first_pay'];
$lists[] = [
'id' => $val['id'],
'num' => $val['num'],
'loan_money' => $loan_money,
'month_pay' => $val['month_pay']
];
}
}
$data = [
'list' => $lists,
'total' => $count
];
return $data;
}
}