diff --git a/app/controller/api/Test.php b/app/controller/api/Test.php
index 2947187..04e700e 100644
--- a/app/controller/api/Test.php
+++ b/app/controller/api/Test.php
@@ -61,7 +61,7 @@ class Test extends Base
try {
$param = $this->request->param();
validate()->rule([
- 'report_date|结报日期' => 'require|number|max:11'
+ 'report_date|结报日期' => 'require|date'
])->check($param);
$data = (new \app\service\invoice\TempInvoiceService())->tempSaveSummaryReport($param['report_date']);
if (!is_array($data)) {
diff --git a/app/controller/task/InvoiceIssuanceTask.php b/app/controller/task/InvoiceIssuanceTask.php
index c3e95fb..fa20186 100644
--- a/app/controller/task/InvoiceIssuanceTask.php
+++ b/app/controller/task/InvoiceIssuanceTask.php
@@ -62,7 +62,7 @@ class InvoiceIssuanceTask extends Base
*/
public function runSummaryReport(): Response
{
- $result = (new InvoiceIssuanceService())->saveSummaryReport();
+ $result = (new InvoiceIssuanceService())->tempSaveSummaryReport();
if ($result !== true) {
return $this->buildFailed('0', $result);
}
diff --git a/app/service/invoice/InvoiceIssuanceService.php b/app/service/invoice/InvoiceIssuanceService.php
index 1744d1e..7a9d1b6 100644
--- a/app/service/invoice/InvoiceIssuanceService.php
+++ b/app/service/invoice/InvoiceIssuanceService.php
@@ -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() . '
';
+ //echo $e->getMessage() . '
';
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();
+ }
+ }
}
diff --git a/route/apiRoute.php b/route/apiRoute.php
index 7d6a2bd..b1f32f8 100644
--- a/route/apiRoute.php
+++ b/route/apiRoute.php
@@ -19,6 +19,7 @@ Route::group('api', function() {
Route::rule('Test/index', 'api.Test/index', 'get');
Route::rule('Test1/index', 'api.Test1/index', 'get');
Route::rule('Test/index', 'api.Test/apiInvoiceIssuance', 'post');
+ Route::rule('Test/saveSummaryReport', 'api.Test/saveSummaryReport', 'post');
Route::rule('InvoiceIssuance/downFile', 'api.InvoiceIssuance/downFile', 'get');
//MISS路由定义
//Route::miss('api.Miss/index');