Browse Source

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

wugg 1 năm trước cách đây
mục cha
commit
294c9381dc

+ 21 - 5
app/admin/command/GetOrderInfoAndInvoiceInfo.php

@@ -172,7 +172,23 @@ class GetOrderInfoAndInvoiceInfo extends Command
 				$invinfo =Db::name('invoice_red')->where(['invRed'=>$invNo,'is_del'=>0])->findOrEmpty();
 				$invNo = $invinfo['invNo']??'';
 				if(!key_exists('ZXBM' , $data[0])){
-					$data = $invinfo['DDMXXX']?json_decode($invinfo['DDMXXX'],true):[];
+					$data  =Db::name('invoice_good')
+            		->where(['invNo'=>$invNo,'is_del'=>0])
+            		->field("0 as FPHXZ,
+									catNo  as SPBM,
+									id as ZXBM,
+									is_discount as YHZCBS,
+									if(inv_tag=0,'',inv_tag) as  LSLBS,
+									addTax	as ZZSTSGL,
+									goodName as XMMC,
+									'' as DW,
+									'' as SPSL,
+									'' as DJ,
+									(-totalPrice) as JE,
+									0 HSBZ,
+									tax as SL,
+									-taxPrice as SE")->select()->toArray();
+//					$data = $invinfo['DDMXXX']?json_decode($invinfo['DDMXXX'],true):[];
 				}
 			}
 			foreach ($data as $value){
@@ -180,11 +196,11 @@ class GetOrderInfoAndInvoiceInfo extends Command
 					$invinfo =Db::name("invoice_good")->where(["invNo"=>$invNo,"id"=>$value['ZXBM'],'is_del'=>0])->findOrEmpty();
 					if(empty($invinfo)) continue;
 					if($status==4){
-					$invinfo['goodPrice'] = $value['DJ'];
-					$invinfo['totalPrice'] = $value['JE'];
-					$invinfo['taxPrice'] = $value['SE'];
+						$invinfo['goodPrice'] = $value['DJ'];
+						$invinfo['totalPrice'] = $value['JE'];
+						$invinfo['taxPrice'] = $value['SE'];
 					}else{
-					$invinfo['goodNum'] =0;
+						$invinfo['goodNum'] =0;
 					}
 					$invinfo['updatetime'] = date("Y-m-d H:i:s");
 					Db::name("invoice_good")->save($invinfo);

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

@@ -83,7 +83,9 @@ class downredinvres extends Command
 			}
 		}else{
 			$data['remark']=$result['ZTXX'];
+			$data['status']=5;
 			Db::name("invoice_red")->where(["id"=>$row['id']])->update($data);
+			$this->updateReturn($row['returnCode'],$result['ZTXX']);
 		}
 
 		Db::commit();
@@ -164,11 +166,8 @@ class downredinvres extends Command
 	 * @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]);
+	public function updateReturn($returnCode,$remark=''){
+		Db::name("invoice_return")->where(["returnCode"=>$returnCode,"status"=>1])->update(["status"=>4,"updatetime"=>date("Y-m-d H:i:s"),"remark"=>$remark]);
 	}
 	
 	
@@ -178,7 +177,7 @@ class downredinvres extends Command
 			$row=Db::name('invoice_red')->where($where)->update($resultChild);
 			if ($row) {
 				if ($resultChild['status'] == 2) $this->AddRed($resultChild['YFPDM'] , $resultChild['YFPHM']);
-				if ($resultChild['status'] == 5) $this->updateReturn($resultChild['YFPDM'] , $resultChild['YFPHM'] ,$resultChild['remark']);
+				if ($resultChild['status'] == 5) $this->updateReturn($row['returnCode'] ,$resultChild['remark']);
 			}
 		}
 	

+ 1 - 22
app/admin/controller/InvCat.php

@@ -128,7 +128,7 @@ class InvCat extends BaseController{
             $supplier =Db::name("supplier_info")->where(["code"=>$goodinfo["supplierNo"]])->find();
             $goodinfo["supplierName"]=$supplier["name"]??"";
 
-            return app_show(0,"获取成功",$goodinfo);
+        return app_show(0,"获取成功",$goodinfo);
     }
     //发票类目列表
     public function catlist(){
@@ -194,7 +194,6 @@ class InvCat extends BaseController{
         ]);
 
         Db::startTrans();
