wugg 1 år sedan
förälder
incheckning
c4df1d5d23

+ 14 - 5
app/admin/command/GenerrateInvoice.php

@@ -90,12 +90,21 @@ class GenerrateInvoice extends Command
     	if(empty($data)){
     		throw  new  \Exception("开票数据不能为空");
     	}
-    	$invoice=Config::get("invoice");
-    	$tax =new TaxInvoice($invoice['appKey'],$invoice['appSecret'],$invoice['entCode']);
+	        $invoiceConf=Config::get('invoice');
+	
+//    	$tax =new TaxInvoice($invoice['appKey'],$invoice['appSecret'],$invoice['entCode']);
+    	$tax=[];
     	foreach ($data AS $value){
-
-			$result = $tax->GenerateInvoice($value['DDPCXX'],$value['DDZXX']);
-
+			if(!isset($tax[$value['DDPCXX']['NSRSBH']])){
+				if(!isset($invoiceConf[$value['DDPCXX']['NSRSBH']])){
+					Db::name('invoice_interface')->where(['DDQQPCH'=>$value['DDPCXX']['DDQQPCH']])->update
+					(['status'=>4,'remark'=>"金税配置不存在",'updatetime'=>date('Y-m-d H:i:s')]);
+					continue;
+				}
+				$invoice=$invoiceConf[$value['DDPCXX']['NSRSBH']];
+				$tax[$value['DDPCXX']['NSRSBH']] = new TaxInvoice($invoice['appKey'],$invoice['appSecret'],$invoice['entCode']);
+			}
+			$result = $tax[$value['DDPCXX']['NSRSBH']]->GenerateInvoice($value['DDPCXX'],$value['DDZXX']);
 			if(isset($result['ZTDM'])&&$result['ZTDM']=='010000'){
 				Db::name("invoice_interface")->where(['DDQQPCH'=>$result['DDQQPCH']])->update(['status'=>1,
 				"remark"=>$result['ZTXX'],"updatetime"=>date("Y-m-d H:i:s",time()+60)]);

+ 9 - 1
app/admin/command/GetOrderInfoAndInvoiceInfo.php

@@ -88,7 +88,15 @@ class GetOrderInfoAndInvoiceInfo extends Command
     }
 
     protected function GetOrderInfo($order){
-    	$invoice=Config::get("invoice");
+//    	$invoice=Config::get("invoice");
+    	$invoiceConf=Config::get('invoice');
+    	if(!isset($invoiceConf[$order['XHFSBH']])){
+    		Db::name('invoice_interface')->where($order)->update(['status'=>4,'remark'=>"金税配置不存在",'updatetime'=>date('Y-m-d H:i:s')]);
+			echo '['.date('Y-m-d H:i:s').']';
+			echo "金税配置不存在\r\n";
+			return '';
+    	}
+    	$invoice = $invoiceConf[$order['XHFSBH']];
     	$tax =new \TaxInvoice($invoice['appKey'],$invoice['appSecret'],$invoice['entCode']);
 		$result=$tax->GetOrderInfoAndInvoiceInfo($order['XHFSBH'],$order['DDQQLSH']);
 		if(isset($result['ZTDM'])&& $result['ZTDM']=='000000'){

+ 3 - 1
app/admin/command/QueryInvalidInvoice.php

@@ -101,7 +101,9 @@ class QueryInvalidInvoice extends Command
 
 
     private function ChickInvoice($sellid,$invoice_code,$invoice_num){
-    	$invoice=Config::get("invoice");
+    	$invoiceConf=Config::get("invoice");
+    	if(!isset($invoiceConf[$sellid]))throw new \Exception("金税配置不存在");
+    	$invoice = $invoiceConf[$sellid];
     	$tax =new TaxInvoice($invoice['appKey'],$invoice['appSecret'],$invoice['entCode']);
     	$reuslt = $tax->QueryInvalidInvoice($sellid,$invoice_num,$invoice_code);
     	return $reuslt;

+ 8 - 1
app/admin/command/downredinvres.php

@@ -38,7 +38,14 @@ class downredinvres extends Command
 		$data=["updatetime"=>date("Y-m-d H:i:s",time()+600)];
         $opendatetime =date("Ymd",strtotime($row['addtime']));
         $ebddatetime =date("Ymd",strtotime("+2 days",strtotime($row['addtime'])));
-		$invoice=Config::get("invoice");
+		$invoiceConf=Config::get('invoice');
+    	if(!isset($invoiceConf[$row['XHFSBH']])){
+    		$data['remark']="金税配置不存在";
+			Db::name('invoice_red')->where(['id'=>$row['id']])->update($data);
+			Db::commit();
+        	return '';
+    	}
+    	$invoice = $invoiceConf[$row['XHFSBH']];
 		$Tax =new \TaxInvoice($invoice['appKey'],$invoice['appSecret'],$invoice['entCode']);
 		if($row['addtime']==$row['updatetime']){
 			$pch=randomkeys(8).md5(date("YmdHis").$row['id']);

+ 0 - 28
app/admin/command/wechatTmp.php

@@ -1,28 +0,0 @@
-<?php
-declare (strict_types = 1);
-
-namespace app\admin\command;
-
-use think\console\Command;
-use think\console\Input;
-use think\console\input\Argument;
-use think\console\input\Option;
-use think\console\Output;use think\Wechat as wchat;
-
-class wechatTmp extends Command
-{
-    protected function configure()
-    {
-        // 指令配置
-        $this->setName('wechattmp')
-            ->setDescription('the wechattmp command');
-    }
-
-    protected function execute(Input $input, Output $output)
-    {
-        $wechat_conf=['appid'=>env('WECHAT.APPID'),'appsecret'=>env('WECHAT.APPSECRET')];
-		$this->wechat=new wchat($wechat_conf);
-		
-		
-    }
-}

+ 16 - 6
app/admin/controller/OrderInv.php

@@ -723,10 +723,12 @@ class OrderInv extends BaseController{
 		if($company==false)return  error_show(1004,"开票业务公司未找到");
 		$invoiceinfo =Db::name("invoice_ticket")->where(["invNo"=>$invNo])->find();
 		if($invoiceinfo==false)return  error_show(1004,"发票详细信息未找到");
+		$invoiceConf=Config::get('invoice');
+    	if(!isset($invoiceConf[$company['company_license']]))return  error_show(1004,'金税配置不存在');
+    	$invoice = $invoiceConf[$company['company_license']];
+    	$tax =new \TaxInvoice($invoice['appKey'],$invoice['appSecret'],$invoice['entCode']);
 		Db::startTrans();
 		try{
-		$invoice=Config::get("invoice");
-    	$tax =new \TaxInvoice($invoice['appKey'],$invoice['appSecret'],$invoice['entCode']);
 		 $result=$tax->DeprecateInvoices($company['company_license'],$this->kingInvoice[$invoiceinfo['inv_type']],$invoiceinfo['inv_code'],$invoiceinfo['inv_number'],1);
 		 if(isset($result['ZTDM']) && $result['ZTDM']=='050000'){
 			 $up =Db::name("invoice_pool")->where($invinfo)->update(["status"=>6,"updatetime"=>date("Y-m-d H:i:s")]);
@@ -1047,7 +1049,9 @@ class OrderInv extends BaseController{
     //红冲票
 
     private  function addDiscard($ticket=[],$returnCode){
-		$invoice=Config::get("invoice");
+		$invoiceConf=Config::get('invoice');
+    	if(!isset($invoiceConf[$ticket['seller_id']]))throw new \Exception('金税配置不存在', 1006);
+    	$invoice = $invoiceConf[$ticket['seller_id']];
     	$tax =new \TaxInvoice($invoice['appKey'],$invoice['appSecret'],$invoice['entCode']);
     	$result=$tax->DeprecateInvoices($ticket['seller_id'],$ticket['inv_type'],$ticket['inv_code'],$ticket['inv_number'],1);
     	 if(isset($result['ZTDM']) && ($result['ZTDM']=='050000' || $result['ZTDM']=='053000')){
@@ -1207,7 +1211,9 @@ class OrderInv extends BaseController{
 	* @throws \think\db\exception\ModelNotFoundException
 	 */
     private function  addApplyRed($ticket=[],$return_reason,$returnCode,$red_desc){
-    	$invoice=Config::get("invoice");
+    	$invoiceConf=Config::get('invoice');
+    	if(!isset($invoiceConf[$ticket['seller_id']]))throw new \Exception('金税配置不存在', 1006);
+    	$invoice = $invoiceConf[$ticket['seller_id']];
 		$Tax =new \TaxInvoice($invoice['appKey'],$invoice['appSecret'],$invoice['entCode']);
 		$redticketList=[];
 		$redticketArry=[
@@ -1782,7 +1788,9 @@ class OrderInv extends BaseController{
 		if(empty($ticket)) return error_show(1004,"未找到开票信息");
 		$company =Db::name("company_info")->where(["companyNo"=>'GS2207150956046617'])->findOrEmpty();
 		if(empty($company)) return error_show(1004,"业务企业信息未找到");
-		$invoice=Config::get("invoice");
+		$invoiceConf=Config::get('invoice');
+    	if(!isset($invoiceConf[$company['company_license']]))throw new \Exception('金税配置不存在', 1006);
+    	$invoice = $invoiceConf[$company['company_license']];
 		$Tax =new \TaxInvoice($invoice['appKey'],$invoice['appSecret'],$invoice['entCode']);
 		$redticketList=[];
 		$redticketArry=[
@@ -1926,7 +1934,9 @@ class OrderInv extends BaseController{
 		if(empty($ticketArr)){
 		 return error_show(1004,"未找到开票信息");
 		}
-		$invoice=Config::get("invoice");
+		$invoiceConf=Config::get('invoice');
+    	if(!isset($invoiceConf[$company['company_license']]))throw new \Exception('金税配置不存在', 1006);
+    	$invoice = $invoiceConf[$company['company_license']];
 		$Tax =new \TaxInvoice($invoice['appKey'],$invoice['appSecret'],$invoice['entCode']);
 		Db::startTrans();
 		try{

+ 1 - 2
app/admin/controller/WeChat.php

@@ -7,13 +7,12 @@ use think\App;
 use app\admin\BaseController as Base;
 use think\facade\Validate;
 use think\facade\Db;
-use think\Wechat as wchat;
 class WeChat extends Base {
 	public $wechat;
 	public function __construct(App $App) {
 		parent::__construct($App);
 		$wechat_conf=["appid"=>env("WECHAT.APPID"),"appsecret"=>env("WECHAT.APPSECRET")];
-		$this->wechat=new wchat($wechat_conf);
+		$this->wechat=new \Wechat($wechat_conf);
 	}
 //		获取用户信息{subscribe,openid,nickname,sex,city,province,country,language,headimgurl,subscribe_time,[unionid]}
 

+ 1 - 1
app/command/Report.php

@@ -148,7 +148,7 @@ class Report extends Command
             if ($method == '') throw new Exception('该报表暂无对应的处理方法');
 
 		$data =$this->$method($param);
-            $url = excelSaveFile($data, $file . date('_YmdHis'));//加时间戳,防止同名文件覆盖
+            $url = excelSaveFile($data, $file . date('_YmdHis_').$param['id']);//加时间戳,防止同名文件覆盖
 		 Db::name('exec_log')
                     ->where(['id' => $param['id'], 'status' => 4])//status==1 待处理
                     ->update([