Commit 06528a2b authored by hujun's avatar hujun

暂存

parent f635d5e3
...@@ -168,6 +168,171 @@ class ApplyForCost extends Basic ...@@ -168,6 +168,171 @@ class ApplyForCost extends Basic
return $this->response(200, '', $list); return $this->response(200, '', $list);
} }
/**
* 费用申请列表
*
* @return \think\Response
*/
public function costListV2() {
$pageNo = empty($this->params['page_no']) ? 1 : $this->params['page_no'];
$pageSize = empty($this->params['page_size']) ? 15 : $this->params['page_size'];
$where['a.is_del'] = 0;
$redis = new RedisCacheService();
$agent_data = $redis->getRedisCache(2, $this->agentId);
$check_url = '';
$return_type = $this->params['type'];
switch ($this->params['type']) {
case 1 :
if (!empty($this->params['site_id'])) {
$where['a.site_id'] = $this->params['site_id'];
}
$check_url = 'index/checkCostTwo/1';
$where['a.status'] = 0;
$get_check_user = 'index/getCostListOne/0';
$is_check = $this->checkAuth($get_check_user);
if ($is_check) {
$m_agent = new AAgents();
$district_id = $m_agent->getAgentsByWhereColumn(['phone'=>$this->agentPhone], 'district_id');
if ($district_id) {
$where['b.district_id'] = ['in', $district_id]; //总监多个账号查看
}
} else {
$where['a.store_id'] = $agent_data['store_id'];
}
break;
case 2 :
$check_url = 'index/checkCostThree/2';
//总监权限查看
$where['a.status'] = 5;
$get_check_user = 'index/getCostListTwo/1';
$is_check = $this->checkAuth($get_check_user);
if (!$is_check) {
$get_check_user = 'index/getCostListOne/0';
$is_check = $this->checkAuth($get_check_user);
if ($is_check) {
$m_agent = new AAgents();
$district_id = $m_agent->getAgentsByWhereColumn(['phone'=>$this->agentPhone], 'district_id');
if ($district_id) {
$district_id[] = $agent_data['district_id'];
$where['b.district_id'] = ['in', $district_id]; //总监多个账号查看
}
} else {
$where['a.store_id'] = $agent_data['store_id']; //店长查看
}
}
//财务一审查看
break;
case 3 :
$get_check_user = 'index/getCostListThree/2';
$is_check = $this->checkAuth($get_check_user);
if (!$is_check) {
$where['a.store_id'] = $agent_data['store_id'];
}
$check_url = 'index/checkCostFour/3';
$where['a.status'] = 2;break; //财务一审
case 4 :
$get_check_user = 'index/getCostListFour/3';
$is_check = $this->checkAuth($get_check_user);
if (!$is_check) {
$where['a.store_id'] = $agent_data['store_id'];
}
$check_url = 'index/checkCostFive/4';
$where['a.status'] = 3;break; //财务二审
case 5 :
$get_check_user = 'index/getCostListFive/4';
$is_check = $this->checkAuth($get_check_user);
if (!$is_check) {
$where['a.store_id'] = $agent_data['store_id'];
}
$where['a.status'] = 4;break; //财务三审-已出款
case 6 :
$get_check_user = 'index/getCostListSix/5';
$is_check = $this->checkAuth($get_check_user);
if (!$is_check) {
$where['a.store_id'] = $agent_data['store_id'];
}
$return_type = 5;
$where['a.site_id'] = $this->siteId;
$where['a.status'] = 1;
$check_url = 'index/checkCostSix/5';
break; //行政审核
default :
return $this->response(101, '请求错误');
}
$is_check = $this->checkAuth($check_url); //审核通过权限
$field = 'a.id,a.count_time,a.source,a.type,a.create_time,a.agent_id,a.total_fee,a.fee_item,a.purpose,';
$field .= 'b.name as agent_name,a.card_name,a.bank,a.card_no,a.source,a.store_id,a.status';
$fee_model = new FApplyForFee();
$cost_service = new CostService();
$m_img = new FImg();
$m_check = new FApplyForFeeCheck();
$m_store = new AStore();
$list = $fee_model->getJoinAgentList($pageNo, $pageSize, 'a.ID DESC', $field, $where);
$source = [
0=> 'app申请',
1=>'excel导入'
];
$data = [];
foreach($list as $v) {
$fee_id[] = $v['id'];
$key = $v['id'];
$data[$key] = $v;
$data[$key]['type_name'] = $cost_service->getFeeType($v['type']);
$data[$key]['fee_item_name'] = $cost_service->getFeeType($v['fee_item']);
$office_name = $m_store->getStoreCost('b.office_name', ['a.id'=>$v['store_id']]);
$data[$key]['office_name'] = empty($office_name['office_name']) ? '':$office_name['office_name'];
$data[$key]['source_name'] = $source[$v['source']];
$data[$key]['image_base_url'] = 'static/chat_image/';
$data[$key]['return_type'] = $return_type;
if ($v['status'] > 0 && $this->params['type'] == 1) {
$is_check = 0; //已审核去除
}
$data[$key]['is_check'] = $is_check;
$data[$key]['check_image_array'] = $data[$key]['image_array'] = $data[$key]['check_image_array'] = $data[$key]['check_list'] = [];
}
if (isset($fee_id)) {
$img_where['img_id'] = ['in', $fee_id];
$img_where['img_type'] = ['in', '1,2'];
$images_array = $image_data = $m_img->findByAll('id,img_name,img_type,img_id', $img_where);
foreach($images_array as $v2) {
$image_array = $check_image_array = [];
$key = $v2['img_id'];
if ($v2['img_type'] == 1) {
$image_array[] = [
'id' => $v2['id'],
'img_name' => $v2['img_name']
];
} else {
$check_image_array[] = [
'id' => $v2['id'],
'img_name' => $v2['img_name']
];
}
$data[$key]['image_array'] = $image_array;
$data[$key]['check_image_array'] = $check_image_array;
}
$check_list = $m_check->findByAll('a.remark,a.create_time,b.name as agent_name,apply_for_id',['apply_for_id'=>['in', $fee_id]]);
foreach($check_list as $v3) {
$key = $v3['apply_for_id'];
$data[$key]['check_list'][] = $v3;
}
$data = array_values($data);
}
return $this->response(200, '', $data);
}
/** /**
* 审核 * 审核
* *
......
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