财务代码搬到新的分支上

master
zhengyongxing 4 years ago
parent 341fa19b6f
commit 1fff2e6c09

@ -101,133 +101,184 @@ class AggregateFinanceSetController extends Controller {
$this->getAndSaveData(2,$begintime,$endtime);
}
protected function getAndSaveData($type,$begintime,$endtime)
{
$sign = md5($begintime.$endtime.$type.$this->token);
$arr = [
"begintime"=>$begintime,
"endtime"=>$endtime,
"type"=>$type,
"sign"=>$sign
];
$dataurl .= $this->apihost."&".http_build_query($arr);
$html = file_get_contents($dataurl);
$rsp = json_decode($html,true);
if($rsp['code'] != 1){
echo $rsp['error'].PHP_EOL;die;
}
//成功插入
$Aggregate = M("aggregate_statement","tab_");
$begintimestr = date("Y-m-d",$begintime);
$endtimestr = date("Y-m-d",$endtime);
if($rsp['count'] > 0){
//插入数据
foreach ($rsp['data'] as $k => $v) {
foreach ($v["game_list"] as $ke => &$va) {
$va['begintime'] = $begintimestr;
$va['endtime'] = $endtimestr;
$va['fax_ratio'] = 0;
}
$v["statement_info"] = json_encode($v["game_list"],JSON_UNESCAPED_UNICODE);
unset($v["game_list"]);
$v['begintime'] = $begintime;
$v['endtime'] = $endtime;
$v['create_time'] = time();
$v['admin_name'] = "system";
$v['admin_id'] = 0;
$v['second_party_info'] = json_encode([
"partner"=>$v['channel_name']
],JSON_UNESCAPED_UNICODE);
$Aggregate->add($v);
}
}
if($type == 0){
echo "----周结统计ok".PHP_EOL;
}elseif($type == 1){
echo "----月结统计ok".PHP_EOL;
}elseif($type == 2){
echo "----补点统计ok".PHP_EOL;
}
}
protected function getAndSaveData($type,$begintime,$endtime)
{
$sign = md5($begintime.$endtime.$type.$this->token);
$arr = [
"begintime"=>$begintime,
"endtime"=>$endtime,
"type"=>$type,
"sign"=>$sign
];
$dataurl .= $this->apihost."&".http_build_query($arr);
$html = file_get_contents($dataurl);
// echo $dataurl;die();
sleep(5);
$rsp = json_decode($html,true);
if($rsp['code'] != 1){
echo $rsp['error'].PHP_EOL;die;
}
//成功插入
$Aggregate = M("aggregate_statement","tab_");
$begintimestr = date("Y-m-d",$begintime);
$endtimestr = date("Y-m-d",$endtime);
if($rsp['count'] > 0){
//插入数据
foreach ($rsp['data'] as $k => $v) {
foreach ($v["game_list"] as $ke => &$va) {
$va['begintime'] = $begintimestr;
$va['endtime'] = $endtimestr;
$va['fax_ratio'] = 0;
}
$v["statement_info"] = json_encode($v["game_list"],JSON_UNESCAPED_UNICODE);
unset($v["game_list"]);
$v['begintime'] = $begintime;
$v['endtime'] = $endtime;
$v['create_time'] = time();
$v['admin_name'] = "system";
$v['admin_id'] = 0;
$v['second_party_info'] =
json_encode([
"partner"=>$v['channel_name'],
"invoice_type"=>$v['invoice_type'],
"invoice_item"=>$v['invoice_item'],
"company_tax_no"=>$v['tax_identification_number'],
"link_man"=>$v['connection_person'],
"link_phone"=>$v['phone'],
"address"=>$v['send_address'],
"register_address"=>$v['register_address'],
"register_phone"=>$v['register_phone'],
"payee_name"=>$v['bank_user'],
"bank_account"=>$v['bank_card'],
"opening_bank"=>$v['bank_name'],
],JSON_UNESCAPED_UNICODE);
$Aggregate->add($v);
}
}
if($type == 0){
echo "----周结统计ok".PHP_EOL;
}elseif($type == 1){
echo "----月结统计ok".PHP_EOL;
}elseif($type == 2){
echo "----补点统计ok".PHP_EOL;
}
}
/**
* 重算聚合接口数据
* @param [type] $id
* @return void
*/
public function updateAggregateFinanceData($id)
{
//获取基础信息
$Aggregate = M("aggregate_statement","tab_");
$info = $Aggregate->where("id='{$id}'")->find();
$sign = md5($info['begintime'].$info['endtime'].$info['withdraw_type'].$this->token);
$arr = [
"begintime"=>$info['begintime'],
"endtime"=>$info['endtime'],
"type"=>$info['withdraw_type'],
"sign"=>$sign,
"channel_id"=>$info['channel_id']
];
$dataurl .= $this->apihost."&".http_build_query($arr);
$html = file_get_contents($dataurl);
$rsp = json_decode($html,true);
if($rsp['code'] != 1){
echo $rsp['error'].PHP_EOL;die;
}
//更新信息
$begintimestr = date("Y-m-d",$info['begintime']);
$endtimestr = date("Y-m-d",$info['endtime']);
if($rsp['count'] > 0){
//插入数据
foreach ($rsp['data'] as $k => $v) {
foreach ($v["game_list"] as $ke => &$va) {
$va['begintime'] = $begintimestr;
$va['endtime'] = $endtimestr;
$va['fax_ratio'] = 0;
}
$v["statement_info"] = json_encode($v["game_list"],JSON_UNESCAPED_UNICODE);
unset($v["game_list"]);
$v['create_time'] = time();
$v['admin_name'] = $_SESSION['onethink_admin']['user_auth']['username'];
$v['admin_id'] = $_SESSION['onethink_admin']['user_auth']['uid'];
$v['verify_status'] = 0;
$first_party_info = json_decode($info['first_party_info'], 1);
if($first_party_info['partner'] == $info['channel_name']){
$v['second_party_info'] = $info['first_party_info'];
$v['first_party_info'] = $info['second_party_info'];
$v['pay_type'] =0;
}
$res = $Aggregate->where("id='{$id}'")->save($v);
if(empty($res)){
return false;
}
}
}else{
$savedata = [
"create_time"=>time(),
"admin_name"=>$_SESSION['onethink_admin']['user_auth']['username'],
"admin_id"=>$_SESSION['onethink_admin']['user_auth']['uid'],
"verify_status"=>0,
"statement_info"=>json_encode([],JSON_UNESCAPED_UNICODE),
"ratio_money"=>0,
"pay_money"=>0
];
$first_party_info = json_decode($info['first_party_info'], 1);
if($first_party_info['partner'] == $info['channel_name']){
$savedata['second_party_info'] = $info['first_party_info'];
$savedata['first_party_info'] = $info['second_party_info'];
$savedata['pay_type'] =0;
}
public function updateAggregateFinanceData($id)
{
//获取基础信息
$Aggregate = M("aggregate_statement","tab_");
$info = $Aggregate->where("id='{$id}'")->find();
$sign = md5($info['begintime'].$info['endtime'].$info['withdraw_type'].$this->token);
$arr = [
"begintime"=>$info['begintime'],
"endtime"=>$info['endtime'],
"type"=>$info['withdraw_type'],
"sign"=>$sign,
"channel_id"=>$info['channel_id']
];
$dataurl .= $this->apihost."&".http_build_query($arr);
$html = file_get_contents($dataurl);
$rsp = json_decode($html,true);
if($rsp['code'] != 1){
echo $rsp['error'].PHP_EOL;die;
}
//更新信息
$begintimestr = date("Y-m-d",$info['begintime']);
$endtimestr = date("Y-m-d",$info['endtime']);
$res = $Aggregate->where("id='{$id}'")->save($savedata);
if(empty($res)){
return false;
}
}
return true;
}
if($rsp['count'] > 0){
//插入数据
foreach ($rsp['data'] as $k => $v) {
foreach ($v["game_list"] as $ke => &$va) {
$va['begintime'] = $begintimestr;
$va['endtime'] = $endtimestr;
$va['fax_ratio'] = 0;
}
$v["statement_info"] = json_encode($v["game_list"],JSON_UNESCAPED_UNICODE);
unset($v["game_list"]);
$v['create_time'] = time();
$v['admin_name'] = $_SESSION['onethink_admin']['user_auth']['username'];
$v['admin_id'] = $_SESSION['onethink_admin']['user_auth']['uid'];
$v['verify_status'] = 0;
// $first_party_info = json_decode($info['first_party_info'], 1);
// if($first_party_info['partner'] == $info['channel_name']){
$v['second_party_info'] =
json_encode([
"partner"=>$v['channel_name'],
"invoice_type"=>$v['invoice_type'],
"invoice_item"=>$v['invoice_item'],
"company_tax_no"=>$v['tax_identification_number'],
"link_man"=>$v['connection_person'],
"link_phone"=>$v['phone'],
"address"=>$v['send_address'],
"register_address"=>$v['register_address'],
"register_phone"=>$v['register_phone'],
"payee_name"=>$v['bank_user'],
"bank_account"=>$v['bank_card'],
"opening_bank"=>$v['bank_name'],
],JSON_UNESCAPED_UNICODE);
$v['first_party_info'] = '';
$v['pay_type'] =0;
// } else {
// $v['second_party_info'] =
// json_encode([
// "partner"=>$v['channel_name'],
// "invoice_type"=>$v['invoice_type'],
// "invoice_item"=>$v['invoice_item'],
// "company_tax_no"=>$v['tax_identification_number'],
// "link_man"=>$v['connection_person'],
// "link_phone"=>$v['phone'],
// "address"=>$v['send_address'],
// "register_address"=>$v['register_address'],
// "register_phone"=>$v['register_phone'],
// "payee_name"=>$v['bank_user'],
// "bank_account"=>$v['bank_card'],
// "opening_bank"=>$v['bank_name'],
// ],JSON_UNESCAPED_UNICODE);
//
// $v['pay_type'] =1;
// }
$res = $Aggregate->where("id='{$id}'")->save($v);
if(empty($res)){
return false;
}
}
}else{
$savedata = [
"create_time"=>time(),
"admin_name"=>$_SESSION['onethink_admin']['user_auth']['username'],
"admin_id"=>$_SESSION['onethink_admin']['user_auth']['uid'],
"verify_status"=>0,
"statement_info"=>json_encode([],JSON_UNESCAPED_UNICODE),
"ratio_money"=>0,
"pay_money"=>0
];
$first_party_info = json_decode($info['first_party_info'], 1);
if($first_party_info['partner'] == $info['channel_name']){
$savedata['second_party_info'] = $info['first_party_info'];
$savedata['first_party_info'] = $info['second_party_info'];
$savedata['pay_type'] =0;
}
$res = $Aggregate->where("id='{$id}'")->save($savedata);
if(empty($res)){
return false;
}
}
return true;
}
}

