|
|
|
@ -49,7 +49,7 @@ class InvoiceIssuanceService |
|
|
|
|
|
|
|
$model = (new InvoiceIssuance()); |
|
|
|
$data = $model->where($where) |
|
|
|
->field('id,project_id,invoice_head_id,amount,create_time,status,serial_number') |
|
|
|
->field('id,project_id,invoice_head_id,amount,create_time,status,serial_number,expire_time') |
|
|
|
->order('create_time desc') |
|
|
|
->paginate($limit, false) |
|
|
|
->each(function ($item, $key) { |
|
|
|
@ -63,6 +63,7 @@ class InvoiceIssuanceService |
|
|
|
} |
|
|
|
$item->project_id = InvoiceIssuance::$projectArr[$item->project_id] ?? ''; |
|
|
|
$item->status_str = InvoiceIssuance::$statusArr[$item->status]; |
|
|
|
$item->expire_time = date("Y-m", $item->expire_time); |
|
|
|
}); |
|
|
|
return $data->toArray(); |
|
|
|
} |
|
|
|
@ -210,27 +211,51 @@ class InvoiceIssuanceService |
|
|
|
$feeUsers['jfrq'] = $FeeComputeDetail['WaterPayDate']; |
|
|
|
|
|
|
|
// 保存 |
|
|
|
$is_continue = false;// 是否跳过加工 |
|
|
|
$jsyj = 0; // 总金额 |
|
|
|
|
|
|
|
$ChinaTaxes = new ChinaTaxes($feeUsers, $invoiceDate); |
|
|
|
$savingDetailedData = $ChinaTaxes->savingDetailedData(); |
|
|
|
if (!isset($savingDetailedData['sbpch'])) { |
|
|
|
$VoucherData = $ChinaTaxes->queryIssuedPaymentVoucher($bdznsrsbh); |
|
|
|
$bdzkjmxList = $VoucherData['bdzkjmxList']; |
|
|
|
if (empty($bdzkjmxList)) { |
|
|
|
throw new \Exception('未查询到待开具电子缴款凭证数据'); |
|
|
|
} |
|
|
|
foreach ($bdzkjmxList as $bdzkjmxValue) { |
|
|
|
foreach($bdzkjmxValue['bdzkjmxVO'] as $bdzkjmxVOValue) { |
|
|
|
if ($bdzkjmxVOValue['yhbm'] == $pucode) { |
|
|
|
$sbpch = $bdzkjmxVOValue['sbpch']; |
|
|
|
$jsyj = $bdzkjmxVOValue['ydzse']; |
|
|
|
$is_continue = true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (!$is_continue) throw new \Exception('未查询到用户开具电子缴款凭证数据'); |
|
|
|
} else { |
|
|
|
// 批次号 |
|
|
|
$sbpch = $savingDetailedData['sbpch']; |
|
|
|
} |
|
|
|
|
|
|
|
// 批次号 |
|
|
|
$sbpch = $savingDetailedData['sbpch']; |
|
|
|
(new InvoiceIssuanceData())->saveField($invoiceIssuance['id'], 'sbpch', $sbpch); |
|
|
|
|
|
|
|
// 委托 - 加工数据 |
|
|
|
$realTimeProcessing = $ChinaTaxes->realTimeProcessing($sbpch); |
|
|
|
$realTimeProcessing = ['code' => 0]; |
|
|
|
if (!$is_continue) { |
|
|
|
$realTimeProcessing = $ChinaTaxes->realTimeProcessing($sbpch); |
|
|
|
} |
|
|
|
|
|
|
|
if ($realTimeProcessing['code'] == 200) { |
|
|
|
if ($realTimeProcessing['code'] == 200 || $is_continue) { |
|
|
|
// 处理加工成功返回数据 |
|
|
|
if (!isset($realTimeProcessing['data']['mxGrid'])) { |
|
|
|
throw new FuncException('加工数据有误'); |
|
|
|
} |
|
|
|
$mxGrid = $realTimeProcessing['data']['mxGrid']; |
|
|
|
|
|
|
|
$jsyj = 0; // 总金额 |
|
|
|
if (isset($mxGrid['sbMxsjVOList'])) { |
|
|
|
foreach ($mxGrid['sbMxsjVOList'] as $sbMxsjVOValue) { |
|
|
|
if (isset($sbMxsjVOValue['jsyj'])) $jsyj += $sbMxsjVOValue['jsyj']; |
|
|
|
if (!$is_continue) { |
|
|
|
if (!isset($realTimeProcessing['data']['mxGrid'])) { |
|
|
|
throw new FuncException('加工数据有误'); |
|
|
|
} |
|
|
|
$mxGrid = $realTimeProcessing['data']['mxGrid']; |
|
|
|
if (isset($mxGrid['sbMxsjVOList'])) { |
|
|
|
foreach ($mxGrid['sbMxsjVOList'] as $sbMxsjVOValue) { |
|
|
|
if (isset($sbMxsjVOValue['jsyj'])) $jsyj += $sbMxsjVOValue['jsyj']; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -531,6 +556,7 @@ class InvoiceIssuanceService |
|
|
|
if (!empty($r_data['ycms'])) { |
|
|
|
(new InvoiceIssuanceData())->saveField($data['id'], 'ycms', $r_data['ycms']); |
|
|
|
if (empty($r_data['sbpch'])) { |
|
|
|
(new InvoiceIssuance())->where('id', $data['id'])->save(['status' => 2]); |
|
|
|
// 第一次保存协议就失败 |
|
|
|
throw new \Exception($r_data['ycms']); |
|
|
|
} |
|
|
|
@ -575,6 +601,7 @@ class InvoiceIssuanceService |
|
|
|
|
|
|
|
return true; |
|
|
|
} catch (\Exception $e) { |
|
|
|
(new InvoiceIssuanceData())->saveField($data['id'], 'ycms', $e->getMessage()); |
|
|
|
//echo $e->getMessage() . '<br>'; |
|
|
|
return false; |
|
|
|
} |
|
|
|
@ -674,7 +701,7 @@ class InvoiceIssuanceService |
|
|
|
} |
|
|
|
|
|
|
|
if (!$save) { |
|
|
|
throw new FuncException('数据储存失败'); |
|
|
|
throw new FuncException('无新的结报数据'); |
|
|
|
} |
|
|
|
|
|
|
|
$FinalReportData->saveAll($save); |
|
|
|
@ -687,4 +714,37 @@ class InvoiceIssuanceService |
|
|
|
return $e->getMessage(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 临时结报 |
|
|
|
* @param $frd_id |
|
|
|
* @return bool|string |
|
|
|
*/ |
|
|
|
public function tempFinalReport($frd_id) |
|
|
|
{ |
|
|
|
try { |
|
|
|
$FinalReportDate = new FinalReportDate(); |
|
|
|
$data = $FinalReportDate->where('id', $frd_id)->find(); |
|
|
|
if (!$data) { |
|
|
|
throw new \Exception('参数有误'); |
|
|
|
} |
|
|
|
$zje = FinalReportData::getFrdSumAmount($frd_id); |
|
|
|
if ($zje <= 0) { |
|
|
|
throw new \Exception('结报金额为0'); |
|
|
|
} |
|
|
|
$result = $this->curl(['report_date' => $data['report_date'], 'zje' => $zje], 'apiFinalReport'); |
|
|
|
if ($result['code'] == 1) { |
|
|
|
$update = [ |
|
|
|
'status' => 1, |
|
|
|
'report_time' => time() |
|
|
|
]; |
|
|
|
FinalReportDate::update($update, ['id' => $frd_id]); |
|
|
|
} else { |
|
|
|
throw new FuncException($result['msg'] ?? '结报失败'); |
|
|
|
} |
|
|
|
return true; |
|
|
|
} catch (\Exception $e) { |
|
|
|
return $e->getMessage(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|