Browse Source

Merge branch 'dev-wgg' of wugg/cxinv into dev

wugg 1 year ago
parent
commit
24afd4960d

+ 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]);
+	}
 }

+ 7 - 7
app/admin/controller/InvCat.php

@@ -9,7 +9,7 @@ use think\facade\Db;
 use think\facade\Validate;
 
 class InvCat extends BaseController{
-	private $Tax=[1=>"免税",2=>"不征税",3=>"零税率"];
+	private $Tax=[0=>'',1=>"免税",2=>"不征税",3=>"零税率"];
     public function __construct(App $app) {parent::__construct($app);}
     //商品关联开票类目
     public function AddGood(){
@@ -36,7 +36,7 @@ class InvCat extends BaseController{
             $tax=str_replace("%","",$tax)/100;
 			$invTag=isset($this->post['inv_tag'])&& $this->post['inv_tag']!==''?intval($this->post['inv_tag']):0;
 			$is_discount=isset($this->post['is_discount'])&& $this->post['is_discount']!==''?intval($this->post['is_discount']):0;
-			$addTax=isset($this->post['addTax'])&& $this->post['addTax']!==''?trim($this->post['addTax']):'';
+			$addTax=isset($this->post['addTax'])&& $this->post['addTax']!==''?intval($this->post['addTax']):0;
 			if($is_discount==1){
 //				1.如果YHZCBS为1, 则ZZSTSGL必须填; 如果YHZCBS为0,ZZSTSGL不填。
 //				2.如果YHZCBS为1, 且税率为0, 则LSLBS只能根据实际情况选择"1或2"中的一种, 不能选择3, 且ZZSTSGL内容也只能写与1/2对应的"免税/不征税";
@@ -51,7 +51,7 @@ class InvCat extends BaseController{
 					if($addTax==''){
 						return error_show(1004,"参数 addTax 不能为空");
 					}
-					if($addTax!=$this->Tax[$invTag]){
+					if($addTax!=$invTag){
 					return error_show(1004,"税率标识与增值税管理内容不符");
 					}
 				}
@@ -74,7 +74,7 @@ class InvCat extends BaseController{
                 "inv_good_name"=>$inv_good_name,
                 "inv_tag"=>$invTag,
                 "is_discount"=>$is_discount,
-                "addTax"=>$addTax,
+                "addTax"=>$this->Tax[$addTax],
                 "status"=>1,
                 "updatetime"=>date("Y-m-d H:i:s")
             ];
@@ -110,9 +110,9 @@ class InvCat extends BaseController{
         $page = $page>=$total? intval($total):$page;
         $list =Db::name("good")->where($condition)->order("id desc")->page($page,$size)->select()->toArray();
         foreach ($list as &$value){
-            $company =Db::name("supplier_info")->where(["code"=>$value['companyNo']])->find();
-            $value['companyName']=$company['name']??"";
-            $supplier =Db::name("supplier_info")->where(["code"=>$value["supplierNo"]])->find();
+            $company =Db::name("company_info")->where(["companyNo"=>$value['companyNo']])->findOrEmpty();
+            $value['companyName']=$company['company_name']??"";
+            $supplier =Db::name("supplier_info")->where(["code"=>$value["supplierNo"]])->findOrEmpty();
             $value["supplierName"]=$supplier["name"]??"";
         }
         return app_show(0,"获取成功",["list"=>$list,"count"=>$count]);

+ 13 - 5
app/admin/controller/OrderInv.php

@@ -616,13 +616,18 @@ class OrderInv extends BaseController{
 	* @throws \think\db\exception\DbException
 	 */
     public function batchCheck(){
-    	$param =$this->request->only(["invNos"=>[],"status"=>''],"post");
-    	$valid=Validate::rule(["invNos|发票编号"=>"require|array","status|审核状态"=>"require|number|in:2,8"]);
+    	$param =$this->request->only(["invNos"=>[],"status"=>'',"open_type"=>0],"post");
+    	$valid=Validate::rule([
+    		"invNos|发票编号"=>"require|array",
+    	    "status|审核状态"=>"require|number|in:2,8",
+    	    "open_type|审核状态"=>"require|number|in:0,1,2,3",
+    	    ]);
     	if($valid->check($param)==false) return error_show(1004,$valid->getError());
     	$list =Db::name("invoice_pool")->where(["invNo"=>$param['invNos'],"status"=>1,"is_del"=>0])->column("id");
     	if(empty($list)) return error_show(1004,"未找到有效数据");
-		$up =Db::name("invoice_pool")->where(["id"=>$list,"status"=>1,"is_del"=>0])->update(["status"=>2,
-		"updatetime"=>date("Y-m-d H:i:s")]);
+		$up =Db::name("invoice_pool")
+		->where(["id"=>$list,"status"=>1,"is_del"=>0])
+		->update(["status"=>$param['status'],"open_type"=>$param['open_type'],"updatetime"=>date("Y-m-d H:i:s")]);
 		if($up==false) return error_show(1004,"数据审核失败");
 		 return app_show(0,"数据审核成功");
     }
@@ -1471,6 +1476,9 @@ class OrderInv extends BaseController{
         ->where($condition)->field("a.id,
 						a.invNo,
 						a.platform_type,
+						a.open_type,
+						a.is_ticket,
+						a.tag_id,
 						a.apply_id,
 						a.apply_name,
 						a.status,
@@ -2141,7 +2149,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']]??"";

+ 1 - 1
app/command/Report.php

@@ -944,7 +944,7 @@ class Report extends Command
 
 	//采购部门销售业绩
 	private function R($param=[]){
-		$where = [["a.is_del","=",0],["a.status","=",2],["b.is_stock","=",0]];
+		$where = [["a.is_del","=",0],["a.status","in",[2,3]],["b.is_stock","=",0]];
 		if (($param['start'] != '') && ($param['end'] != '')) $where[] = ['a.sendtime', 'between', [date("Y-m-d 00:00:00",
 		strtotime($param['start'])),date("Y-m-d 23:59:59",strtotime($param['end']))]];
 //		if ($param['companyNo'] != '') $where[] = ['supplierNo', '=', $param['companyNo']];