Commit ef483be5 authored by hujun's avatar hujun

费用报销审核

parent 2af7bb9a
......@@ -10,6 +10,8 @@ namespace app\index\controller;
use app\index\extend\Basic;
use app\index\service\CostService;
use app\index\untils\ExportExcelUntil;
use app\model\FApplyForFee;
use app\model\FApplyForFeeCheck;
......@@ -21,16 +23,33 @@ class Cost extends Basic
* @return \think\Response
*/
public function getCostList() {
if (!$this->request->isAjax() && $this->params['excel'] != 1) {
return view('cost/costCheck');
}
$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';
$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,';
$field .= 'b.name as agent_name,a.site_id';
$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);
if ($this->params['excel'] != 1) {
$list = $fee_model->getJoinAgentList($pageNo, $pageSize, 'ID DESC', $field, $where);
$data['list'] = &$list;
$data['total'] = $fee_model->getJoinAgentListTotal($where);
return $this->response(200, '', $data);
} else {
$list = $fee_model->getJoinAgentList(1, 100000, 'ID DESC', $field, $where);
foreach ($list as $k=>$v) {
}
$export = new ExportExcelUntil();
// $title = [ 'ID', '提交时间', '商铺地址', '商铺号', '成交价', '提交人', '成交类型', '应收佣金(元)','已收佣金(元)','未收佣金(元)' ];
// $export->exportTable($excel_title, $excel_data, 11, $excel_title, $title);
}
}
/**
......@@ -129,6 +148,16 @@ class Cost extends Basic
if (isset($param['district_id'])) {
$where['b.district_id'] = $param['district_id'];
}
//费用项目
if (isset($param['fee_item'])) {
$where['a.fee_item'] = $param['fee_item'];
}
//详细用途简述
if (isset($param['purpose'])) {
$check_where['a.purpose'] = ['like', '%'.$param['purpose'].'%'];
}
return $where;
}
......@@ -156,4 +185,36 @@ class Cost extends Basic
}
return $this->response($code, $msg);
}
/**
* 审核
*
* @return \think\Response
*/
public function checkCost()
{
$code = 101;
if (empty($this->params['id'])) {
return $this->response($code, '参数错误');
}
switch($this->params['check_status']) {
case 1 :
$this->params['status'] = 1;break;
case 2 :
$this->params['status'] = 2;break;
case 3 :
$this->params['status'] = 3;break;
case 4 :
$this->params['status'] = 4;break;
default :
return $this->response($code, '请求链接参数错误');
}
$service = new CostService();
$result = $service->check($this->params, $this->userId);
if ($result['status'] != 'fail') {
$code = 200;
}
return $this->response($code, $result['msg']);
}
}
\ No newline at end of file
<?php
namespace app\index\service;
use app\model\FApplyForFee;
use app\model\FApplyForFeeCheck;
class CostService
{
private $apply_model;
private $check_model;
public function __construct()
{
$this->apply_model = new FApplyForFee();
$this->check_model = new FApplyForFeeCheck();
}
/**
* 费用报销审核
* status 审核状态 1总监审核 2一审审核 3二审审核 4三审审核
*
* @param $params
* @param $agent_id
* @return mixed
*/
public function check($params, $agent_id)
{
$result['status'] = 'fail';
$where['id'] = $params['id'];
$where['is_del'] = $id = 0;
$cost_data = $this->apply_model->findByOne('id,status', $where);
if (empty($cost_data)) {
$result['msg'] = '无该记录';
return $result;
}
if ($cost_data['status'] == $params['status']) {
$result['msg'] = '已审核过:1';
return $result;
}
$check_where['apply_for_id'] = $cost_data['id'];
$check_where['is_del'] = 0;
try {
$check_data = $this->check_model->findByOneOrder('type', $check_where, 'id desc');
} catch (\Exception $e) {
$result['msg'] = '查询审核记录失败'.$e->getMessage();
return $result;
}
if ($check_data['type'] == $params['status']) {
$result['msg'] = '已审核过:2';
return $result;
}
$save_check['apply_for_id'] = $cost_data['id'];
$save_check['agent_id'] = $agent_id;
$save_check['type'] = $params['status'];
$save_check['remark'] = $params['remark'];
$num = $this->check_model->saveData($save_check);
if ($num) {
try {
$id = $this->apply_model->updateData(['status'=>$params['status']], ['id'=>$cost_data['id']]);
} catch (\Exception $e) {
$result['msg'] = '修改申请记录失败'.$e->getMessage();
return $result;
}
}
if ($id) {
$result['status'] = 'successful';
} else {
$result['msg'] = '审核失败';
}
return $result;
}
}
\ No newline at end of file
......@@ -16,18 +16,29 @@ class FApplyForFee extends BaseModel
$this->db_ = Db::name($this->table);
}
/**
* 新增数据
* @param $data
* @return mixed
* @return int|string
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
public function saveOffice($data) {
$time = date("Y-m-d H:i:s", time());
public function saveData($data) {
$data["is_del"] = 0;
$data['create_time'] = $time;
$data['update_time'] = $time;
return $this->db_->insert($data);
$data['create_time'] = date("Y-m-d H:i:s", time());
$id = $this->db_->insertGetId($data);
return $id;
}
/**
* @param $data
* @return int|string
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
public function updateData($data, $where)
{
$data['update_time'] = date("Y-m-d H:i:s", time());
return $this->db_->update($data);
}
/**
......
......@@ -22,7 +22,7 @@ class FApplyForFeeCheck extends BaseModel
* @param $data
* @return mixed
*/
public function saveOffice($data) {
public function saveData($data) {
$time = date("Y-m-d H:i:s", time());
$data["is_del"] = 0;
$data['create_time'] = $time;
......@@ -52,4 +52,20 @@ class FApplyForFeeCheck extends BaseModel
->where($params)
->column($field);
}
/**
* @param $field
* @param $params
* @param string $order
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function findByOneOrder($field, $params, $order = 'id desc') {
return $this->db_->field($field)
->where($params)
->order($order)
->find();
}
}
......@@ -526,12 +526,16 @@ Route::group('index', [
'getStoreList' => [ 'index/StoreFee/getStoreList', [ 'method' => 'POST|GET' ] ],
'bindStore' => [ 'index/StoreFee/bindStore', [ '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' => 4]], //费用报销审核
'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' => 4]], //费用报销审核
'delCost' => ['index/Cost/delCost', ['method' => 'POST']], //删除费用报销审核
'checkCostTwo/:check_status' => ['index/Cost/checkCost', ['method' => 'POST'], ['check_status' => 1]], //费用报销审核总监
'checkCostThree/:check_status' => ['index/Cost/checkCost', ['method' => 'POST'], ['check_status' => 2]], //费用报销审核一审
'checkCostFour/:check_status' => ['index/Cost/checkCost', ['method' => 'POST'], ['check_status' => 3]], //费用报销审核二审
'checkCostFive/:check_status' => ['index/Cost/checkCost', ['method' => 'POST'], ['check_status' => 4]], //费用报销审核三审
]);
......
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