Merge branch 'feature/trippest'

hotfix/远程访问多媒体中心
lyt 6 years ago
commit 1dd1d4b1d6

@ -252,6 +252,126 @@ class Vendor_money extends CI_Controller {
$objWriter->save('php://output'); $objWriter->save('php://output');
} }
public function report_precheck()
{
$data = array();
$data['default_date1'] = date('Y-m-01', strtotime("last month"));
$data['default_date2'] = date('Y-m-d H:i:s', mktime(0,0,0,date('m'),1,date('Y'))-1);
$vendor_sourcetype = $this->trippest->vendor_sourcetype();
$data['default_vendor'] = array_keys($vendor_sourcetype);
$this->load->view('order_report_precheck', $data);
}
public function precheck()
{
$this->permission->is_admin(true);
$ret = array();
$date_range = $this->input->post("date_range");
preg_match_all('/\d{4}\-\d{2}\-\d{2}/', $date_range, $date_range_arr);
if (empty($date_range_arr[0])) {
return $this->settlement();
}
$start_date = $date_range_arr[0][0];
$end_date =$date_range_arr[0][1] . " 23:59:59";
if ($end_date == null) {
$end_date = date("Y-m-d H:i:s", strtotime("+1 month", strtotime($start_date))-1);
}
$ret['default_date1'] = $start_date;
$ret['default_date2'] = $end_date;
$vendors = $this->input->post("vendors");
$ret['default_vendor'] = $vendors;
$vendor_sourcetype = $this->trippest->vendor_sourcetype();
// price [Trippest receipts & agency receipts]
$ret['price_error'] = $this->money_model->get_precheck_price_error($start_date, $end_date, implode(',' ,$vendors));
// cost
$HT_combine_cost = $this->money_model->get_combine_cost($start_date, $end_date, implode(',' ,$vendors));
$cost_error = array();
$ht_no_match = array();
$xls_no_match = array();
// $config['upload_path'] = FCPATH.'download_statement\temp_files';
$config['upload_path'] = 'download_statement/temp_files';
// $config['file_name'] = "1.xls";
$config['encrypt_name'] = true;
if ( ! is_dir($config['upload_path'])) {
mkdir($config['upload_path'], 0777, true);
}
$config['allowed_types'] = 'xls|xlsx';
$config['max_size'] = 0;
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload('upload_cost'))
{
$ret['error_msg'] = $this->upload->display_errors();
}
else
{
$upload_data = array('upload_data' => $this->upload->data());
$read_path = $upload_data['upload_data']['full_path'];
$xls_data=array();
$this->load->library('PHPExcel');
$PHPExcel = new PHPExcel();
/**默认用excel2007读取excel若格式不对则用之前的版本进行读取*/
$PHPReader = new PHPExcel_Reader_Excel2007();
if(!$PHPReader->canRead($read_path)){
$PHPReader = new PHPExcel_Reader_Excel5();
if(!$PHPReader->canRead($read_path)){
echo 'no Excel';
return ;
}
}
$PHPExcel = $PHPReader->load($read_path);
/**读取excel文件中的第一个工作表*/
$currentSheet = $PHPExcel->getSheet(0);
/**取得最大的列号*/
// $allColumn = $currentSheet->getHighestColumn();
$allColumn = 'B';
/**取得一共有多少行*/
$allRow = $currentSheet->getHighestRow();
$col_titles = array('A' => 'group_name', 'B' => 'group_cost');
/**从第3行开始输出因为excel表中第一行为列名*/
for($currentRow = 3;$currentRow <= $allRow;$currentRow++){
$row_tmp = array();
/**从第A列开始输出*/
for($currentColumn= 'A';$currentColumn<= $allColumn; $currentColumn++){
/**ord()将字符转为十进制数*/
$val = $currentSheet->getCellByColumnAndRow(ord($currentColumn) - 65,$currentRow)->getValue();
$col_mean = $col_titles[$currentColumn];
$row_tmp[$col_mean] = $val;
}
if (isset($row_tmp['group_name']) && !empty($row_tmp['group_name'])) {
$xls_data[] = $row_tmp;
}
}
$all_xls_group_name = array_column($xls_data, 'group_name');
$all_ht_group_no = array_column($HT_combine_cost, 'GCI_combineNo');
$not_in_ht = array_diff($all_xls_group_name, $all_ht_group_no);
$not_in_xls = array_diff($all_ht_group_no, $all_xls_group_name);
foreach ($HT_combine_cost as $kht => $ht_cost) {
if (in_array($ht_cost['GCI_combineNo'], $not_in_xls)
&& !in_array(strtolower($ht_cost['GCI_combineNo']),array('cancel', 'forbidden'))
) {
$ht_no_match[] = $ht_cost;
}
foreach ($xls_data as $kxls => $xls_cost) {
if ($xls_cost['group_name'] == $ht_cost['GCI_combineNo']
&& strval($ht_cost['cost']) != strval($xls_cost['group_cost'])
) {
$cost_error[] = array_merge($ht_cost, $xls_cost);
}
}
}
foreach ($xls_data as $kxls => $xls_cost) {
if (in_array($xls_cost['group_name'], $not_in_ht)) {
$xls_no_match[] = $xls_cost;
}
}
unlink($upload_data['upload_data']['full_path']);
}
$ret['cost_error'] = $cost_error;
$ret['ht_no_match'] = $ht_no_match;
$ret['xls_no_match'] = $xls_no_match;
return $this->load->view('order_report_precheck', $ret);
}
} }
/* End of file vendor_money.php */ /* End of file vendor_money.php */

