wugg il y a 2 ans
Parent
commit
fc552084f6

+ 14 - 6
app/admin/controller/Company.php

@@ -4,12 +4,17 @@ declare (strict_types = 1);
 namespace app\admin\controller;
 use app\admin\BaseController;
 use think\App;
-use think\facade\Db;
+use think\facade\Config;use think\facade\Db;
 
 
 class Company extends BaseController
 {
-    public function __construct(App $app) {parent::__construct($app);}
+	protected $invoiceType;
+    public function __construct(App $app) {
+    	parent::__construct($app);
+        $invoice =Config::get("invoiceType");
+        $this->invoiceType = $invoice['invoiceType'];
+    }
     /**
      * 显示资源列表
      *
@@ -102,7 +107,8 @@ class Company extends BaseController
             $reviewer = isset($post['reviewer'])&&$post['reviewer']!="" ? trim($post['reviewer']) :"";
             $ownerPlace = isset($post['ownerPlace'])&&$post['ownerPlace']!="" ? trim($post['ownerPlace']) :"";
             $denomination = isset($post['denomination'])&&$post['denomination']!="" ? trim($post['denomination']) :"";
-            $invoiceType = isset($post['invoiceType'])&&!empty($post['invoiceType']) ? implode(",", $post['invoiceType']):"";
+            $invoiceType = isset($post['invoiceType'])&&!empty($post['invoiceType']) ? $post['invoiceType']:"";
+            if($invoiceType!=''&& !empty(array_diff($invoiceType,$this->invoiceType))) return error_show(1004,"存在无效发票类型");
        $data = [
            "companyNo"=>$companyNo,
            "company_name"=>$name,
@@ -121,7 +127,7 @@ class Company extends BaseController
            "reviewer"=>$reviewer,
            "ownerPlace"=>$ownerPlace,
            "denomination"=>$denomination,
-           "invoiceType"=>$invoiceType,
+           "invoiceType"=>$invoiceType!=''|| empty($invoiceType)?implode(",",$invoiceType):"",
            "status"=>1,
            "addtime"=>date("Y-m-d H:i:s"),
            "updatetime"=>date("Y-m-d H:i:s")
@@ -186,7 +192,9 @@ class Company extends BaseController
             $reviewer = isset($post['reviewer'])&&$post['reviewer']!="" ? trim($post['reviewer']) :"";
             $ownerPlace = isset($post['ownerPlace'])&&$post['ownerPlace']!="" ? trim($post['ownerPlace']) :"";
             $denomination = isset($post['denomination'])&&$post['denomination']!="" ? trim($post['denomination']) :"";
-            $invoiceType = isset($post['invoiceType'])&&!empty($post['invoiceType']) ? implode(",", $post['invoiceType']):"";
+            $invoiceType = isset($post['invoiceType'])&&!empty($post['invoiceType']) ? implode(",", $post['invoiceType']):[];
+             if(($invoiceType!=''|| !empty($invoiceType))&& !empty(array_diff($invoiceType,$this->invoiceType)))
+             	return error_show(1004,"存在无效发票类型");
         $data = [
             "company_name"=>$name,
             "company_address"=>$address,
@@ -204,7 +212,7 @@ class Company extends BaseController
            "reviewer"=>$reviewer,
            "ownerPlace"=>$ownerPlace,
            "denomination"=>$denomination,
-           "invoiceType"=>$invoiceType,
+           "invoiceType"=>$invoiceType!=''|| !empty($invoiceType)?implode(",",$invoiceType):"",
             "updatetime"=>date("Y-m-d H:i:s")
         ];
         $result = Db::name("company_info")->where("companyNo","=",$companyNo)->update($data);

+ 54 - 74
app/admin/controller/OrderInv.php

@@ -5,21 +5,23 @@ namespace app\admin\controller;
 use app\admin\BaseController;
 use app\admin\model\ReportCode;
 use think\App;
-use think\Exception;use think\facade\Config;
+use think\Exception;
+use think\facade\Config;
 use think\facade\Db;
 use think\facade\Cache;
 
 class OrderInv extends BaseController{
-	private $typename=[
-		"004"=>"增值税专用发票",
-		'007'=>"增值税普通发票",
-		'026'=>'增值税电子普通发票',
-		'028'=>'增值税电子专用发票',
-		'021'=>"全电专用发票",
-		'022'=>"全电普通发票"
-		];
+	protected $typename;
+	protected $invoiceType;
+    protected $invName;
+    protected $kingInvoice;
     public function __construct(App $app) {
         parent::__construct($app);
+        $invoice =Config::get("invoiceType");
+        $this->invoiceType = $invoice['invoiceName'];
+        $this->invName = $invoice['invoiceType'];
+        $this->typename = $invoice['KingName'];
+        $this->kingInvoice = $invoice['KingInvoice'];
     }
     /**
      * 新建销售单开票申请
@@ -60,12 +62,13 @@ class OrderInv extends BaseController{
 //       if($customer==false){
 //           return error_show(1004,"客户信息未找到");
 //       }
-       $invtype = isset($this->post['invtype'])&&$this->post['invtype']!=='' ? intval($this->post['invtype']):"";
+       $invtype = isset($this->post['invtype'])&&$this->post['invtype']!=='' ? trim($this->post['invtype']):"";
         if($invtype==''){
            return error_show(1004,"参数 invtype 不能为空");
        }
-        $email = isset($this->post['email'])&&$this->post['email']!=='' ? trim($this->post['email']):"";
+        if(!in_array($invtype,$this->invName)) return error_show(1004,"发票类型有误");
 
+        $email = isset($this->post['email'])&&$this->post['email']!=='' ? trim($this->post['email']):"";
         $remark = isset($this->post['remark'])&&$this->post['remark']!=='' ? trim($this->post['remark']):"";
         $exam_remark = isset($this->post['exam_remark'])&&$this->post['exam_remark']!=='' ? trim($this->post['exam_remark']):"";
         $orderArr = isset($this->post['orderArr'])&&!empty($this->post['orderArr']) ? $this->post['orderArr']:[];
@@ -280,19 +283,20 @@ class OrderInv extends BaseController{
                if($invCode==='') return error_show(1004,"参数 invCode 不能为空");
                if($invNum==='') return error_show(1004,"参数 invNum 不能为空");
                if($open_date==='') return error_show(1004,"参数 open_date 不能为空");
-               if($invinfo['inv_type']==2 || $invinfo['inv_type']==3){
+               if(in_array($invinfo['inv_type'],['normal','roll',"toll",'electronic'])){
                	    if($checkCode==='') return error_show(1004,"参数 checkCode 不能为空");
                }
                if($subtotal_fee==='') return error_show(1004,"参数 subtotal_fee 不能为空");
+               //全电子发票 信息需要全填补充切无法接口识别验真
+	           if(in_array($invinfo['inv_type'],['fully_digitalized_special_electronic','fully_digitalized_normal_electronic'])){
+	              if($invNum==='') return error_show(1004,"参数 invNum 不能为空");
+	              if($open_date==='') return error_show(1004,"参数 open_date 不能为空");
+	              if($subtotal_fee==='') return error_show(1004,"参数 subtotal_fee 不能为空");
+	              if($total_fee=='') return error_show(1004,"参数 total_fee 不能为空");
+					$status=3;
+	           }
            }
-           //全电子发票 信息需要全填补充切无法接口识别验真
-           if($invinfo['inv_type']==5){
-              if($invNum==='') return error_show(1004,"参数 invNum 不能为空");
-              if($open_date==='') return error_show(1004,"参数 open_date 不能为空");
-              if($subtotal_fee==='') return error_show(1004,"参数 subtotal_fee 不能为空");
-              if($total_fee=='') return error_show(1004,"参数 total_fee 不能为空");
-				$status=3;
-           }
+
         }
 
         if($status==7){
@@ -304,10 +308,10 @@ class OrderInv extends BaseController{
 
           $invup =Db::name("invoice_pool")->where($invinfo)->update($update);
         if($invup){
-            if(($status==2&& $open_type!=1) || ($invinfo['inv_type']==5 &&$status==3 )){
+            if(($status==2&& $open_type!=1) || ($invinfo['inv_type']==5 &&$status==2)){
             		 $invpool=[
                         "invNo"=>$invinfo['invNo'],
-                        "inv_type"=>invoiceType($invinfo['inv_type']),
+                        "inv_type"=>$this->kingInvoice[$invinfo['inv_type']],
                         "inv_code"=>$invCode,
                         "inv_number"=>$invNum,
                         "check_code"=>$checkCode,
@@ -398,7 +402,7 @@ class OrderInv extends BaseController{
 							"HJSE"=>"0",
 							"BZ"=>$invinfo['remark'],
 							"DDMXXX"=>$goodinfo,
-							"FPLXDM"=>invoiceType($invinfo['inv_type']),
+							"FPLXDM"=>$this->kingInvoice[$invinfo['inv_type']],
 							"DDQQPCH"=>"",
 							"DDQQLSH"=>randomkeys(26).date("YmdHis"),
 							"status"=>"0",
@@ -586,7 +590,7 @@ class OrderInv extends BaseController{
 		try{
 		$invoice=Config::get("invoice");
     	$tax =new \TaxInvoice($invoice['appKey'],$invoice['appSecret'],$invoice['entCode']);
-		 $result=$tax->DeprecateInvoices($company['company_license'],invoiceType($invoiceinfo['inv_type']),$invoiceinfo['inv_code'],$invoiceinfo['inv_number'],1);
+		 $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")]);
 			 if($up){
@@ -762,9 +766,9 @@ class OrderInv extends BaseController{
 	            if($invCode==='') return error_show(1004,"参数 invCode 不能为空");
 	            if($invNum==='') return error_show(1004,"参数 invNum 不能为空");
 	            if($open_date==='') return error_show(1004,"参数 open_date 不能为空");
-	            if($invinfo['inv_type']==2 || $invinfo['inv_type']==3){
-	                    if($checkCode==='') return error_show(1004,"参数 checkCode 不能为空");
-	               }
+	            if(in_array($invinfo['inv_type'],['normal','roll',"toll",'electronic'])){
+               	    if($checkCode==='') return error_show(1004,"参数 checkCode 不能为空");
+               }
 	            if($subtotal_fee==='') return error_show(1004,"参数 subtotal_fee 不能为空");
             }
         }
@@ -810,7 +814,7 @@ class OrderInv extends BaseController{
                         "addtime"=>date("Y-m-d H:i:s"),
                         "updatetime"=>date("Y-m-d H:i:s")
                      ];
-                $in = Db::name("invoice_ticket")->insert($invpool);
+                    $in = Db::name("invoice_ticket")->insert($invpool);
 	                if($in==false){
 	                    Db::rollback();
 	                   return error_show(1004,"发票信息添加失败");
@@ -850,12 +854,6 @@ class OrderInv extends BaseController{
                               }
                           }
                      }
-//                      $up=Db::name("invoice_pool")->where($invinfo)->update(["status"=>6,"updatetime"=>date("Y-m-d
-//                      H:i:s")]);
-//                     if($up==false){
-//                     	 Db::rollback();
-//                         return error_show(1003,"发票信息更新失败");
-//                     }
                 }
                 if($status==3 || $status==4){
                      foreach ($qrd as $value){
@@ -1016,7 +1014,7 @@ class OrderInv extends BaseController{
         if($status!==""){
           $condition[]=["a.status","=",$status];
         }
-        $inv_type = isset($this->post['inv_type'])&&$this->post['inv_type']!=="" ? intval($this->post['inv_type']):"";
+        $inv_type = isset($this->post['inv_type'])&&$this->post['inv_type']!=="" ? trim($this->post['inv_type']):"";
         if($inv_type!==""){
            $condition[]=["a.inv_type","=",$inv_type];
         }
@@ -1135,7 +1133,7 @@ class OrderInv extends BaseController{
         if($end!=""){
             $condition[]=["a.addtime","<=",$end." 23:59:59"];
         }
-         $inv_type = isset($this->post['inv_type'])&&$this->post['inv_type']!=="" ? intval($this->post['inv_type']):"";
+         $inv_type = isset($this->post['inv_type'])&&$this->post['inv_type']!=="" ? trim($this->post['inv_type']):"";
         if($inv_type!==""){
            $condition[]=["b.inv_type","=",$inv_type];
         }
@@ -1195,7 +1193,7 @@ class OrderInv extends BaseController{
 		$redticketArry=[
 			"SQBSCQQPCH"=>randomkeys(26).date("YmdHis"),
 			"NSRSBH"=>$company['company_license'],
-			"FPLXDM"=>invoiceType($invfo['inv_type']),
+			"FPLXDM"=>$this->kingInvoice[$invfo['inv_type']],
 		];
 		$goodinfo =Db::name("invoice_good")
             		->where(["invNo"=>$invNo,"is_del"=>0])
@@ -1284,7 +1282,7 @@ class OrderInv extends BaseController{
 			 "XXBTSBS"=>"0",
 			 "DDMXXX"=>json_encode($qdmx,JSON_UNESCAPED_UNICODE),
 			 "SQBSCQQPCH"=>$redticketArry['SQBSCQQPCH'],
-			 "FPLXDM"=>invoiceType($invfo['inv_type']),
+			 "FPLXDM"=>$this->kingInvoice[$invfo['inv_type']],
 		];
 	    $redticketList[]=["HZSQDTXX"=>$info,"DDMXXX"=>$qdmx];
 		$result=$Tax->AllocateRedInvoiceApplication($redticketArry,$redticketList);
@@ -1340,7 +1338,7 @@ class OrderInv extends BaseController{
 			$redticketArry=[
 					"SQBSCQQPCH"=>randomkeys(26).date("YmdHis"),
 					"NSRSBH"=>$company['company_license'],
-					"FPLXDM"=>invoiceType($inv_type[0]),
+					"FPLXDM"=>$this->kingInvoice[$inv_type[0]],
 				];
 			$redticketList=[];
 			foreach ($invfo as $value){
@@ -1437,7 +1435,7 @@ class OrderInv extends BaseController{
 			 "XXBTSBS"=>"0",
 			 "DDMXXX"=>json_encode($qdmx,JSON_UNESCAPED_UNICODE),
 			 "SQBSCQQPCH"=>$redticketArry['SQBSCQQPCH'],
-			  "FPLXDM"=>invoiceType($value['inv_type']),
+			  "FPLXDM"=>$this->kingInvoice[$value['inv_type']],
 		];
 		$insertAll[$info['SQBSCQQLSH']]=$data;
 		}
@@ -1924,9 +1922,9 @@ class OrderInv extends BaseController{
         if($end!=""){
             $condition[]=["a.addtime","<=",$end." 23:59:59"];
         }
-         $inv_type = isset($this->post['inv_type'])&&$this->post['inv_type']!=="" ? intval($this->post['inv_type']):"";
+         $inv_type = isset($this->post['inv_type'])&&$this->post['inv_type']!=="" ? trim($this->post['inv_type']):"";
         if($inv_type!==""){
-           $condition[]=["b.inv_type","=",$inv_type];
+           $condition[]=["c.inv_type","=",$inv_type];
         }
          $companyNo = isset($this->post['companyNo'])&&$this->post['companyNo']!=="" ? trim($this->post['companyNo']):"";
         if($companyNo!==""){
@@ -1995,9 +1993,8 @@ class OrderInv extends BaseController{
     	 ->page($page,intval($post['size']))
     	 ->order("a.id desc")
     	 ->select()->toArray();
-    	 $typename=["004"=>"增值税专用发票",'007'=>"增值税普通发票",'026'=>'增值税电子普通发票','028'=>'增值税电子专用发票'];
     	  foreach ($list as &$value){
-    	 	    $value['invtype_name'] = $typename[$value['inv_type']]??"";
+    	 	    $value['invtype_name'] = $this->typename[$value['inv_type']]??"";
     	 }
     	 return app_show(0,"获取成功",["list"=>$list,"count"=>$count]);
     }
@@ -2056,25 +2053,7 @@ class OrderInv extends BaseController{
            $temp['num'] =$good['goodNum'];
            $temp['price'] =$good['goodPrice'];
            $temp['total_fee'] =$good['totalPrice'];
-           switch ($value['inv_type']){
-               case 1:
-                   $temp['inv_type']  = "增值税专用发票";
-                   break;
-               case 2:
-                   $temp['inv_type']  = "增值税普通发票";
-                   break;
-               case 3:
-                   $temp['inv_type']  = "增值税电子专用发票";
-                   break;
-               case 4:
-                  $temp['inv_type']  = "增值税电子普通发票";
-                  break;
-               default:
-                   $temp['inv_type']  = "-";
-                   break;
-           }
-        // $temp['inv_type'] = $value['inv_type']==1?"增值税专用发票": "增值税普通发票";
-        // $temp['inv_value'] =$value['inv_value'];
+           $temp['inv_type']=$this->invoiceType[$value['inv_type']]?? "-";
             $temp['remark'] =$value['remark'];
            $temp['kp_companyName'] = $invinfo['seller_title']??"";
            $temp['kp_company_address'] = $invinfo['seller_addr']??"";
@@ -2137,14 +2116,14 @@ class OrderInv extends BaseController{
             if($value["inv_type"]===""){
                 return error_show(1005,"第".($key+1)."行缺少发票类型数据");
             }
-            $invtype=array_search($value['inv_type'],$this->typename)??"";
-            if($value["inv_code"]=="" && $value['inv_type']!=="000"){
+            if(!in_array($value['inv_type'],$this->invName))  return error_show(1005,"第".($key+1)."行发票类型数据有误");
+            if($value["inv_code"]=="" && !in_array($value['inv_type'],[ "fully_digitalized_special_electronic", "fully_digitalized_normal_electronic"])){
                 return error_show(1005,"第".($key+1)."行缺少发票代码数据");
             }
             if($value["inv_number"]==""){
                 return error_show(1005,"第".($key+1)."行缺少发票号码数据");
             }
-            if($value["inv_total"]==""&& in_array($invtype,["021","022"])){
+            if($value["inv_total"]==""&& in_array($value['inv_type'],["fully_digitalized_special_electronic", "fully_digitalized_normal_electronic"])){
                 return error_show(1005,"第".($key+1)."行缺少发票金额数据");
             }
              if($value["inv_subtotal"]==""){
@@ -2154,7 +2133,7 @@ class OrderInv extends BaseController{
                 return error_show(1005,"第".($key+1)."行缺少发票开票日期数据");
             }
             //电子票校验码必传
-            if($value["check_code"]=="" && in_array($invtype,["026","028"])){
+            if($value["check_code"]=="" && in_array($value['inv_type'],['normal','roll',"toll",'electronic'])){
                 return error_show(1005,"第".($key+1)."行缺少发票校验码数据");
             }
 //            if($value['inv_type']==="000"){
@@ -2177,7 +2156,7 @@ class OrderInv extends BaseController{
             $temp=[];
             $temp['invNo'] = $value["invNo"];
             $temp['type'] = 0;
-            $temp['inv_type'] =$invtype ;
+            $temp['inv_type'] =$value['inv_type'];
             $temp['inv_code'] = $value['inv_code'];
             $temp['inv_number'] = $value['inv_number'];
             $temp['inv_subtotal'] = $value['inv_subtotal'];
@@ -2209,17 +2188,16 @@ class OrderInv extends BaseController{
 		 Db::startTrans();
 		 try{
 		 	$keyarr =array_keys($total);
-		 	$invTArr =array_keys($this->typename);
 		 	$inpool = Db::name("invoice_pool")->where([["invNo","in",$keyarr],["open_type","in",[0,2,3]],["is_del","=",0],["status","=",0]])->column("winv_fee,invNo,inv_value,inv_type","invNo");
 
 		 	foreach ($total as $key=>$val){
 				if(!isset($inpool[$key])) continue;
-				if(in_array($val['inv_type'],["021","022"]) && $inpool[$key]['winv_fee']!=$val['total']){
+				if(in_array($val['inv_type'],["fully_digitalized_special_electronic", "fully_digitalized_normal_electronic"]) && $inpool[$key]['winv_fee']!=$val['total']){
 					throw new Exception("{$key}全电发票面金额小于未开票金额");
 				}
-				if($invTArr[$inpool[$key]['inv_type']]!= $val['inv_type'] ) throw new Exception("{$key}发票类型有误");
+				if($inpool[$key]['inv_type']!= $val['inv_type']) throw new Exception("{$key}发票类型有误");
 				$update=[
-					"status"=>in_array($val['inv_type'],["021","022"])?3:2,
+					"status"=>in_array($val['inv_type'],["fully_digitalized_special_electronic", "fully_digitalized_normal_electronic"])?3:2,
 					"open_type"=>$inpool[$key]['open_type']??3,
 					"updatetime"=>date("Y-m-d H:i:s")
 				];
@@ -2262,9 +2240,11 @@ class OrderInv extends BaseController{
                           }
                       }
                  }
-            }
+                 $val['inv_type'] = $this->kingInvoice[$val['inv_type']];
+                 $list[]=$val;
+                }
 		 	}
-		 	        $inticket =Db::name("invoice_ticket")->insertAll($list);
+		 	     $inticket =Db::name("invoice_ticket")->insertAll($list);
 			     if(!$inticket){
 	                Db::rollback();
 	                return error_show(1005,"发票数据录入失败");

+ 24 - 49
app/admin/controller/Payment.php

@@ -5,48 +5,29 @@ namespace app\admin\controller;
 
 use app\admin\BaseController;
 use app\admin\model\ReportCode;
-use think\App;use think\Exception;use think\facade\Db;use think\facade\Validate;
+use think\App;use think\Exception;
+use think\facade\Config;
+use think\facade\Db;
+use think\facade\Validate;
 
 class Payment extends BaseController
 {
-     //发票类型
-    //增值税专用发票:vat_special
-    //增值税普通发票:vat_normal
-    //增值税普通发票(卷式):vat_normal_roll
-    //增值税电子专用发票:vat_special_electronic
-    //增值税电子普通发票:vat_normal_electronic
-    //增值税电子普通发票(通行费):vat_normal_electronic_toll
-    //区块链电子发票:blockchain_electronic
-    public $invoiceType=[
-        "special"=>"增值税专用发票",
-        "normal"=>"增值税普通发票",
-        "roll"=>"增值税普通发票(卷式)",
-        "special_electronic"=>"增值税电子专用发票",
-        "electronic"=>"增值税电子普通发票",
-        "toll"=>"增值税电子普通发票(通行费)",
-        "fully_digitalized_special_electronic"=>"全电专用发票",
-        "fully_digitalized_normal_electronic"=>"全电普通发票",
-        ];
-
-    public $invName= [
-              "01"=>"special",//"增值税专用发票",
-             '04'=>"normal",//"增值税普通发票",
-             '11'=>"roll",//"增值税普通发票(卷式)",
-             '08'=>"special_electronic",// "增值税电子专用发票",
-             '10'=>"electronic",//"增值税电子普通发票",
-             '14'=>"toll",//"增值税电子普通发票(通行费)"
-             '21'=>"fully_digitalized_special_electronic",//"全电专用发票"
-             '22'=>"fully_digitalized_normal_electronic",//"全电普通发票"
-
-        ];
+    protected $invoiceType;
+
+    protected $invName;
 //
 //    发票状态,取值范围:
 //
 //    正常:valid
 //    已作废:invalidated
 //    已红冲:reversed
-    public $invStatus=["valid"=>'正常',"invalidated"=>'已作废',"reversed"=>'已红冲'];
-    public function __construct(App $app) {parent::__construct($app);}
+    protected $invStatus=["valid"=>'正常',"invalidated"=>'已作废',"reversed"=>'已红冲'];
+    public function __construct(App $app) {
+    	parent::__construct($app);
+    	$invoice =Config::get("invoiceType");
+        $this->invoiceType = $invoice['invoiceName'];
+        $this->invName = $invoice['invoiceType'];
+    }
     /**
      *付款详细列表
      * @return \think\Response
@@ -985,44 +966,38 @@ class Payment extends BaseController
         if($payinfo['status']!=2){
             return error_show(1004,"对账单数据未完成审核");
         }
-//        $type = isset($post['invType']) && $post['invType']!="" ? intval($post['invType']):"";
-//        if($type==''){
-//           return error_show(1004,"参数 invType 不能为空");
-//        }
 
         $invArr=isset($post['invArr']) && !empty($post['invArr']) ? $post['invArr'] :'';
         if($invArr==''|| empty($invArr)){
         	 return error_show(1004,"参数 invArr 不能为空");
         }
-
-
 		$daList=[];
 		foreach ($invArr as $item){
 			if(!isset($item['invType'])||$item['invType']=='') return error_show(1004,"参数 invType 不能为空");
+			if(in_array($item['invoiceType'],['fully_digitalized_special_electronic','fully_digitalized_normal_electronic']) && $item['invType']!=1){
+					return error_show(1004,"全电发票暂不支持图片识别");
+			}
 			if($item['invType']==1){
 				if(!isset($item['invoiceType'])||$item['invoiceType']=='')  return error_show(1004,"参数 invoiceType 不能为空");
-				if(!in_array($item['invoiceType'],[21,22])){
+				if (!in_array($item['invoiceType'],$this->invName))  return error_show(1004,"发票类型有误");
+				//全电票没有发票代码
+				if(!in_array($item['invoiceType'],['fully_digitalized_special_electronic','fully_digitalized_normal_electronic'])){
 					if(!isset($item['invCode'])||$item['invCode']=='')  return error_show(1004,"参数 invCode 不能为空");
 				}
 				if(!isset($item['invNumber'])||$item['invNumber']=='')  return error_show(1004,"参数 invNumber 不能为空");
 				if(!isset($item['invoiceType'])||$item['invoiceType']=='')  return error_show(1004,"参数 invoiceType 不能为空");
 				if(!isset($item['open_time'])||$item['open_time']=='')  return error_show(1004,"参数 open_time 不能为空");
 				if(!isset($item['subtotal_amount'])||$item['subtotal_amount']=='')  return error_show(1004,"参数 subtotal_amount 不能为空");
-				if(in_array($item['invoiceType'],['04','11',"10",'14'])){
+				//普票需要校验码
+				if(in_array($item['invoiceType'],['normal','roll',"toll",'electronic'])){
 					if(!isset($item['checkNumber'])||$item['checkNumber']=='')  return error_show(1004,"参数 checkNumber 不能为空");
 				}
 			}
 			if($item['invType']==2){
-				if(in_array($item['invoiceType'],[21,22])){
-					return error_show(1004,"全电发票暂不支持图片识别");
-				}
 				if(!isset($item['inv_img'])||$item['inv_img']=='')  return error_show(1004,"参数 inv_img 不能为空");
 				if(!isset($item['invName'])||$item['invName']=='')  return error_show(1004,"参数 invName 不能为空");
 			}
 			if($item['invType']==3){
-				if(in_array($item['invoiceType'],[21,22])){
-					return error_show(1004,"全电发票暂不支持图片识别");
-				}
 				if(!isset($item['inv_img'])||$item['inv_img']=='')  return error_show(1004,"参数 inv_img 不能为空");
 				if(!isset($item['invName'])||$item['invName']=='')  return error_show(1004,"参数 invName 不能为空");
 			}
@@ -1035,7 +1010,7 @@ class Payment extends BaseController
                 "inv_fee"=> 0,//核算金额
                 "inv_subtotal_amount"=> $item['subtotal_amount']??0, //票面金额
                 "invType"=> $item['invType'],
-                "invoiceType"=>key_exists($item['invoiceType'],$this->invName)?$this->invName[$item['invoiceType']]:'',
+                "invoiceType"=>$item['invoiceType'],
                 "inv_img"=>$item['inv_img']??'',
                 "invName"=>$item['invName']??'',
                 "invoiceNumber"=>$item['invNumber']??'',
@@ -1106,7 +1081,7 @@ class Payment extends BaseController
             ]);
 
             $val->extend('checkNumberCallback', function ($val, $rule, $da) {
-                if (in_array($val, ['special', 'normal', 'roll', 'special_electronic', 'electronic', 'toll'])) {
+                if (in_array($val, ['normal','roll',"toll",'electronic'])) {
                     if (empty($da)) return '电子票时校验码必填';
                 }
                 return true;

+ 51 - 0
config/invoiceType.php

@@ -0,0 +1,51 @@
+<?php
+return [
+	"invoiceType"=>[
+		     "special",//"增值税专用发票",
+             "normal",//"增值税普通发票",
+             "roll",//"增值税普通发票(卷式)",
+             "special_electronic",// "增值税电子专用发票",
+             "electronic",//"增值税电子普通发票",
+             "toll",//"增值税电子普通发票(通行费)"
+             "fully_digitalized_special_electronic",//"全电专用发票"
+            "fully_digitalized_normal_electronic",//"全电普通发票"
+            ],
+    "invoiceName"=>[
+    	"special"=>"增值税专用发票",
+        "normal"=>"增值税普通发票",
+        "roll"=>"增值税普通发票(卷式)",
+        "special_electronic"=>"增值税电子专用发票",
+        "electronic"=>"增值税电子普通发票",
+        "toll"=>"增值税电子普通发票(通行费)",
+        "fully_digitalized_special_electronic"=>"全电专用发票",
+        "fully_digitalized_normal_electronic"=>"全电普通发票",
+		],
+	//金税开票发票类型代码
+	"KingInvoice"=>[
+		"special"=>"004",
+        "normal"=>"007",
+        "roll"=>"", //暂无
+        "special_electronic"=>"028",
+        "electronic"=>"026",
+        "toll"=>"",//暂无
+        "fully_digitalized_special_electronic"=>"021",
+        "fully_digitalized_normal_electronic"=>"022",
+        ],
+        //金税类型名称
+	"KingName"=>[
+		"004"=>"增值税专用发票",
+		'007'=>"增值税普通发票",
+		'026'=>'增值税电子普通发票',
+		'028'=>'增值税电子专用发票',
+		'021'=>"全电专用发票",
+		'022'=>"全电普通发票"
+		],
+	"KingInv"=>[
+		"004"=>"special",
+		'007'=>"normal",
+		'026'=>'electronic',
+		'028'=>'special_electronic',
+		'021'=>"fully_digitalized_special_electronic",
+		'022'=>"fully_digitalized_normal_electronic"
+		]
+];