Commit 7ad93c4f authored by hujun's avatar hujun

费用报销

parent ff605c7a
......@@ -59,7 +59,7 @@ class ApplyForCost extends Basic
case 2 :
$check_url = 'index/checkCostThree/2';
//总监权限查看
//行政权限查看
$where['a.status'] = 5;
$get_check_user = 'index/getCostListTwo/1';
......@@ -182,7 +182,8 @@ class ApplyForCost extends Basic
*
* @return \think\Response
*/
public function costListV2() {
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;
......@@ -198,19 +199,8 @@ class ApplyForCost extends Basic
}
$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'];
}
$where['a.status'] = 0;
break;
case 2 :
$check_url = 'index/checkCostThree/2';
......@@ -222,50 +212,25 @@ class ApplyForCost extends Basic
$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; //财务一审
$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; //财务二审
$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; //财务三审-已出款
$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;
......@@ -275,6 +240,23 @@ class ApplyForCost extends Basic
return $this->response(101, '请求错误');
}
$is_ = $this->checkAuth($get_check_user);
if ($this->params['type'] == 1) {
if ($is_) {
$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[] = ['EXP', 'a.store_id =' . $agent_data['store_id'] . ' or a.payee_agent_id=' . $this->agentId];
}
} else {
if (!$is_) {
$where[] = ['EXP', 'a.store_id =' . $agent_data['store_id'] . ' or a.payee_agent_id=' . $this->agentId];
}
}
$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';
......@@ -286,33 +268,37 @@ class ApplyForCost extends Basic
$list = $fee_model->getJoinAgentList($pageNo, $pageSize, 'a.ID DESC', $field, $where);
$source = [
0=> 'app申请',
1=>'excel导入'
0 => 'APP申请',
1 => 'EXCEL导入',
2 => '后台新增'
];
$data = [];
foreach($list as $v) {
foreach ($list as $v) {
$fee_id[] = $v['id'];
if ($v['store_id'] > 0) {
$store_id[] = $v['store_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]['source_name'] = empty($source[$v['source']]) ? '' : $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'] = [];
$data[$key]['office_name'] = '';
}
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) {
$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'];
......@@ -332,11 +318,21 @@ class ApplyForCost extends Basic
$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) {
$check_field = 'a.remark,a.create_time,b.name as agent_name,apply_for_id';
$check_list = $m_check->findByAll($check_field, ['apply_for_id' => ['in', $fee_id]]);
foreach ($check_list as $v3) {
$key = $v3['apply_for_id'];
$data[$key]['check_list'][] = $v3;
}
//办公室名
if (isset($store_id)) {
$store_id = array_unique($store_id);
$office_name = $m_store->getStoreCostColumn('a.id,b.office_name', ['a.id' => ['in', $store_id]]);
foreach ($data as $k => $v) {
$data[$k]['office_name'] = empty($office_name[$v['store_id']]) ? '' : $office_name[$v['store_id']];
}
}
$data = array_values($data);
}
return $this->response(200, '', $data);
......
......@@ -476,6 +476,23 @@ class AStore extends BaseModel
return $result;
}
/**
* @param $field
* @param $params
* @return array|false|\PDOStatement|string|\think\Model
*/
public function getStoreCostColumn($field,$params)
{
$params["a.status"] = 0;
$result = Db::table($this->table)
->field($field)
->alias('a')
->join('f_office b', 'a.office_id = b.id', 'left')
->where($params)
->column($field);
return $result;
}
/**
* @param $field
* @param $params
......
......@@ -1084,7 +1084,7 @@ Route::group('broker', [
'getOpenList' => ['api_broker/PayLogOpen/getOpenList', ['method' => 'GET|POST']],
'openCheck' => ['api_broker/PayLogOpen/openCheck', ['method' => 'GET|POST']],
'applyForOpen' => ['api_broker/PayLogOpen/applyForOpen', ['method' => 'GET|POST']],
'costList' => ['api_broker/ApplyForCost/costList', ['method' => 'GET']], //费用申请列表
'costList' => ['api_broker/ApplyForCost/costListV2', ['method' => 'GET']], //费用申请列表
'moveHouseAgent' => ['api_broker/User/moveHouseAgent', ['method' => 'GET|POST']],//客方同步到新表
'moveHouseSiteId' => ['api_broker/User/moveHouseSiteId', ['method' => 'GET|POST']],//站点同步到新表
'getFindShopListIsMy' => ['api_broker/FindShop/getFindShopList', ['method' => 'GET']],//委托找铺
......
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