@ -326,6 +326,113 @@ class Vendor_money_model extends CI_Model {
return $query->result_array(); return $query->result_array();
} }
public function get_combine_cost($start_date, $end_date, $all_vendor)
{
$sql = "SELECT group_cost.GCI_VEI_SN vendor_code,GCI_combineNo,
(SELECT isnull(SUM(CONVERT(float, isnull(gcod.GCOD_sumMoney,0))),0)
FROM GroupCombineOperationDetail gcod
WHERE gcod.GCOD_GCI_combineNo=GCI_combineNo
AND gcod.GCOD_operationType<> 'otherReceives'
) AS cost
FROM
(SELECT DISTINCT isnull(gci.GCI_combineNo,'1') GCI_combineNo,
GCI_VEI_SN
FROM GroupCombineInfo gci
WHERE 1=1
AND GCI_VEI_SN IN ($all_vendor)
AND EXISTS
( SELECT 1
FROM CK_GroupInfo
WHERE CGI_Checked=1
AND CGI_GRI_SN=GCI_GRI_SN
AND CGI_ArriveDate BETWEEN '$start_date' AND '$end_date')
) AS group_cost
order by GCI_combineNo desc";
$query = $this->HT->query($sql);
return $query->result_array();
}
public function get_precheck_price_error($start_date, $end_date, $all_vendor)
{
$sql = "SELECT
data_tmp.TLD_total_price-(HT_haina_receipt+HT_agency_receipt) as 'total_price_err', --总团款差额 (账单减HT)',
case data_tmp.COLI_OPI_ID when 435
then data_tmp.TLD_total_price-HT_agency_receipt
else data_tmp.TLD_agency_receipt-HT_agency_receipt
end as 'agency_receipt_err', --地接代收差额 (账单减HT)',
case data_tmp.COLI_OPI_ID when 435
then TLD_total_price-HT_agency_receipt
else TLD_total_price-TLD_agency_receipt-HT_haina_receipt
end as 'HT_receipt_err' --海纳收差额 (账单减HT)'
,(select top 1 GCI_combineNo from groupcombineinfo where gci_gri_sn=data_tmp.GRI_SN) as combineNo
,* from
(
select
gri.GRI_Name,
(select isnull(SUM(cast(GCI_priceCNY as decimal(10,2))),0) from GroupCombineInfo where GCI_GRI_SN=COLI_GRI_SN) as TLD_total_price,
(select isnull(SUM(cast(GCI_agencyReceipt as decimal(10,2))),0) from GroupCombineInfo where GCI_GRI_SN=COLI_GRI_SN) as TLD_agency_receipt,
(select isnull(SUM(cast(GAI_SSJE as decimal(10,2))),0) from BIZ_GroupAccountInfo where GAI_COLI_SN=COLI_SN
and GAI_Type in (" . PAY_OTHER . ")
and GAI_VEI_SN in ($all_vendor)
and DeleteFlag=0
) as HT_agency_receipt,
(select isnull(SUM(cast(GAI_SSJE as decimal(10,2))),0) from BIZ_GroupAccountInfo where GAI_COLI_SN=COLI_SN
and GAI_Type not in (" . PAY_OTHER . ")
and DeleteFlag=0
--and isnull(GAI_VEI_SN,0) in (0,)
) as HT_haina_receipt,
(select isnull(SUM(tourcost),0) from report_tour
inner join BIZ_ConfirmLineDetail on COLD_SN=RPT_COLD_SN and COLD_PlanVEI_SN in ($all_vendor)
where ordernumber=COLI_ID ) AS cost
,coli.COLI_OPI_ID
,gri.GRI_SN
--,*
from
--CK_GroupInfo cgi inner join
GRoupInfo gri --on CGI_GRI_SN=GRI_SN
inner join BIZ_ConfirmLineInfo coli on COLI_GRI_SN=GRI_SN
inner join report_order ro on ro.ordernumber=COLI_ID
where 1=1
--and CGI_ArriveDate BETWEEN '$start_date' and '$end_date'
and exists (
select 1 from OperatorInfo where OPI_DEI_SN=30 and OPI_SN=COLI_OPI_ID
)
and ro.orderstats=1
and GRI_OrderType=227002
and exists (
select 1 from BIZ_ConfirmLineDetail where COLD_COLI_SN=coli.COLI_SN
and DeleteFlag=0
and COLD_PlanVEI_SN in ($all_vendor)
and COLD_StartDate BETWEEN '$start_date' and '$end_date'
)
) as data_tmp
where 1=1
-- 总团款不相等
and data_tmp.TLD_total_price-(HT_haina_receipt+HT_agency_receipt)<>0
-- 地接代收不相等:同步
OR (
data_tmp.COLI_OPI_ID=435 and HT_haina_receipt<>0 and TLD_agency_receipt<>0
and data_tmp.TLD_total_price-HT_agency_receipt<>0
)
-- 地接代收不相等:自营
OR (
data_tmp.COLI_OPI_ID<>435 --and HT_haina_receipt<>0 and TLD_agency_receipt<>0
and data_tmp.TLD_agency_receipt-HT_agency_receipt<>0
)
-- 海纳收不相等:同步
OR (
data_tmp.COLI_OPI_ID=435
and (HT_haina_receipt<>0 or TLD_total_price-HT_agency_receipt<>0)
)
-- 海纳收不相等:自营
OR (
data_tmp.COLI_OPI_ID<>435
and TLD_total_price-TLD_agency_receipt-HT_haina_receipt<>0
)";
$query = $this->HT->query($sql);
return $query->result_array();
}
} }
/* End of file vendor_money.php */ /* End of file vendor_money.php */

