wugg 1 vuosi sitten
vanhempi
commit
982fe9d25b
2 muutettua tiedostoa jossa 23 lisäystä ja 6 poistoa
  1. 22 5
      app/admin/command/downredinvres.php
  2. 1 1
      app/admin/controller/OrderInv.php

+ 22 - 5
app/admin/command/downredinvres.php

@@ -41,10 +41,13 @@ class downredinvres extends Command
 		$invoice=Config::get("invoice");
 		$Tax =new \TaxInvoice($invoice['appKey'],$invoice['appSecret'],$invoice['entCode']);
 		if($row['addtime']==$row['updatetime']){
-			$row['SQBSCQQPCH']=randomkeys(26).date("YmdHis");
+			$pch=randomkeys(26).date("YmdHis");
+			$data['SQBSCQQPCH']=$pch;
+		}else{
 			$data['SQBSCQQPCH']=$row['SQBSCQQPCH'];
 		}
-		$result=$Tax->DownloadRedInvoiceApplicationResult($row['SQBSCQQPCH'],$row['XHFSBH'],$row['FPLXDM'],$opendatetime,$opendatetime);
+
+		$result=$Tax->DownloadRedInvoiceApplicationResult($data['SQBSCQQPCH'],$row['XHFSBH'],$row['FPLXDM'],$opendatetime,$opendatetime);
 		if(isset($result['ZTDM']) && $result['ZTDM']=='060000'){
 			if(isset($result['HZSQDXZZXX']) && !empty($result['HZSQDXZZXX'])){
 				foreach ($result['HZSQDXZZXX'] as $item){
@@ -64,8 +67,9 @@ class downredinvres extends Command
 					}
 					$where=["YFPDM"=>$resultChild['YFPDM'],"YFPHM"=>$resultChild['YFPHM'],"status"=>1];
 					$row= Db::name("invoice_red")->where($where)->update($data);
-					if($row && $data['status']==2 ){
-						$this->AddRed($resultChild['YFPDM'],$resultChild['YFPHM']);
+					if($row){
+						if($data['status']==2)$this->AddRed($resultChild['YFPDM'],$resultChild['YFPHM']);
+						if($data['status']==5)$this->updateReturn($resultChild['YFPDM'],$resultChild['YFPHM'],$resultChild['ZTXX']);
 					}
 				}
 			}
@@ -82,7 +86,7 @@ class downredinvres extends Command
         }
 
     }
-
+	//立即提交红冲开票
 	public function AddRed($fpdm,$fphm){
     	$cod=["YFPDM"=>$fpdm,"YFPHM"=>$fphm,"status"=>2,"is_del"=>0];
     	$red=Db::name("invoice_red")->where($cod)->findOrEmpty();
@@ -145,4 +149,17 @@ class downredinvres extends Command
 			}
 			Db::name("invoice_red")->where($red)->update(["status"=>3,"updatetime"=>date("Y-m-d H:i:s"),"remark"=>"红冲开票申请已提交待开票"]);
 	}
+
+	/**红冲申请失败退票信息失败
+	 * @param        $fpdm
+	 * @param        $fphm
+	 * @param string $remark
+	 * @throws \think\db\exception\DbException
+	 */
+	public function updateReturn($fpdm,$fphm,$remark=''){
+		$where=["YFPDM"=>$fpdm,"YFPHM"=>$fphm,"status"=>5];
+		$fp = Db::name("invoice_red")->where($where)->findOrEmpty();
+		if(empty($fp)) throw new \Exception("未找到红票申请信息表");
+		Db::name("invoice_return")->where(["returnCode"=>$fp['returnCode'],"status"=>1])->update(["status"=>4,"updatetime"=>date("Y-m-d H:i:s"),"remark"=>$remark]);
+	}
 }

+ 1 - 1
app/admin/controller/OrderInv.php

@@ -2141,7 +2141,7 @@ class OrderInv extends BaseController{
 		$info =Db::name("invoice_ticket")->json(['item'])->withoutField("pdfstream")->where($condition)->findOrEmpty();
 		if(!empty($info)&& isset($info['item'])){
 			array_walk($info['item'],function (&$value){
-					$value['SL'] = ($value['SL']*100)."%";
+					if(stripos($value["SL"],"%")==false)$value['SL'] =  ($value['SL']*100)."%";
 			});
 		}
 		$info['invtype_name'] = $this->typename[$info['inv_type']]??"";