Commit ef773c4c authored by hangjun83's avatar hangjun83

财务开票模块更新

parent 09fb88ac
...@@ -31,4 +31,9 @@ class RhawnInvoiceRepositoryEloquent extends BaseRepository implements RhawnInvo ...@@ -31,4 +31,9 @@ class RhawnInvoiceRepositoryEloquent extends BaseRepository implements RhawnInvo
} }
return null; return null;
} }
public function updateInvoiceById($id,$updateParams)
{
return $this->updateOrCreate(['id' => $id],$updateParams)->toArray();
}
} }
...@@ -179,7 +179,7 @@ class InvoiceService ...@@ -179,7 +179,7 @@ class InvoiceService
$applyInvoiceParams['zpFppzdm'] = $invoiceParams['invoice_category'] == 2 ? '1130' : '04'; $applyInvoiceParams['zpFppzdm'] = $invoiceParams['invoice_category'] == 2 ? '1130' : '04';
$applyInvoiceParams['jshj'] = bcmul($invoiceParams['invoice_money'],1,2); $applyInvoiceParams['jshj'] = bcmul($invoiceParams['invoice_money'],1,2);
$applyInvoiceParams['hjje'] = bcdiv($applyInvoiceParams['jshj'],1.13,2); $applyInvoiceParams['hjje'] = bcdiv($applyInvoiceParams['jshj'],1.13,2);
$applyInvoiceParams['hjse'] = bcmul($applyInvoiceParams['hjje'],bcdiv($platformInfo['tax_rate'],100,3),2); $applyInvoiceParams['hjse'] = bcsub($applyInvoiceParams['jshj'],$applyInvoiceParams['hjje'],2);//bcmul($applyInvoiceParams['hjje'],bcdiv($platformInfo['tax_rate'],100,3),2);
//初始化非必填项 //初始化非必填项
$applyInvoiceParams['bz'] = ''; $applyInvoiceParams['bz'] = '';
...@@ -385,21 +385,90 @@ class InvoiceService ...@@ -385,21 +385,90 @@ class InvoiceService
public function apiCallBack($params) public function apiCallBack($params)
{ {
if(isset($params) && !empty($params)){ if(isset($params) && !empty($params)){
$queueParams = [];
//现将返回的数据进行存储 //现将返回的数据进行存储
//$this->apiService->storePlatformDataEntries('invoice_callBack_',$params);
switch($params['ywlxdm']){ switch($params['ywlxdm']){
case 'fpkj' : $this->apiService->storePlatformDataEntries('invoice_callBack_'.$params['ddlsh'].'_applyInvoice',$params);break; case 'fpkj' :
$this->apiService->storePlatformDataEntries('invoice_callBack_'.$params['ddlsh'].'_applyInvoice',$params);
$queueParams = ['params' => $params,'type' => 'applyInvoiceCallBack'];
break;
} }
//塞入队列 //塞入队列
/*$this->apiService->pushQueue([ $this->apiService->pushQueue([
'params' => ['invoice_number' => $params['ddlsh'],'type' => 'applyInvoice'], 'params' => $queueParams,
'consumer' => __CLASS__, 'consumer' => __CLASS__,
'method' => 'applyInvoiceCallBack' 'method' => 'invoiceApiCallBack'
],'invoiceCallBack');*/ ],'invoiceCallBack');
}
}
public function invoiceApiCallBack($params)
{
if(empty($params)){
return false;
}
//记录日志
SimpleLogs::writeLog($params, __CLASS__.':'.__FUNCTION__.' callback params => ');
//根据type回调相应方法处理逻辑
if($params['type'] && method_exists(__CLASS__,$params['type'])){
app(__CLASS__)->$params['type']($params['params']);
}
}
public function applyInvoiceCallBack($callBackParams)
{
if(empty($callBackParams)){
return false;
}
//根据发票流水找到相应数据
if(isset($callBackParams['ddlsh']) && !empty($callBackParams['ddlsh'])){
$invoiceInfo = $this->invoiceRecordRepository->getInvoiceRecordByNumber($callBackParams['ddlsh']);
if(!$invoiceInfo){
SimpleLogs::writeLog($callBackParams, __CLASS__.':'.__FUNCTION__.' 无法找到发票流水号:'.$callBackParams['ddlsh'].'的数据', 'error');
return false;
}
//更新对应的发票数据,并反写回相应的平台发票
try{
$updateInvoice = [];
if($callBackParams['status'] == 1){
$updateInvoice['inovice_number'] = $callBackParams['ddlsh'];
$updateInvoice['invoice_status'] = 1;
$updateInvoice['invoice_real_number'] = $callBackParams['fphm'];
$updateInvoice['invoice_real_date'] = $callBackParams['kprq'];
$updateInvoice['invoice_pdf_url'] = $callBackParams['pdf'];
$updatedInvoiceResult = $this->invoiceRecordRepository->saveInvoice($updateInvoice);
if($updatedInvoiceResult){
//对平台的发票信息进行更新
$updateResult = null;
switch($updatedInvoiceResult['invoice_platform']){
case 'rhawn' :
$updateResult = $this->rhawnInvoiceRepository->updateInvoiceById($updatedInvoiceResult['platform_invoice_id'],
[
'soi_api_status' => 1,
'soi_no' => $callBackParams['fphm'],
'soi_date' => strtotime($callBackParams['kprq']),
//'soi_total' => bcmul($callBackParams['jshj'],1,2),
'soi_tax' => bcmul($callBackParams['hjse'],1,2),
'soi_amount' => bcmul($callBackParams['hjje'],1,2)
]
);
}
if($updateResult){
//发送邮件
}
}
}
}catch(\Throwable $exception){
SimpleLogs::writeLog($exception->getMessage(), __CLASS__.':'.__FUNCTION__, 'error');
}
} }
} }
public function applyInvoiceCallBack() public function getInvoicePdfDownloadUrl()
{ {
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment