Commit 9c782cb2 authored by hujun's avatar hujun

费用报销审核

parent 422317c2
......@@ -10,11 +10,125 @@ namespace app\index\controller;
use app\index\extend\Basic;
use app\model\FApplyForFee;
use app\model\FApplyForFeeCheck;
class Cost extends Basic
{
/**
* 费用报销列表
*
* @return \think\Response
*/
public function getCostList() {
$pageNo = empty($this->params['pageNo']) ? 1 : $this->params['pageNo'];
$pageSize = empty($this->params['pageSize']) ? 15 : $this->params['pageSize'];
$where = $this->buildWhere($this->params);
$field = 'a.id,a.count_time,a.source,a.type,a.create_time,a.agent_id,a.total_fee,a.fee_item,a.purpose,a.status,b.name as agent_name';
$fee_model = new FApplyForFee();
$list = $fee_model->getJoinAgentList($pageNo, $pageSize, 'ID DESC', $field, $where);
$data['list'] = &$list;
$data['total'] = $fee_model->getJoinAgentListTotal($where);
return $this->response(200, '', $data);
}
/**
* 构造条件
*
* @param $param
* @return mixed
*/
private function buildWhere($param)
{
if (isset($param['checkout_status'])) {
switch($this->params['check_status']) {
case 0 :
$where['a.status'] = 0;break;
case 1 :
$where['a.status'] = 1;break;
case 2 :
$where['a.status'] = 2;break;
case 3 :
$where['a.status'] = 3;break;
case 4 :
$where['a.status'] = 4;break;
}
}
$where['a.is_del'] = 0;
//默认提交的月份
if (isset($params['count_time'])) {
$where['a.count_time'] = $param['count_time'];
}
//申请提交时间
if (isset($param['create_time_start'])) {
$where['a.create_time'] = ['>=', $param['create_time_start']];
}
//申请提交时间
if (isset($param['create_time_end'])) {
$where['a.create_time'] = ['<=', $param['create_time_end']];
}
//申请提交时间
if (isset($param['create_time_start']) && isset($param['create_time_end'])) {
$where['a.create_time'] = ['between', [$param['create_time_start']. ' 00:00:00', $param['create_time_end'].' 23:59:59']];
}
//财务三审通过时间
if (isset($param['pass_time_start'])) {
$check_where['create_time'] = ['>=', $param['pass_time_start']];
}
//财务三审通过时间
if (isset($param['pass_time_end'])) {
$check_where['a.create_time'] = ['<=', $param['pass_time_end']];
}
//财务三审通过时间
if (isset($param['pass_time_start']) && isset($param['pass_time_end'])) {
$check_where['a.create_time'] = ['between', [$param['pass_time_end']. ' 00:00:00', $param['pass_time_end'].' 23:59:59']];
}
if (isset($check_where)) {
$m_fee_check = new FApplyForFeeCheck();
$check_where['is_del'] = 0;
$check_where['type'] = $where['a.status'] = 4;
$fee_id = $m_fee_check->findColumn('apply_for_id', $check_where);
$where['a.id'] = ['in', $fee_id];
}
//费用类型
if (isset($param['type'])) {
$where['a.type'] = $param['type'];
}
//站点
if (isset($param['site_id'])) {
$where['a.site_id'] = $param['site_id'];
}
//编号
if (isset($param['id'])) {
$where['a.id'] = $param['id'];
}
//提交人id
if (isset($param['agent_id'])) {
$where['a.agent_id'] = $param['agent_id'];
}
//提交人门店id
if (isset($param['store_id'])) {
$where['a.store_id'] = $param['store_id'];
}
//提交人部门id
if (isset($param['district_id'])) {
$where['b.district_id'] = $param['district_id'];
}
return $where;
}
}
\ No newline at end of file
......@@ -41,4 +41,33 @@ class FApplyForFee extends BaseModel
->find();
return $result;
}
/**
* @param int $pageNo
* @param int $pageSize
* @param string $order_
* @param string $field
* @param string $params
* @return false|\PDOStatement|string|\think\Collection
*/
public function getJoinAgentList($pageNo = 1, $pageSize = 15, $order_ = 'a.id desc', $field = '', $params = '') {
return $this->field($field)->alias('a')
->join('a_agents b', 'a.agent_id=b.id','left')
->where($params)
->order($order_)
->limit($pageSize)
->page($pageNo)
->select();
}
/**
* @param string $params
* @return int|string
*/
public function getJoinAgentListTotal($params = '') {
return $this->alias('a')
->join('a_agents b', 'a.agent_id=b.id','left')
->where($params)
->count('a.id');
}
}
......@@ -41,4 +41,15 @@ class FApplyForFeeCheck extends BaseModel
->find();
return $result;
}
/**
* @param $field
* @param $params
* @return array
*/
public function findColumn($field,$params) {
return $this->db_
->where($params)
->column($field);
}
}
......@@ -524,6 +524,12 @@ Route::group('index', [
'getOfficeInfo' => [ 'index/StoreFee/getOfficeInfo', [ 'method' => 'POST|GET' ] ],
'editOffice' => [ 'index/StoreFee/editOffice', [ 'method' => 'POST|GET' ] ],
'getStoreList' => [ 'index/StoreFee/getStoreList', [ 'method' => 'POST|GET' ] ],
'getCostList' => ['index/Cost/getCostList', ['method' => 'GET']], //费用报销审核全部
'getCostListOne/:check_status' => ['index/Cost/getCostList', ['method' => 'GET'], ['check_status' => 0]], //费用报销审核总监
'getCostListTwo/:check_status' => ['index/Cost/getCostList', ['method' => 'GET'], ['check_status' => 1]], //费用报销审核一审
'getCostListThree/:check_status' => ['index/Cost/getCostList', ['method' => 'GET'], ['check_status' => 2]], //费用报销审核二审
'getCostListFour/:check_status' => ['index/Cost/getCostList', ['method' => 'GET'], ['check_status' => 3]], //费用报销审核三审
'getCostListFive/:check_status' => ['index/Cost/getCostList', ['method' => 'GET'], ['check_status' => 3]], //费用报销审核四审
]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment