wugg 2 years ago
parent
commit
f8a1d2d2a2
1 changed files with 6 additions and 3 deletions
  1. 6 3
      app/admin/command/QueryInvalidInvoice.php

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

@@ -8,7 +8,7 @@ use think\console\Input;
 use think\console\input\Argument;
 use think\console\input\Option;
 use think\console\Output;
-use think\facade\Config;
+use think\facade\Cache;use think\facade\Config;
 use TaxInvoice;
 use think\facade\Db;
 class QueryInvalidInvoice extends Command
@@ -22,11 +22,12 @@ class QueryInvalidInvoice extends Command
 
     protected function execute(Input $input, Output $output)
     {
-//    	$this->ChickInvoice('91110113MA004JNJ28',"1100223130","35084031");
+		$generrateinvoice= Cache::store("redis")->get("queryinvalidinvoice");
+	    if($generrateinvoice==0) Cache::store("redis")->set("queryinvalidinvoice",1,180);
     	$date=date("Y-m-d H:i:s");
     	Db::startTrans();
     	try{
-    	$data =Db::name("invoice_return")->where(["status"=>1,"discard"=>2,"is_del"=>0])->where("updatetime","<=",date("Y-m-d H:i:s"))->findOrEmpty();
+    	$data =Db::name("invoice_return")->where(["status"=>1,"discard"=>2])->where("updatetime","<=",date("Y-m-d H:i:s"))->lock(true)->findOrEmpty();
     	if(empty($data))return;
     	$invoiceInfo = Db::name("invoice_ticket")->where(["invNo"=>$data['invNo'],"is_del"=>0,"status"=>1])->findOrEmpty();
     	if(empty($invoiceInfo))throw new \Exception("未找到开票数据");
@@ -75,10 +76,12 @@ class QueryInvalidInvoice extends Command
 			$reup=Db::name("invoice_return")->where($data)->update(["status"=>4,"remark"=>$data['remark']."({$check['ZTXX']})","updatetime"=>date("Y-m-d H:i:s")]);
 			if($reup==false)throw new \Exception("退票数据更新失败");
 		}
+		Cache::store("redis")->set("queryinvalidinvoice",0);
 		Db::commit();
 		$output->writeln("[$date] {$data['invNo']}数据处理完成");
     	}catch (\Exception $e){
     		Db::rollback();
+    		Cache::store("redis")->set("queryinvalidinvoice",0);
     		$output->writeln("[$date] ".$e->getMessage());
     	}