|
|
|
@ -531,6 +531,7 @@ class InvoiceIssuanceService |
|
|
|
if (!empty($r_data['ycms'])) { |
|
|
|
(new InvoiceIssuanceData())->saveField($data['id'], 'ycms', $r_data['ycms']); |
|
|
|
if (empty($r_data['sbpch'])) { |
|
|
|
// 第一次保存协议就失败 |
|
|
|
throw new \Exception($r_data['ycms']); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -574,7 +575,7 @@ class InvoiceIssuanceService |
|
|
|
|
|
|
|
return true; |
|
|
|
} catch (\Exception $e) { |
|
|
|
echo $e->getMessage() . '<br>'; |
|
|
|
//echo $e->getMessage() . '<br>'; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -582,10 +583,11 @@ class InvoiceIssuanceService |
|
|
|
/** |
|
|
|
* |
|
|
|
* @param array $data |
|
|
|
* @param string $url |
|
|
|
* @return mixed |
|
|
|
* @throws \Exception |
|
|
|
*/ |
|
|
|
private function curl(array $data) |
|
|
|
private function curl(array $data, string $url = 'apiInvoiceIssuance') |
|
|
|
{ |
|
|
|
|
|
|
|
$data_json = json_encode($data); |
|
|
|
@ -593,7 +595,7 @@ class InvoiceIssuanceService |
|
|
|
$curl = curl_init(); |
|
|
|
|
|
|
|
curl_setopt_array($curl, [ |
|
|
|
CURLOPT_URL => "https://intp.xingtongworld.com/api/test/apiInvoiceIssuance", |
|
|
|
CURLOPT_URL => "https://intp.xingtongworld.com/api/test/" . $url, |
|
|
|
CURLOPT_RETURNTRANSFER => true, |
|
|
|
CURLOPT_ENCODING => "", |
|
|
|
CURLOPT_MAXREDIRS => 10, |
|
|
|
@ -626,4 +628,63 @@ class InvoiceIssuanceService |
|
|
|
return json_decode($response, true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 临时第三方代理结报数据保存 |
|
|
|
* @return bool|string |
|
|
|
*/ |
|
|
|
public function tempSaveSummaryReport() |
|
|
|
{ |
|
|
|
try { |
|
|
|
|
|
|
|
$report_date = date("Y-m"); |
|
|
|
|
|
|
|
$FinalReportDate = new FinalReportDate(); |
|
|
|
$frd_id = $FinalReportDate->where('report_date', $report_date)->value('id'); |
|
|
|
if (!$frd_id) { |
|
|
|
$frdSave = [ |
|
|
|
'report_date' => $report_date, |
|
|
|
'status' => 0, |
|
|
|
'create_time' => time() |
|
|
|
]; |
|
|
|
$frd_id = $FinalReportDate->insertGetId($frdSave); |
|
|
|
} |
|
|
|
|
|
|
|
$data = $this->curl(['report_date' => $report_date], 'saveSummaryReport'); |
|
|
|
|
|
|
|
|
|
|
|
$FinalReportData = new FinalReportData(); |
|
|
|
|
|
|
|
if ($data['code'] == 1) { |
|
|
|
|
|
|
|
$save = []; |
|
|
|
foreach ($data['data'] as $val) { |
|
|
|
$sbpch = $val['sbpch']; // 申报批次号 |
|
|
|
$queryWhere = [ |
|
|
|
'frd_id' => $frd_id, |
|
|
|
'sbpch' => $sbpch |
|
|
|
]; |
|
|
|
$queryData = $FinalReportData->where($queryWhere)->field('id')->find(); |
|
|
|
if ($queryData) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
$queryWhere['ydzse'] = $val['ydzse']; |
|
|
|
$queryWhere['create_time'] = $val['create_time']; |
|
|
|
$save[] = $queryWhere; |
|
|
|
} |
|
|
|
|
|
|
|
if (!$save) { |
|
|
|
throw new FuncException('数据储存失败'); |
|
|
|
} |
|
|
|
|
|
|
|
$FinalReportData->saveAll($save); |
|
|
|
} else { |
|
|
|
throw new \Exception($data['msg']); |
|
|
|
} |
|
|
|
|
|
|
|
return true; |
|
|
|
} catch (\Exception $e) { |
|
|
|
return $e->getMessage(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|