wugg 5 months ago
parent
commit
b95d3b8910

+ 1 - 1
app/admin/command/CheckInvoice.php

@@ -27,11 +27,11 @@ class CheckInvoice extends Command
     protected function execute(Input $input, Output $output)
     protected function execute(Input $input, Output $output)
     {
     {
         $this->datetime = date("Y-m-d");
         $this->datetime = date("Y-m-d");
+        if(Cache::get('checkInvoiceP')==1)return;
         $list = $this->getInvoice();
         $list = $this->getInvoice();
         $invoice =Config::get('invoiceType');
         $invoice =Config::get('invoiceType');
         $this->InvoiceNum = $invoice['KingInvoice'];
         $this->InvoiceNum = $invoice['KingInvoice'];
         $this->output=$output;
         $this->output=$output;
-        if(Cache::get('checkInvoiceP')==1)return;
         while ($list->valid()){
         while ($list->valid()){
             Cache::set('checkInvoiceP',1,1800);
             Cache::set('checkInvoiceP',1,1800);
              $invoice = $list->current();
              $invoice = $list->current();

+ 0 - 2
app/admin/controller/Base.php

@@ -132,9 +132,7 @@ class Base extends BaseController
 	                if ($db['code'] != 0) $this->error($db['message'],$db['code']);
 	                if ($db['code'] != 0) $this->error($db['message'],$db['code']);
 	                if (!empty($db['data']) && $db['data']['count'] > 0) {
 	                if (!empty($db['data']) && $db['data']['count'] > 0) {
 	                	$this->error("供应商公司存在操作账户,请用供应商账户操作");
 	                	$this->error("供应商公司存在操作账户,请用供应商账户操作");
-//	                    return error_show(1004,"供应商公司存在操作账户,请用供应商账户操作");
 	                }
 	                }
-
                 }
                 }
             }
             }
         }
         }

+ 3 - 12
app/admin/controller/Payment.php

@@ -1893,22 +1893,13 @@ class Payment extends Base
                        if($report)$report->rmField("hpNo",$hpNo);
                        if($report)$report->rmField("hpNo",$hpNo);
                     }
                     }
                 }
                 }
