|
|
|
@ -300,9 +300,8 @@ class Vendor_money extends CI_Controller {
|
|
|
|
|
$ret['not_found'] = $this->money_model->get_order_not_found_gci($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();
|
|
|
|
|
$xls_ht_diff = array();
|
|
|
|
|
$xls_data = array();
|
|
|
|
|
// $config['upload_path'] = FCPATH.'download_statement\temp_files';
|
|
|
|
|
$config['upload_path'] = 'download_statement/temp_files';
|
|
|
|
|
// $config['file_name'] = "1.xls";
|
|
|
|
@ -321,71 +320,117 @@ class Vendor_money extends CI_Controller {
|
|
|
|
|
{
|
|
|
|
|
$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'])) {
|
|
|
|
|
$row_tmp['group_name'] = trim_str(trim($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'))
|
|
|
|
|
$xls_data = $this->read_excel($read_path);
|
|
|
|
|
unlink($upload_data['upload_data']['full_path']);
|
|
|
|
|
$xls_ht_diff = $this->diff_xls_ht_cost($xls_data, $HT_combine_cost);
|
|
|
|
|
foreach ($xls_ht_diff['cost_error'] as $kc => $cost_error) {
|
|
|
|
|
$colis = $this->get_gci_coli($cost_error['GCI_combineNo'], false);
|
|
|
|
|
if (array_sum(array_column($colis['data'], 'no_fresh')) > 0
|
|
|
|
|
|| array_sum(array_column($colis['data'], 'cgi_check')) > 0
|
|
|
|
|
) {
|
|
|
|
|
$ht_no_match[] = $ht_cost;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
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 ($colis['data'] as $kco => $coli) {
|
|
|
|
|
async_curl("https://www.mycht.cn/webht.php/apps/trippestOrderSync/order_finance/single_order_report_refresh/" . $coli['COLI_SN'], 2);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ( ! empty($xls_data)) {
|
|
|
|
|
// 批量`重新生成账单`之后, 在对比一次
|
|
|
|
|
$HT_combine_cost = $this->money_model->get_combine_cost($start_date, $end_date, implode(',' ,$vendors));
|
|
|
|
|
$xls_ht_diff = $this->diff_xls_ht_cost($xls_data, $HT_combine_cost);
|
|
|
|
|
}
|
|
|
|
|
$ret = array_merge($ret, $xls_ht_diff);
|
|
|
|
|
|
|
|
|
|
return $this->load->view('order_report_precheck', $ret);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function diff_xls_ht_cost($xls_data, $HT_combine_cost)
|
|
|
|
|
{
|
|
|
|
|
$cost_error = array();
|
|
|
|
|
$ht_no_match = array();
|
|
|
|
|
$xls_no_match = array();
|
|
|
|
|
$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 (in_array($xls_cost['group_name'], $not_in_ht)) {
|
|
|
|
|
$xls_no_match[] = $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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
unlink($upload_data['upload_data']['full_path']);
|
|
|
|
|
}
|
|
|
|
|
foreach ($xls_data as $kxls => $xls_cost) {
|
|
|
|
|
if (in_array($xls_cost['group_name'], $not_in_ht)) {
|
|
|
|
|
$xls_no_match[] = $xls_cost;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$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);
|
|
|
|
|
return $ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function read_excel($read_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'])) {
|
|
|
|
|
$row_tmp['group_name'] = trim_str(trim($row_tmp['group_name']));
|
|
|
|
|
$xls_data[] = $row_tmp;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return $xls_data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function get_gci_coli($gci=null, $output=true)
|
|
|
|
|
{
|
|
|
|
|
$gci = $gci===null ? $this->input->get_post('gci') : $gci;
|
|
|
|
|
if ( ! $gci ) {
|
|
|
|
|
return $output===true ? $this->output->set_content_type('application/json')->set_output(json_encode([])) : [];
|
|
|
|
|
}
|
|
|
|
|
$result['data'] = $this->money_model->get_gci_coli($gci);
|
|
|
|
|
if (array_sum(array_column($result['data'], 'no_fresh')) == 0) {
|
|
|
|
|
$result['msg'] = '拼团中的订单含有其他地接社预订, 请到HT中查看和操作, 以免覆盖数据.';
|
|
|
|
|
}
|
|
|
|
|
return $output===true ? $this->output->set_content_type('application/json')->set_output(json_encode($result)) : $result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|