市场结算管理上传

master
zhengyongxing 5 years ago
parent 5e14eaf4c9
commit ba158e6b9a

@ -1813,4 +1813,17 @@ function getAdmin($column = 'uid') {
return session("user_auth")[$column];
}
//获取所有有关的公司
function getCompanyList() {
$sql = "select id,company_name,1 as company_type from tab_promote_company UNION ALL select id,partner,0 as company_type from tab_partner";
$data = M()->table("({$sql}) as a")->select();
return $data;
}
?>

@ -7961,4 +7961,69 @@ class ExportController extends Controller
exit();
}
public function excelUpStreamTemplate() {
header("Content-type: text/html; charset=gb2312");
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
date_default_timezone_set('Europe/London');
Vendor("PHPExcel.PHPExcel");
$objPHPExcel = new \PHPExcel();
$objReader = \PHPExcel_IOFactory::createReader('Excel5');
//设置模板文件
$objPHPExcel = $objReader->load("Runtime/upstream.xls");
$objPHPExcel->getActiveSheet()->setCellValue('D2', 'chengzhi');
$objPHPExcel->getActiveSheet()->insertNewRowBefore(10,1)->mergeCells('J10:K10')->insertNewRowBefore(10,1)->mergeCells('J10:K10');
ob_end_clean();//清除缓冲区,避免乱码
header('pragma:public');
header('Content-type:application/vnd.ms-excel;charset=utf-8;name="15415.xls"');
header("Content-Disposition:attachment;filename=15415.xls");//attachment新窗口打印inline本窗口打印
$objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('php://output');
exit;
}
public function excelDownStreamTemplate() {
header("Content-type: text/html; charset=gb2312");
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
date_default_timezone_set('Europe/London');
Vendor("PHPExcel.PHPExcel");
$objPHPExcel = new \PHPExcel();
$objReader = \PHPExcel_IOFactory::createReader('Excel5');
//设置模板文件
$objPHPExcel = $objReader->load("upstream.xls");
$objPHPExcel->getActiveSheet()->setCellValue('D2', 'chengzhi');
$objPHPExcel->getActiveSheet()->insertNewRowBefore(10,1);
ob_end_clean();//清除缓冲区,避免乱码
header('pragma:public');
header('Content-type:application/vnd.ms-excel;charset=utf-8;name="15415.xls"');
header("Content-Disposition:attachment;filename=15415.xls");//attachment新窗口打印inline本窗口打印
$objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('php://output');
exit;
}
}

@ -1053,30 +1053,36 @@ class QueryController extends ThinkController
//关联表获取会长账号名
$data = M()->table('('.$data.') as a')
->field("my_time,pay_amount,a.game_id,game_name,game_names,a.promote_id,a.promote_account,a.company_relation,a.company_belong,CASE WHEN root_id is null THEN 0 ELSE root_id END as root_id,CASE WHEN account is null THEN '官方渠道' ELSE account END as account,ratio,turnover_ratio")
->field("my_time,pay_amount,a.game_id,game_name,game_names,a.promote_id,a.promote_account,a.company_relation,a.company_belong,CASE WHEN root_id is null THEN 0 ELSE root_id END as root_id,CASE WHEN account is null THEN '官方渠道' ELSE account END as account,tab_ratio.ratio as ratio,turnover_ratio,game_ratio.ratio as games_ratio")
->join("left join tab_promote on root_id = tab_promote.id")
->join("left join tab_promote_game_ratio as tab_ratio on tab_ratio.game_id = a.game_id and tab_ratio.promote_id=root_id")
->join("left join tab_cp_game_ratio as game_ratio on game_ratio.game_id = a.game_id")
->page($page,$row)
->where($map)
->group("my_time,game_names,root_id")
->order("my_time Desc")
->select();
// dump($data);die();
$pagecount = M()->table('('.$count.') as a')->count();
foreach($data as $key => $value) {
$data[$key]['upstream'] = $value['pay_amount'] * 0.2;
if ($value['games_ratio']) {
$data[$key]['upstream'] = $value['pay_amount'] * ($value['games_ratio']*0.01);
} else {
$data[$key]['upstream'] = $value['pay_amount'] * 0;
}
if ($value['ratio']) {
$data[$key]['downstream'] = $value['pay_amount'] * ($value['ratio']*0.01);
} else {
$data[$key]['downstream'] = $value['pay_amount'] * 0.1;
$data[$key]['downstream'] = $value['pay_amount'] * 0;
}
$value['turnover_ratio'] = json_decode($value['turnover_ratio'],true);
// array_push($value['turnover_ratio'],['turnover'=>1006,'ratio'=>30]);
// dump(json_encode($value['turnover_ratio']));die();
if (is_array($value['turnover_ratio'])) {
foreach($value['turnover_ratio'] as $k =>$v) {

Loading…
Cancel
Save