@ -532,9 +532,9 @@ class AggregateFinanceStatementController extends ThinkController
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('Asia/Shanghai');
Vendor("PHPExcel.PHPExcel");
$objPHPExcel = new \PHPExcel();
@ -543,7 +543,7 @@ class AggregateFinanceStatementController extends ThinkController
$objPHPExcel = $objReader->load("Public/Admin/excel/aggregate_stream.xls");
$statement_begin_time = date('Y.m.d', $data['begintime']);//对账开始时间
$statement_end_time = date('Y.m.d',$data['endtime']);//对账截止时间
$objPHPExcel->getActiveSheet()->getStyle('A1')->getAlignment()->setWrapText(true);
$objPHPExcel->getActiveSheet()->setCellValue('A1', "《 {$data['channel_name']} 》结算单\n{$statement_begin_time}-{$statement_end_time}");
if ($data['withdraw_type'] == '2') {
@ -576,17 +576,33 @@ class AggregateFinanceStatementController extends ThinkController
$objPHPExcel->getActiveSheet()->setCellValue('B'.($line+3), $data['first_party_info']['partner']);//甲方
$objPHPExcel->getActiveSheet()->setCellValue('B'.($line+4), $data['first_party_info']['link_man']);//联系人
$objPHPExcel->getActiveSheet()->setCellValue('B'.($line+5), $data['first_party_info']['link_phone']);//联系电话
$objPHPExcel->getActiveSheet()->setCellValue('B'.($line+6), $data['second_party_info']['invoice_item']);//开票项目
$objPHPExcel->getActiveSheet()->setCellValue('B'.($line+7), $data['second_party_info']['invoice_type']);//发票类型
$objPHPExcel->getActiveSheet()->setCellValue('B'.($line+6), $data['first_party_info']['address']);//邮寄地址
// $objPHPExcel->getActiveSheet()->setCellValue('B'.($line+7), $data['second_party_info']['invoice_type']);//发票类型
//乙方信息
$objPHPExcel->getActiveSheet()->setCellValue('E'.($line+3), $data['second_party_info']['partner']);//乙方
$objPHPExcel->getActiveSheet()->setCellValue('E'.($line+4), $data['second_party_info']['link_man']);//联系人
$objPHPExcel->getActiveSheet()->setCellValue('E'.($line+5), $data['second_party_info']['link_phone']);//联系电话
$objPHPExcel->getActiveSheet()->setCellValue('E'.($line+6), $data['second_party_info']['address']);//邮寄地址
$objPHPExcel->getActiveSheet()->setCellValue('E'.($line+8), $data['pay_company']['payee_name']);//户名
$objPHPExcel->getActiveSheet()->setCellValue('E'.($line+9), $data['pay_company']['bank_account']);//银行账号
$objPHPExcel->getActiveSheet()->setCellValue('E'.($line+10), $data['pay_company']['opening_bank']);//开户行
//开票信息
$invoice_data = "发票类型:".$data['second_party_info']['invoice_type'];
$invoice_data .= "\n发票抬头".$data['second_party_info']['partner'];
$invoice_data .= "\n纳税人识别号".$data['second_party_info']['company_tax_no'];
$invoice_data .= "\n开户银行".$data['second_party_info']['opening_bank'];
$invoice_data .= "\n开户账号".$data['second_party_info']['payee_name'];
$invoice_data .= "\n开票内容".$data['second_party_info']['invoice_item'];
$invoice_data .= "\n注册地址及电话".$data['second_party_info']['register_address'].",".$data['second_party_info']['register_phone'];
$objPHPExcel->getActiveSheet()->setCellValue('B'.($line+7), $invoice_data);//乙方
$first_data = "户名:{$data['pay_company']['payee_name']}";
$first_data .= "\n账号{$data['pay_company']['bank_account']}";
$first_data .= "\n开户行{$data['pay_company']['opening_bank']}";
$objPHPExcel->getActiveSheet()->setCellValue('B'.($line+8), $first_data);//户名
// $objPHPExcel->getActiveSheet()->setCellValue('E'.($line+8), $data['pay_company']['payee_name']);//户名
// $objPHPExcel->getActiveSheet()->setCellValue('E'.($line+9), $data['pay_company']['bank_account']);//银行账号
// $objPHPExcel->getActiveSheet()->setCellValue('E'.($line+10), $data['pay_company']['opening_bank']);//开户行
if($data['withdraw_type'] == 1){
$m = date('Y.m', $data['begintime']);
$fileName = "{$data['second_party_info']['partner']}&{$data['first_party_info']['partner']}-对账单{$m}";
@ -598,7 +614,7 @@ class AggregateFinanceStatementController extends ThinkController
header('Content-type:application/vnd.ms-excel;charset=utf-8;name="' . $fileName .'".xls');
header("Content-Disposition:attachment;filename={$fileName}.xls");//attachment新窗口打印inline本窗口打印
$objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('php://output');
$objWriter->save('php://output');
}
//获取权限
public function getAuth()

@ -442,9 +442,9 @@ class PromoteModel extends Model{
if(!$show_data_power){
$parseData[$key]['account'] = encryptStr($parseData[$key]['account']);
// $parseData[$key]['account'] = encryptStr($parseData[$key]['account']);
$parseData[$key]['mobile_phone'] = encryptStr($parseData[$key]['mobile_phone']);
$parseData[$key]['top_account'] = encryptStr($parseData[$key]['top_account']);
// $parseData[$key]['top_account'] = encryptStr($parseData[$key]['top_account']);
}

Loading…
Cancel
Save