|
@@ -7,7 +7,7 @@ use app\admin\model\CompanyInfo;use app\admin\model\InvoiceInfo;use app\admin\mo
|
|
|
use think\console\Input;
|
|
|
use think\console\input\Argument;
|
|
|
use think\console\input\Option;
|
|
|
-use think\console\Output;use think\facade\Config;
|
|
|
+use think\console\Output;use think\facade\Config;use think\facade\Db;
|
|
|
|
|
|
class CheckInvoice extends Command
|
|
|
{
|
|
@@ -54,29 +54,38 @@ class CheckInvoice extends Command
|
|
|
}
|
|
|
protected function taxCheck($invoice){
|
|
|
$invoiceConf=Config::get('invoice');
|
|
|
- $invoice = $invoiceConf['91110113MA004JNJ28'];
|
|
|
- $Tax =new \TaxInvoice($invoice['appKey'],$invoice['appSecret'],$invoice['entCode']);
|
|
|
+ $iinvoicenfo = $invoiceConf['91110113MA004JNJ28'];
|
|
|
+ $Tax =new \TaxInvoice($iinvoicenfo['appKey'],$iinvoicenfo['appSecret'],$iinvoicenfo['entCode']);
|
|
|
$opentime = date("Ymd",strtotime($invoice['open_time']));
|
|
|
$checkNum= $invoice['checkNumber'];
|
|
|
$invNum= $this->InvoiceNum[$invoice['invoiceType']];
|
|
|
- if(!in_array($invNum,['012','022',"004","028"]))$checkNum= substr($invoice['checkNumber'],-6);
|
|
|
+ $subtotal= $invoice['inv_subtotal_amount'];
|
|
|
+ if(!in_array($invNum,['012','022',"028"]))$checkNum= substr($invoice['checkNumber'],-6);
|
|
|
if(in_array($invNum,['021','022'])) $subtotal= $invoice['inv_amount'];
|
|
|
- $result=$Tax->CheckInvoiceSingle( $checkNum,$subtotal,$invoice['inv_code'],$invoice['inv_number'],$opentime,$invNum);
|
|
|
- if(isset($result['code']) && $result['code']=='0000' and count($result['data'])>0){
|
|
|
- if($result['data']['cyjg']=="0001"){
|
|
|
- $data= $result['data'];
|
|
|
- $this->changeFiled($data,$invoice);
|
|
|
- }
|
|
|
- if (in_array($result['data']['cyjg'],["0002","1014"])){
|
|
|
- $this->lastUpdate($invoice['id']);
|
|
|
- }
|
|
|
+ $result=$Tax->CheckInvoiceSingle( $checkNum,$subtotal,$invoice['invoiceCode'],$invoice['invoiceNumber'],$opentime,$invNum);;
|
|
|
+ Db::startTrans();
|
|
|
+ try{
|
|
|
+ if(isset($result['code']) && $result['code']=='0000' and count($result['data'])>0){
|
|
|
+ if($result['data']['cyjg']=='0001'){
|
|
|
+ $data= $result['data'];
|
|
|
+ $this->changeFiled($data,$invoice);
|
|
|
+ }
|
|
|
+ if (in_array($result['data']['cyjg'],['0002','1014'])){
|
|
|
+ $this->lastUpdate($invoice['id']);
|
|
|
+ }else $this->faild($invoice['id']);
|
|
|
+ }else $this->faild($invoice['id']);
|
|
|
+ Db::commit();
|
|
|
+ }catch (\Exception $e){
|
|
|
+ Db::rollback();
|
|
|
+ echo $e->getMessage();
|
|
|
}
|
|
|
- $this->faild($invoice['id']);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
protected function changeFiled($data,$invoice){
|
|
|
$save = [
|
|
|
"payNo"=>$invoice['payNo'],
|
|
|
+ "hpNo"=>$invoice['hpNo'],
|
|
|
"type"=>$invoice['invoiceType'],
|
|
|
"title"=>"",
|
|
|
"code"=>$data['fpdm'],
|
|
@@ -102,7 +111,8 @@ class CheckInvoice extends Command
|
|
|
"issuer"=>$data['kpr'],
|
|
|
"reviewer"=>$data['fhr'],
|
|
|
"remarks"=>$data['bz'],
|
|
|
- "items"=>$this->checkItem($data['detailList'])
|
|
|
+ "change_field"=>"",
|
|
|
+ "item_list"=>$this->checkItem($data['detailList'])
|
|
|
];
|
|
|
$pay = Pay::where(["payNo"=>$invoice['payNo'],"is_del"=>0,"status"=>2])->findOrEmpty();
|
|
|
|