@ -0,0 +1,197 @@
<?php
/**
* 账单结算
*/
?>
<!DOCTYPE html>
<html>
<head>
<title>Trippest &amp; 地接账单预审核</title>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta content="width=device-width, initial-scale=1.0, user-scalable=no" name="viewport">
<meta content="yes" name="apple-mobile-web-app-capable">
<meta name="referrer" content="always">
<link href="http://www.mycht.cn/css/webht/bootstrap.min.css" rel="stylesheet" type="text/css" />
<link href="http://www.mycht.cn/css/bootstrap-datetimepicker.min.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css">
<!-- <?php // include 'flatpickr.css.php'; ?> -->
<style type="text/css">
form{border-bottom: 1px solid #ccc;}
.navbar-header h1{display: inline-block;margin-left: 30px;margin-right: 30px;}
label {display: inline-block;max-width: none;margin-bottom: 5px;font-weight: bold; }
.form-check-label{font-weight: normal; margin-left: 5px;}
thead th {text-align: center;}
tbody td {text-align: right;}
.bg-grey {background-color: #f5f5f5;}
.text-left {text-align: left;}
.text-right {text-align: right;}
.text-bold {font-weight: bold;}
.text-red {color: red;}
.cell-right {float: right;}
td a {cursor: pointer;}
</style>
</head>
<body>
<div id="wrapper" class="chkVisible print-none">
<div class="navbar-header" style="float:none;border-bottom: 1px solid #ccc;">
<a class="navbar-brand text-muted" style="height: 52px;padding-top: 7px;padding-left: 30px;" href="http://www.mycht.cn/webht.php/index/index">
<img width="150" style="height:40px;" src="/css/nav/img/6000.png">
</a>
<h1>Trippest &amp; 地接账单预审核</h1>
<ul class="nav navbar-nav navbar-right pull-right" style="margin:7.5px 0;">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><?php $userdata=$this->session->userdata('admin_chtcdn'); echo $userdata['OPI_Name']; ?> <span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li><a href="<?php echo site_url('login/logout'); ?>">退出</a></li>
</ul>
</li>
</ul>
</div>
</div>
<div class="container-fluid">
<p></p>
<form action="/webht.php/apps/trippestordersync/vendor_money/precheck" method="POST" role="form" id="request_form" name="request_form" enctype="multipart/form-data">
<div class="form-group row">
<label for="" class="col-md-2">地接社</label>
<div class="">
<label class="form-check-label"><input type="checkbox" class="" name="vendors[]" id="" value="1343" <?php if(in_array(1343, $default_vendor)) { ?>checked<?php } ?> >北京图兰朵</label>
<label class="form-check-label"><input type="checkbox" class="" name="vendors[]" id="" value="29188" <?php if(in_array(29188, $default_vendor)) { ?>checked<?php } ?>>上海图兰朵</label>
<label class="form-check-label"><input type="checkbox" class="" name="vendors[]" id="" value="30548" <?php if(in_array(30548, $default_vendor)) { ?>checked<?php } ?>>西安图兰朵</label>
<!-- <label class="form-check-label"><input type="checkbox" class="" name="vendors[]" id="" value="628">桂林地接</label> -->
</div>
</div>
<div class="form-group row">
<!-- <label for="" class="col-md-2">发团日期</label> -->
<div class="col-md-6">
<input type="text" class="form-control" name="date_range" id="date_range" placeholder="选择日期范围" required>
</div>
<div class="col-md-6">
<input type="file" class="form-control" name="upload_cost" id="upload_cost" placeholder="上传成本文件" >
</div>
<div class="">
<!-- <input type="text" class="form-control" id="end_date" placeholder="结束日期"> -->
<button type="submit" class="btn btn-primary">开始预审</button>
<span>(&nbsp;务必上传与所选&nbsp;[&nbsp;发团日期&nbsp;,地接社&nbsp;]相对应的成本文件.&nbsp;)</span>
</div>
</div>
</form>
<p></p>
<table class="table table-bordered table-hover">
<thead>
<tr>
<th colspan="9" class="text-left">团款异常:</th>
</tr>
<tr>
<th>HT团号</th>
<th>拼团号</th>
<th class="text-left">
总团款差额
<p>=&nbsp;账单总团款&nbsp;-&nbsp;(&nbsp;HT收款&nbsp;+&nbsp;HT代收&nbsp;)</p>
</th>
<th class="text-left">
地接代收差额
<p>=&nbsp;账单代收&nbsp;-&nbsp;HT代收</p>
</th>
<th class="text-left">
海纳收差额
<p>=&nbsp;账单收款&nbsp;-&nbsp;HT收款</p>
</th>
<th>账单:总团款</th>
<th>账单:地接代收</th>
<th>HT:海纳收款</th>
<th>HT:地接代收</th>
</tr>
</thead>
<tbody>
<?php if ( ! empty($price_error)) {
foreach ($price_error as $ko => $ep) { ?>
<tr>
<td class="text-left"><?php echo $ep['GRI_Name']; ?></td>
<td class="text-left"><?php echo $ep['combineNo']; ?></td>
<td>
<?php echo $ep['total_price_err']; ?>
<!-- <p><?php // echo "=" . $ep['TLD_total_price'] . "-(" . $ep['HT_haina_receipt'] . "+" . $ep['HT_agency_receipt'] . ")"; ?></p> -->
</td>
<td><?php echo $ep['agency_receipt_err']; ?></td>
<td><?php echo $ep['HT_receipt_err']; ?></td>
<td><?php echo $ep['TLD_total_price']; ?></td>
<td><?php echo $ep['TLD_agency_receipt']; ?></td>
<td><?php echo $ep['HT_haina_receipt']; ?></td>
<td><?php echo $ep['HT_agency_receipt']; ?></td>
</tr>
<?php }
} ?>
</tbody>
</table>
<?php if ( ! empty($error_msg)) { ?>
<p><?php echo $error_msg; ?></p>
<?php } ?>
<table class="table table-bordered table-hover">
<thead>
<tr>
<th colspan="3" class="text-left">成本异常:</th>
</tr>
<tr>
<th>拼团号</th>
<th>HT成本</th>
<th>账单成本</th>
</tr>
</thead>
<tbody>
<?php if ( ! empty($cost_error)) {
foreach ($cost_error as $ko => $ec) { ?>
<tr>
<td><?php echo $ec['GCI_combineNo']; ?></td>
<td><?php echo $ec['cost']; ?></td>
<td><?php echo $ec['group_cost']; ?></td>
</tr>
<?php }
} ?>
<?php if ( ! empty($ht_no_match)) {
foreach ($ht_no_match as $ko => $ht) { ?>
<tr>
<td><?php echo $ht['GCI_combineNo']; ?></td>
<td><?php echo $ht['cost']; ?></td>
<td>未找到</td>
</tr>
<?php }
} ?>
<?php if ( ! empty($xls_no_match)) {
foreach ($xls_no_match as $ko => $xls) { ?>
<tr>
<td><?php echo $xls['group_name']; ?></td>
<td>未找到</td>
<td><?php echo $xls['group_cost']; ?></td>
</tr>
<?php }
} ?>
</tbody>
</table>
</div>
</body>
<script src="/js/jquery.min.js" type="text/javascript"></script>
<script src="/js/bootstrap.min.js" type="text/javascript"></script>
<script src="https://cdn.jsdelivr.net/npm/flatpickr"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#date_range").flatpickr({
dateFormat: 'Y-m-d'
,mode: 'range'
,allowInput: true
,defaultDate:['<?php echo $default_date1 ?>', '<?php echo $default_date2 ?>']
});
})
function detail_download(vendor) {
document.request_form.action = "/webht.php/apps/trippestordersync/vendor_money/index" + "/" + vendor;
document.querySelector('#request_form').submit();
document.request_form.action = "/webht.php/apps/trippestordersync/vendor_money/index";
}
</script>
</html>

@ -40,6 +40,7 @@
<img width="150" style="height:40px;" src="/css/nav/img/6000.png"> <img width="150" style="height:40px;" src="/css/nav/img/6000.png">
</a> </a>
<h1>Trippest &amp; 地接账单结算</h1> <h1>Trippest &amp; 地接账单结算</h1>
<a href="/webht.php/apps/trippestordersync/vendor_money/report_precheck">预审核&raquo;</a>
<ul class="nav navbar-nav navbar-right pull-right" style="margin:7.5px 0;"> <ul class="nav navbar-nav navbar-right pull-right" style="margin:7.5px 0;">
<li class="dropdown"> <li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><?php $userdata=$this->session->userdata('admin_chtcdn'); echo $userdata['OPI_Name']; ?> <span class="caret"></span></a> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><?php $userdata=$this->session->userdata('admin_chtcdn'); echo $userdata['OPI_Name']; ?> <span class="caret"></span></a>

Loading…
Cancel
Save