-                if($payinv['status']==3||$payinv['status']==2){
+                if(in_array($payinv['status'], [1,2,3,11,12])){
                     if($payinfo['inv_fee']< $payinv['inv_fee']){
                     if($payinfo['inv_fee']< $payinv['inv_fee']){
                         Db::rollback();
                         Db::rollback();
                         return error_show(1005,"对账回票申请金额有误,请确认回票申请金额");
                         return error_show(1005,"对账回票申请金额有误,请确认回票申请金额");
                     }
                     }
-                     $payupdate =[
-                            "inv_fee"=>$payinfo['inv_fee']-$payinv['inv_fee'],
-                            "winv_fee"=>$payinfo['winv_fee']+$payinv['inv_fee'],
-                            'inv_status' => ($payinfo['ainv_fee']-$payinv['inv_fee'])==0?1:2,
-                             "updatetime" => date("Y-m-d H:i:s")
-                        ];
-                        $pay =Db::name("pay")->where($payinfo)->update($payupdate);
-                        if($pay==false){
-                            Db::rollback();
-                            return error_show(1003,"删除失败");
-                     }
+                       Pay::subInv($payinfo['payNo'],$payinv['inv_fee']);
+                        if(in_array($payinv['status'], [2,3,12])) \app\admin\model\InvoiceItem::rmInvoice($param['hpNo']);
                       foreach ($cgdNo as $value){
                       foreach ($cgdNo as $value){
                        $report=ReportCode::where(["cgdNo"=>$value])->find();
                        $report=ReportCode::where(["cgdNo"=>$value])->find();
                        if($report)$report->rmField("hpNo",$hpNo);
                        if($report)$report->rmField("hpNo",$hpNo);

+ 46 - 23
app/admin/controller/Sale.php

@@ -3,7 +3,7 @@
 
 
 namespace app\admin\controller;
 namespace app\admin\controller;
 
 
-use app\admin\model\CgdInfo;use app\admin\model\GoodCombind;use app\admin\model\InvoicePool;use app\admin\model\OrderCategory;use app\admin\model\Pay;use app\admin\model\QrdInfo;use app\admin\model\TradePool;use think\App;
+use app\admin\model\CgdInfo;use app\admin\model\GoodCombind;use app\admin\model\InvoiceOrder;use app\admin\model\InvoicePool;use app\admin\model\OrderCategory;use app\admin\model\Pay;use app\admin\model\PayInvoice;use app\admin\model\QrdInfo;use app\admin\model\TradePool;use think\App;
 use think\facade\Db;use think\facade\Validate;
 use think\facade\Db;use think\facade\Validate;
 class Sale extends Base{
 class Sale extends Base{
     public function __construct(App $app) {
     public function __construct(App $app) {
@@ -345,8 +345,6 @@ class Sale extends Base{
         $data=[];
         $data=[];
         foreach ( $list as $ky=>$value){
         foreach ( $list as $ky=>$value){
             $value['catInfo'] = json_decode($value['catInfo'],true);
             $value['catInfo'] = json_decode($value['catInfo'],true);
-            $value['goodNum'] = $value['goodNum'] -$value['thNum'];
-            $value['sendNum'] = $value['sendNum'] -$value['thNum'];
             $value['inv_tag_name']='';
             $value['inv_tag_name']='';
                             $value['pay_tag_name']='';
                             $value['pay_tag_name']='';
                             $value['pay_tag_img']='';
                             $value['pay_tag_img']='';
@@ -547,6 +545,15 @@ class Sale extends Base{
 			            }
 			            }
 			            
 			            
 		           }
 		           }
+
+		           $InvoiceOrder = InvoiceOrder::with(['ItemInfo'])->where(["code"=>$cgdinfo['sequenceNo'],"status"=>[1,2]])->select();
+		           if($InvoiceOrder->isEmpty()==false){
+		               foreach ($InvoiceOrder as $item){
+		                        $hp = PayInvoice::where(['hpNo'=>$item->ItemInfo->invoiceCode])->findOrEmpty();
+			               	    $data[]=['type'=>'发票池关联采购单','username'=> $hp['apply_name'],'orderCode'=>$hp['hpNo'],'companyName'=>$cgdinfo['companyName']];
+			               }
+
+		           }
 	           }
 	           }
 	           if($post['isCgd']==1){
 	           if($post['isCgd']==1){
 			           $cgdinfo =Db::name('cgd_info')->where(['qrdCode'=>$post['orderCode'],'is_del'=>0])->field('sequenceNo,companyName')->findOrEmpty();
 			           $cgdinfo =Db::name('cgd_info')->where(['qrdCode'=>$post['orderCode'],'is_del'=>0])->field('sequenceNo,companyName')->findOrEmpty();
@@ -570,28 +577,44 @@ class Sale extends Base{
 						                }
 						                }
 						            }
 						            }
 				            }
 				            }
+				           $InvoiceOrder = InvoiceOrder::with(['ItemInfo'])->where(['code'=>$cgdinfo['sequenceNo'],'status'=>[1,2]])->select();
+                           if($InvoiceOrder->isEmpty()==false){
+                               foreach ($InvoiceOrder as $item){
+                                        $hp = PayInvoice::where(['hpNo'=>$item->ItemInfo->invoiceCode])->findOrEmpty();
+                                        $data[]=['type'=>'发票池关联采购单','username'=> $hp['apply_name'],'orderCode'=>$hp['hpNo'],'companyName'=>$cgdinfo['companyName']];
+                                   }
+
+                           }
 							$comoOrder = CgdInfo::where(['mainCode'=>$cgdinfo['sequenceNo'],'is_comon'=>2,'status'=>1])->field('sequenceNo,companyName')->findOrEmpty();
 							$comoOrder = CgdInfo::where(['mainCode'=>$cgdinfo['sequenceNo'],'is_comon'=>2,'status'=>1])->field('sequenceNo,companyName')->findOrEmpty();
 				             if(!empty($comoOrder)){
 				             if(!empty($comoOrder)){
-				             							$payNo = Db::name('pay_info')->where(['cgdNo'=>$comoOrder['sequenceNo'],'status'=>1,'is_del'=>0])->value('payNo','');
-				             				           if($payNo!=''){
-				             				           	 $uname = Pay::where('payNo',$payNo)->value('apply_name','');
-				             				                $data[]=['type'=>'源头采购对账单','username'=> $uname,'orderCode'=>$payNo,'companyName'=>$comoOrder['companyName']];
-				             				                
-				             				                 $hp = Db::name('pay_invoice')->where(['payNo'=>$payNo,'is_del'=>0,'status'=>[1,2,3,4]])
-											                ->column('hpNo,apply_name');
-												            if(!empty($hp)){
-												                foreach ($hp as $item){
-												                    $data[]=['type'=>'源头采购对账单回票','username'=> $item['apply_name'],'orderCode'=>$item['hpNo'],'companyName'=>$cgdinfo['companyName']];
-												                }
-												            }
-												            $paydz = Db::name('pay_payment')->where(['payNo'=>$payNo,'is_del'=>0,'status'=>[1,2,3,4]])
-												            ->column('dzNo,apply_name');
-												             if(!empty($paydz)){
-												                foreach ($paydz as $item){
-												                    $data[]=['type'=>'源头采购对账单付款','username'=> $item['apply_name'],'orderCode'=>$item['dzNo'],'companyName'=>$cgdinfo['companyName']];
-												                }
-												            }
-				             				            }
+                                    $payNo = Db::name('pay_info')->where(['cgdNo'=>$comoOrder['sequenceNo'],'status'=>1,'is_del'=>0])->value('payNo','');
+                                   if($payNo!=''){
+                                     $uname = Pay::where('payNo',$payNo)->value('apply_name','');
+                                        $data[]=['type'=>'源头采购对账单','username'=> $uname,'orderCode'=>$payNo,'companyName'=>$comoOrder['companyName']];
+
+                                         $hp = Db::name('pay_invoice')->where(['payNo'=>$payNo,'is_del'=>0,'status'=>[1,2,3,4]])
+                                        ->column('hpNo,apply_name');
+                                        if(!empty($hp)){
+                                            foreach ($hp as $item){
+                                                $data[]=['type'=>'源头采购对账单回票','username'=> $item['apply_name'],'orderCode'=>$item['hpNo'],'companyName'=>$cgdinfo['companyName']];
+                                            }
+                                        }
+                                        $paydz = Db::name('pay_payment')->where(['payNo'=>$payNo,'is_del'=>0,'status'=>[1,2,3,4]])
+                                        ->column('dzNo,apply_name');
+                                         if(!empty($paydz)){
+                                            foreach ($paydz as $item){
+                                                $data[]=['type'=>'源头采购对账单付款','username'=> $item['apply_name'],'orderCode'=>$item['dzNo'],'companyName'=>$cgdinfo['companyName']];
+                                            }
+                                        }
+                                    }
+                                   $InvoiceOrder = InvoiceOrder::with(['ItemInfo'])->where(['code'=>$comoOrder['sequenceNo'],'status'=>[1,2]])->select();
+                                  if($InvoiceOrder->isEmpty()==false){
+                                      foreach ($InvoiceOrder as $item){
+                                               $hp = PayInvoice::where(['hpNo'=>$item->ItemInfo->invoiceCode])->findOrEmpty();
+                                               $data[]=['type'=>'发票池关联源头采购单','username'=> $hp['apply_name'],'orderCode'=>$hp['hpNo'],'companyName'=>$comoOrder['companyName']];
+                                          }
+
+                                  }
 				              }
 				              }
 			           }
 			           }
 		           }
 		           }

+ 2 - 0
app/admin/listener/ComonQrd.php

@@ -67,6 +67,7 @@ class ComonQrd
 		                ];
 		                ];
 		            $qrd=[
 		            $qrd=[
 		                'id'=>$item->id,
 		                'id'=>$item->id,
+		                'apay_fee'=>$item->apay_fee,
 			            'wpay_fee'=>$item->wpay_fee,
 			            'wpay_fee'=>$item->wpay_fee,
 			            'pay_status'=>$item->pay_status,
 			            'pay_status'=>$item->pay_status,
 			            'pay_tag_fee'=>$item->pay_tag_fee,
 			            'pay_tag_fee'=>$item->pay_tag_fee,
@@ -129,6 +130,7 @@ class ComonQrd
     	    }
     	    }
     		$qrd=[
     		$qrd=[
     			"id"=>$item->id,
     			"id"=>$item->id,
+    			'apay_fee'=>$item->apay_fee,
 	            "wpay_fee"=>$item->wpay_fee,
 	            "wpay_fee"=>$item->wpay_fee,
 	            "pay_status"=>$item->pay_status,
 	            "pay_status"=>$item->pay_status,
 	            "pay_tag_fee"=>0,
 	            "pay_tag_fee"=>0,