-
         try {
 
             $all_spuCode = Db::name('good')
@@ -214,26 +213,6 @@ class InvCat extends BaseController{
                 if (!in_array($value['tax'], $all_cat_code[$value['cat_code']]['tax'] != '' ? explode('、', $all_cat_code[$value['cat_code']]['tax']) : [])) throw new Exception($value['tax'].'未找到对应的开票类目税率');
                 $value['tax'] = str_replace('%', '', $value['tax']);
                 $value['tax'] = round(bcdiv($value['tax'], 100, 3), 2);
-
-//
-//                if ($value['is_discount'] == 1) {
-//                    // 优惠政策下 税率标识只能选择 0非零说率 1免税 2不征税 增值税管理为空"出口零税/免税/不征税"
-//                    if($value['tax'] == 0){
-//                    	if ( $value['inv_tag'] == 3) throw new Exception($value['spuCode'].'税率标识不能选择零税率');
-//                        if ($value['addTax'] == '') throw new Exception($value['spuCode'].'参数 addTax 不能为空');
-//                        if($value['addTax']!=$this->Tax[$value['inv_tag']]){
-//                        	throw new Exception($value['spuCode'].'税率标识与增值税管理内容不符');
-//						}
-//                    }
-//
-//
-//                } else {
-//                    // 非优惠政策下 零税率 税率标识只能选择 3 普通零税率  增值税管理为空
-//                    // 非优惠政策下 非零税率 税率标识只能选择 0 非零税率  增值税管理为空
-//                    if ($value['tax'] == 0 && $value['inv_tag'] != 3) throw new Exception($value['spuCode'].'税率标识只能选择零税率');
-//					$value['addTax'] = '';
-//                }
-
                 if($value['is_discount'] ==1){
 //				1.如果YHZCBS为1, 则ZZSTSGL必须填; 如果YHZCBS为0,ZZSTSGL不填。
 //				2.如果YHZCBS为1, 且税率为0, 则LSLBS只能根据实际情况选择"1或2"中的一种, 不能选择3, 且ZZSTSGL内容也只能写与1/2对应的"免税/不征税";

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

@@ -251,6 +251,7 @@ class OrderInv extends BaseController{
    }
     //   1财务审核通过 2 金税开票中/验票中 3 开票成功 4 财务驳回 5 开票失败 6 发票退票/废弃 7取消申请
     //   1财务审核通过 2 待财务上传发票 3 金税开票中/验票中 4 开票成功  5 开票失败 6发票退票/废弃 7取消申请 8 财务驳回 9验票失败
+
    public  function  status(){
         $invNo = isset($this->post['invNo'])&&$this->post['invNo']!=''?trim($this->post['invNo']):"";
         if($invNo==""){
@@ -939,7 +940,9 @@ class OrderInv extends BaseController{
             if($up){
             	if($status==1){
             		if($return_type==1){
+            			//普票
 	                    if(in_array($ticket['inv_type'],['007','026'])) $result= $this->addRedOpen($ticket,$return_reason,$invinfo['company_type'],$returnCode,$red_desc);
+	                    //专票
 	                    if(in_array($ticket['inv_type'],['004','028'])) $result= $this->addApplyRed($ticket,$return_reason,$returnCode,$red_desc);
 						if(isset($result['code'])){
 							if(isset($result['data']) &&$result['invRed']!='' ){
@@ -1079,7 +1082,6 @@ class OrderInv extends BaseController{
 									-taxPrice as SE")->select()->toArray();
 					if(empty($goodinfo)){
 						throw new \Exception("开票商品信息未找到", 10006);
-
 					}
 		if(count($goodinfo)>8){
 		$len =array_unique(array_column($goodinfo,'SL'));
@@ -1485,6 +1487,17 @@ class OrderInv extends BaseController{
         if($inv_type!==""){
            $condition[]=["a.inv_type","=",$inv_type];
         }
+        
+        $inv_lower = isset($this->post['inv_lower'])&&$this->post['inv_lower']!=='' ? floatval($this->post['inv_lower'])
+        :'';
+        if($inv_lower!==''){
+           $condition[]=['a.inv_value','>=',$inv_lower];
+        }
+        $inv_uper = isset($this->post['inv_uper'])&&$this->post['inv_uper']!=='' ? floatval($this->post['inv_uper'])
+        :'';
+        if($inv_uper!==''){
+           $condition[]=['a.inv_value','<=',$inv_uper];
+        }
         $inv_out= isset($this->post['inv_out'])&&$this->post['inv_out']!=="" ? trim($this->post['inv_out']):"";
         if($inv_out!==""){
            $condition[]=["a.inv_out","=",$inv_out];
@@ -1493,10 +1506,6 @@ class OrderInv extends BaseController{
         if($platform_type!==""){
            $condition[]=["a.platform_type","=",$platform_type];
         }
-//          $inv_in = isset($this->post['inv_in'])&&$this->post['inv_in']!=="" ? trim($this->post['inv_in']):"";
-//        if($inv_in!==""){
-//           $condition[]=["a.inv_in","=",$inv_in];
-//        }
          $invNo = isset($this->post['invNo'])&&$this->post['invNo']!=="" ? trim($this->post['invNo']):"";
         if($invNo!==""){
            $condition[]=["a.invNo","like","%$invNo%"];

+ 10 - 2
app/admin/controller/Payment.php

@@ -937,7 +937,9 @@ class Payment extends BaseController
 
         //校验是否开通了供应商账号
         $supp_account = check_has_account_by_supplierNos(array_unique(array_column($list,'supplierNo')));
+        $payArr=Db::name('supplier_info')->whereIn('code',array_unique(array_column($list,'supplierNo')))->column('pay_method','code');
         foreach ($list as &$value){
+        	$value["pay_type"]=$payArr[$value['supplierNo']]??"";
         	$value['goodNum'] =$value['goodNum']- $value['thNum'];
         	$value['sendNum'] =$value['sendNum']- $value['thNum'];
             $value['has_account'] = (int)isset($supp_account['data'][$value['supplierNo']]);
@@ -981,6 +983,10 @@ class Payment extends BaseController
             }
         }
         $list =  Db::name("cgd_info")->where($condition)->order('createdTime desc')->select()->toArray();
+         $payArr=Db::name('supplier_info')->whereIn('code',array_unique(array_column($list,'supplierNo')))->column('pay_method','code');
+        foreach ($list as &$value){
+        	$value['pay_type']=$payArr[$value['supplierNo']]??'';
+        }
          return app_show(0,"获取成功",$list);
     }
     //采购单信息
@@ -995,9 +1001,10 @@ class Payment extends BaseController
             return error_show(1004,"采购单信息未找到");
         }
         $cgdinfo['catInfo'] = json_decode($cgdinfo['catInfo'],true);
-             $payinfo =Db::name("pay_info")->alias("a")->leftJoin("pay b","a.payNo=b.payNo")
+        $payinfo =Db::name("pay_info")->alias("a")->leftJoin("pay b","a.payNo=b.payNo")
         ->where(["a.is_del"=>0,"b.is_del"=>0,"a.cgdNo"=>$sequenceNo])->field("b.inv_status,b.pay_status,b.status")
         ->find();
+        $cgdinfo['pay_type']=Db::name('supplier_info')->where('code',$cgdinfo['supplierNo'])->value('pay_method','');
         $cgdinfo["cgd_pay_status"]=$payinfo['pay_status']??1;
         $cgdinfo["cgd_inv_status"]=$payinfo['inv_status']??1;
         $cgdinfo["cgd_status"]=$payinfo['status']??0;
@@ -1021,6 +1028,7 @@ class Payment extends BaseController
         foreach ($pay as &$value){
             $value['catInfo'] = json_decode($value['catInfo'],true);
         }
+        $payinfo['pay_type']=Db::name('supplier_info')->where('code',$payinfo['supplierNo'])->value('pay_method','');
         $tag =Db::name("tag_log")->alias("a")->leftJoin("order_tag b","a.tag_id=b.id")->where
             (["code"=>$payNo,"a.status"=>1])->column("b.tag_name,a.tag_img,a.tag_remark","b.type");
             $payinfo['inv_tag_name']=$tag[2]['tag_name']??'';
@@ -1297,7 +1305,7 @@ class Payment extends BaseController
     }
 
     /**
-	 * 发票审核状态
+	 * 发票审核状态     //发票验证通过 才会扣减待开票金额 失败的开票申请不用处理
 	 * 0 发票图片识别中 1待系统验证 2 买方公司审核3带买方公司认证 4 认证成功 5验证失败 6买方审核驳回 7 认证失败 8 回票流程终止 9 验证超次数 10 回票已退
      * @return \think\response\Json|void
      * @throws \think\db\exception\DataNotFoundException