Commit 66c27411 authored by hujun's avatar hujun

方法拆分

parent b24e0d92
......@@ -22,9 +22,16 @@ use app\model\FSettingLog;
use app\model\FStoreCost;
use app\model\FStoreCostExt;
use app\model\FStoreData;
use think\Request;
class Cost extends Basic
{
private $fee_model;
public function __construct(Request $request = null)
{
parent::__construct();
$this->fee_model = new FApplyForFee();
}
/**
* 费用报销列表
*
......@@ -57,88 +64,101 @@ class Cost extends Basic
$data['total'] = $fee_model->getJoinAgentListTotal($where);
return $this->response(200, '', $data);
} else {
$field .= ',a.card_name,a.card_no,a.store_id,a.office_id';
$list = $fee_model->getJoinAgentList(1, 100000, 'a.ID DESC', $field, $where);
$redis = new RedisCacheService();
$source = [
0=> 'app申请',
1=>'excel导入'
];
$status = [
0=>'申请中',
1=>'总监通过',
2=>'一审通过',
3=>'二审通过',
4=>'三审通过',
];
$this->getCostListExcel($field, $where);
}
}
foreach ($list as $k=>$v) {
switch ($v['type']) {
case 5 :
$store_id[] = $v['store_id'];
break;
default :
$office_id[] = $v['office_id'];
break;
}
}
$store_data = $office_data = [];
if (isset($store_id)) {
$store_id = array_filter($store_id);
$store_id = array_unique($store_id);
$m_store = new AStore();
$store_data = $m_store->getColumn('id,store_name', ['id'=>['in', $store_id]]);
}
/**
* 导出数据
*
* @param $field
* @param $where
*/
private function getCostListExcel($field, $where)
{
$field .= ',a.card_name,a.card_no,a.store_id,a.office_id';
$list = $this->fee_model->getJoinAgentList(1, 100000, 'a.ID DESC', $field, $where);
$redis = new RedisCacheService();
$source = [
0 => 'app申请',
1 => 'excel导入'
];
$status = [
0 => '申请中',
1 => '总监通过',
2 => '一审通过',
3 => '二审通过',
4 => '三审通过',
];
if (isset($office_id)) {
$office_id = array_filter($office_id);
$office_id = array_unique($office_id);
$m_office = new FOffice();
$office_data = $m_office->getColumn('id,office_name', ['id'=>['in', $office_id]]);
foreach ($list as $k => $v) {
switch ($v['type']) {
case 5 :
$store_id[] = $v['store_id'];
break;
default :
$office_id[] = $v['office_id'];
break;
}
}
$store_data = $office_data = [];
if (isset($store_id)) {
$store_id = array_filter($store_id);
$store_id = array_unique($store_id);
$m_store = new AStore();
$store_data = $m_store->getColumn('id,store_name', ['id' => ['in', $store_id]]);
}
foreach ($list as $k=>$v) {
$type_name = $cost_service->getFeeType($v['type']);
$fee_item_name = $cost_service->getFeeItem($v['fee_item']);
if ($v['type'] == 3) {
$city_name = $redis->getRedisCache(4, $v['site_id']);
$type_name = $city_name.'-'.$type_name;
}
if (isset($office_id)) {
$office_id = array_filter($office_id);
$office_id = array_unique($office_id);
$m_office = new FOffice();
$office_data = $m_office->getColumn('id,office_name', ['id' => ['in', $office_id]]);
}
$store_name = $office_name = '';
switch ($v['type']) {
case 5 :
$store_name = array_key_exists($v['store_id'], $store_data) ? $store_data[$v['store_id']] : '';
break;
default :
$office_name = array_key_exists($v['office_id'], $office_data) ? $office_data[$v['office_id']] : '';
break;
}
$cost_service = new CostService();
foreach ($list as $k => $v) {
$type_name = $cost_service->getFeeType($v['type']);
$fee_item_name = $cost_service->getFeeItem($v['fee_item']);
if ($v['type'] == 3) {
$city_name = $redis->getRedisCache(4, $v['site_id']);
$type_name = $city_name . '-' . $type_name;
}
$excel_data[$k] = [
'id' => $v['id'],
'count_time' => $v['count_time'],
'create_time' => $v['create_time'],
'agent_name' => $v['agent_name'],
'total_fee' => $v['total_fee'],
'type_name' => $type_name,
'fee_item_name' => $fee_item_name,
'purpose' => $v['purpose'],
'source_name' => $source[$v['source']],
'status' => $status[$v['status']],
'card_name' => $v['card_name'],
'card_no' => "\t" . $v['card_no'],
'store_name' => $store_name,
'office_name' => $office_name
];
$store_name = $office_name = '';
switch ($v['type']) {
case 5 :
$store_name = array_key_exists($v['store_id'], $store_data) ? $store_data[$v['store_id']] : '';
break;
default :
$office_name = array_key_exists($v['office_id'], $office_data) ? $office_data[$v['office_id']] : '';
break;
}
if (isset($excel_data)) {
$export = new ExportExcelUntil();
$title = [ '费用总ID', '计入月份', '提交时间', '提交人', '费用总金额', '费用类型', '费用项目', '费用用途',
'来源','状态','收款卡户名','收款卡账号','费用承担门店','费用承担办公室' ];
$export->exportTable('费用报销审核', $excel_data, 13, '费用报销审核', $title);
}
$excel_data[$k] = [
'id' => $v['id'],
'count_time' => $v['count_time'],
'create_time' => $v['create_time'],
'agent_name' => $v['agent_name'],
'total_fee' => $v['total_fee'],
'type_name' => $type_name,
'fee_item_name' => $fee_item_name,
'purpose' => $v['purpose'],
'source_name' => $source[$v['source']],
'status' => $status[$v['status']],
'card_name' => $v['card_name'],
'card_no' => "\t" . $v['card_no'],
'store_name' => $store_name,
'office_name' => $office_name
];
}
if (isset($excel_data)) {
$export = new ExportExcelUntil();
$title = ['费用总ID', '计入月份', '提交时间', '提交人', '费用总金额', '费用类型', '费用项目', '费用用途',
'来源', '状态', '收款卡户名', '收款卡账号', '费用承担门店', '费用承担办公室'];
$export->exportTable('费用报销审核', $excel_data, 13, '费用报销审核', $title);
}
return ;
}
/**
......
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