wugg 6 mesiacov pred
rodič
commit
fc002e9501

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

@@ -126,7 +126,7 @@ class CheckInvoice extends Command
         $pay->save();
         $buyerCode=CompanyInfo::getRegisterCode($pay->companyNo);
         $sellerCode=SupplierInfo::getRegisterCode($pay->supplierNo);
-        PayInvoice::where(["payNo"=>$invoice['payNo'],"status"=>1])->update([
+        PayInvoice::where(["hpNo"=>$invoice['hpNo'],"status"=>1])->update([
             "status"=>11,
             "invStatus"=>$this->taxStatus[$data['zfbz']]??0,
             "check_remark"=>'',
@@ -144,8 +144,8 @@ class CheckInvoice extends Command
         if(!empty($detail)) return array_map(function ($item) {
              return [
               'name'=>$item['hwmc'],
-              'specification'=>$item['jldw'],
-              'unit'=>$item['ggxh'],
+              'specification'=>$item['ggxh'],
+              'unit'=>$item['jldw'],
               'quantity'=>$item['spsl'],
               'unit_price'=>$item['bhsdj'],
               'amount'=>$item['je'],

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

@@ -32,7 +32,7 @@ class CheckTicket extends Command
         while ($ticket->valid()) {
             Cache::set('checkTicketP',1,1800);
             $data = $ticket->current();
-            $this->output->writeln('[' . date(DATE_W3C) . ']' . $ticket['invNo'] . '验票');
+            $this->output->writeln('[' . date(DATE_W3C) . ']' . $data['invNo'] . '验票');
             $this->checkTicket($data);
             $ticket->next();
         }

+ 5 - 5
app/admin/controller/Payment.php

@@ -550,7 +550,7 @@ class Payment extends Base
        	    $stages = Db::name("pay_payment")->where(['status'=>[0,1,2,3,4],"payNo"=>$payNo,"is_del"=>0])
        	    ->findOrEmpty();
        	    if(!empty($stages)) return error_show(1004,"对账单存在未解除的付款申请单");
-       	    $hpinv = Db::name("pay_invoice")->where(['status'=>[0,1,2,3,4,9],"payNo"=>$payNo,"is_del"=>0])->findOrEmpty();
+       	    $hpinv = Db::name("pay_invoice")->where(['status'=>[0,1,2,3,4,9,11,12],"payNo"=>$payNo,"is_del"=>0])->findOrEmpty();
        	    if(!empty($hpinv)) return error_show(1004,"对账单存在未解除的回票申请单");
        	    if($data['inv_tag']==1)$this->error("存在回票标签未解除");
        	    if($data['pay_tag']==1)$this->error("存在付款标签未解除");
@@ -1488,7 +1488,7 @@ class Payment extends Base
         if ($info->isEmpty())$this->error("未找到回票申请信息");
         $payinfo = Pay::where(['payNo'=>$info['payNo'],"is_del"=>0])->findOrEmpty();
         if ($payinfo->isEmpty())$this->error("未找到对账单信息");
-        if($payinfo['status']!=2)$this->error("对账信息未完成审核");
+        if($payinfo['status']!=2&&$param['status']==3)$this->error("对账信息未完成审核");
         if($payinfo['inv_fee']< $info['inv_fee']) $this->error("回票金额不能大于对账单回票金额");
         $invup =['remark'=>$param['remark'],'updatetime'=>date('Y-m-d H:i:s')];
         if($param['status']==3) $invup['check_time']=date("Y-m-d H:i:s");
@@ -1616,7 +1616,7 @@ class Payment extends Base
     public function InvList()
     {
         $post = $this->post;
-        $condition = [["a.is_del","=",0 ],["b.is_del","=",0 ],['pay_type','=',$post['pay_type']??1]];
+        $condition = [["a.is_del","=",0 ],['a.invType','<>',4 ],["b.is_del","=",0 ],['pay_type','=',$post['pay_type']??1]];
         $invtype = isset($post['invType'])&&$post['invType']!='' ? intval($post['invType']):"";
         $check = checkRole($this->roleid,[82,120]);
         if($check){
@@ -1869,8 +1869,8 @@ class Payment extends Base
         $payinv['companyName'] = $payinfo['companyName']??'';
         $payinv['total_fee'] = $payinfo['total_fee']??'';
         $invinfo =InvoiceInfo::where(["hpNo"=>$hpNo])->findOrEmpty();
-         $payinv['invoiceType_cn'] = $this->invoiceType[$payinv['invoiceType']]??'';
-          $payinv['invStatus_cn'] = $this->invStatus[$payinv['invStatus']]??'';
+        $payinv['invoiceType_cn'] = $this->invoiceType[$payinv['invoiceType']]??'';
+        $payinv['invStatus_cn'] = $this->invStatus[$payinv['invStatus']]??'';
         $payinv["info"]=$invinfo;
         return app_show(0,'获取成功',$payinv);
     }

+ 2 - 1
app/admin/controller/Sale.php

@@ -454,7 +454,8 @@ class Sale extends Base{
             if(!$list->isEmpty()){
                $qrdinfo['child']=array_column($list->toArray(),'child');
                foreach ($qrdinfo['child'] as &$value){
-                 $value['orderTax'] = OrderCategory::where(['code' => $qrdinfo['sequenceNo'], 'spuCode' => $value['spuCode']]);
+                 $value['orderTax'] = OrderCategory::where(['code' => $qrdinfo['sequenceNo'], 'spuCode' => $value['spuCode']])
+                 ->field(['cat_code', 'cat_name', 'merge_code', 'short_name', 'tax', 'inv_good_name'])->findOrEmpty();;
                }
             }
         }             ;

+ 86 - 5
app/admin/controller/TagGood.php

@@ -210,6 +210,9 @@ class TagGood extends Base{
 	        if($taginfo['type']==3|| $taginfo['type']==4){
 		           $this->qrdTag($taginfo['type'],$code,$total_fee);
 	        }
+	        if($taginfo['type']==5|| $taginfo['type']==6){
+		           $this->cgdTag($taginfo['type'],$code,$total_fee);
+	        }
 	        $tagdata=[
 	            "code"=>$code,
 	            "tag_id"=>$tagid,
@@ -249,6 +252,10 @@ class TagGood extends Base{
 	        if($tag['type']==3|| $tag['type']==4){
 	        	$message="销售单{$loginfo->code}{$tag->tag_name}";
 		          $this->qrdReTag($tag['type'],$loginfo->code,$loginfo->tag_fee);
+	        }
+	         if($loginfo['type']==5|| $loginfo['type']==6){
+	        	 $message="采购单{$loginfo->code}{$loginfo->tag_name}";
+		          $this->cgdReTag($loginfo['type'],$loginfo->code);
 	        }
 	        $loginfo->status=0;
 	        $loginfo->id=null;
@@ -280,6 +287,10 @@ class TagGood extends Base{
 	        	$message="销售单{$loginfo->code}{$loginfo->tag_name}";
 		         $fee= $this->qrdReTag($loginfo['type'],$loginfo->code);
 	        }
+	        if($loginfo['type']==5|| $loginfo['type']==6){
+	        	 $message="采购单{$loginfo->code}{$loginfo->tag_name}";
+		         $fee= $this->cgdReTag($loginfo['type'],$loginfo->code);
+	        }
 	        $loginfo['status']=0;
 	        $loginfo['tag_fee']=$fee;
 	       unset($loginfo['addtime'],$loginfo['updatetime']);
@@ -430,18 +441,88 @@ class TagGood extends Base{
 		if($resulr==false)throw  new \Exception('销售单更新失败');
 		return $fee;
     }
-    
+
+    	/**
+	* @param $tagId 标签类型 3 回款4开票
+	* @param $code 销售单编号
+	* @param $total_fee 标签金额
+	 * @return \think\response\Json|void
+	* @throws \think\db\exception\DbException
+	 */
+    private function cgdTag($tagId,$code,$total_fee){
+    	$qrd=Db::name('cgd_info')->where(['sequenceNo'=>$code,'is_del'=>0])->findOrEmpty();
+		 if(empty($qrd)){
+		 	throw  new \Exception('未找到销售单数据');
+		 }
+		  $update=['updatetime'=>date('Y-m-d H:i:s')];
+		 if($tagId==5){
+		 	if($qrd['wpay_fee']+$qrd['pay_tag_fee']<$total_fee){
+		 		throw  new \Exception('销售单未付金额不足');
+		 	}
+		 	$update['wpay_fee']=$qrd['wpay_fee']+$qrd['pay_tag_fee']-$total_fee;
+		 	$status = $update['wpay_fee']==0 ? 3:($qrd['apay_fee']==0?1:2);
+		 	$update['pay_tag_fee'] =$qrd['pay_tag_fee']+ $total_fee;
+		 	$update['pay_status'] = $status;
+		 	$update['pay_tag'] = 1;
+		 }
+		 if($tagId==6){
+		 	if($qrd['winv_fee']+$qrd['inv_tag_fee']<$total_fee){
+		 		throw  new \Exception('销售单未开票金额不足');
+		 	}
+		 	$update['winv_fee']=$qrd['winv_fee']+$qrd['inv_tag_fee']-$total_fee;
+		 	$status = $update['winv_fee']==0 ? 3:($qrd['ainv_fee']==0?1:2);
+		 	$update['inv_tag_fee'] = $qrd['inv_tag_fee']+$total_fee;
+		 	$update['inv_status'] = $status;
+		 	$update['inv_tag'] = 1;
+		 }
+		 $resulr= Db::name('cgd_info')->where($qrd)->update($update);
+		  if($resulr==false) throw  new \Exception('标签添加失败');
+    }
+
+    /** 解除标签销售单
+	* @param $tagId 标签类型 3 回款4开票
+	* @param $code 销售单编号
+	* @param $total_fee 标签金额
+	 * @return \think\response\Json|void
+	* @throws \think\db\exception\DbException
+	 */
+    private function cgdReTag($tagId,$code){
+    	$qrd=QrdInfo::where(['sequenceNo'=>$code,'is_del'=>0])->findOrEmpty();
+		 if($qrd->isEmpty())throw  new \Exception('未找到销售单数据');
+		 $fee =0 ;
+		  if($tagId==5){
+		 	if($qrd->pay_tag_fee<0)throw  new \Exception('销售单回款标签金额不足');
+		 	 $fee =$qrd->pay_tag_fee ;
+		 	$qrd->wpay_fee=$qrd->wpay_fee+$qrd->pay_tag_fee;
+		 	$qrd->pay_tag_fee=0;
+		 	$qrd->pay_status = $qrd->wpay_fee==0?3:($qrd->apay_fee==0?1:2);
+		 	$qrd->pay_tag=0;
+		 }
+		 if($tagId==6){
+		 	if($qrd->inv_tag_fee<0)throw  new \Exception('销售单开票标签金额不足');
+		 	$fee =$qrd->inv_tag_fee ;
+		 	$qrd->winv_fee=$qrd->winv_fee+$qrd->inv_tag_fee;
+		 	$qrd->inv_tag_fee=0;
+		 	$qrd->inv_status = $qrd->winv_fee==0?3:($qrd->ainv_fee==0?1:2);
+		 	$qrd->inv_tag=0;
+		 }
+		 $resulr= $qrd->save();
+		if($resulr==false)throw  new \Exception('销售单更新失败');
+		return $fee;
+    }
     
     public function logList(){
     	$param = $this->request->param(["betweenTime"=>[],"customerNo"=>"","supplierNo"=>"",'companyNo'=>'',
     	"type"=>'',"status"=>"","orderCode"=>"","creater"=>"","order_type"=>0,"size"=>10,"page"=>1],"post","trim");
-    	$sbtable = $param['order_type']==2?'payInfo':'orderInfo';
-    	$where=[["tagInfo.type","in",$param['order_type']==2?[1,2]:[3,4]],["{$sbtable}.is_del","=",0],["tagInfo.is_del",'=',0]];
+    	$modela=['','payInfo','orderInfo','cgdInfo'];
+    	$sbtable = $modela[$param['order_type']];
+    	$type = [[],[1,2],[3,4],[5,6]];
+    	$where=[["tagInfo.type","in",$type[$param['order_type']]],["{$sbtable}.is_del","=",0],["tagInfo.is_del",'=',0]];
 
     	empty($param['betweenTime'])?:$where[]=["tag_log.addtime","between",$param['betweenTime']];
     	
-    if($param['order_type']==1)$param['customerNo']==""?:$where[]=["{$sbtable}.customerNo","like","%{$param['customerNo']}%"];
-    if($param['order_type']==2)$param['supplierNo']==""?:$where[]=["{$sbtable}.supplierNo","like","%{$param['supplierNo']}%"];
+        if($param['order_type']==1)$param['customerNo']==""?:$where[]=["{$sbtable}.customerNo","like","%{$param['customerNo']}%"];
+        if($param['order_type']!=1)$param['supplierNo']==""?:$where[]=["{$sbtable}.supplierNo","like","%{$param['supplierNo']}%"];
     	$param['companyNo']==""?:$where[]=["{$sbtable}.companyNo","like","%{$param['companyNo']}%"];
     	$param['type']==''?:$where[]=["tagInfo.type","=",$param['type']];
     	$param['status']===""?:$where[]=["tag_log.status","=",$param['status']];

+ 4 - 4
app/admin/listener/ComonQrd.php

@@ -216,10 +216,10 @@ class ComonQrd
         	if($payinvoice->isEmpty())return;
         	$payinvoice->status=10;
         	$payinvoice->save();
-         $payinfo->winv_fee = $payinfo->winv_fee+$payinvoice->inv_fee;
-         $payinfo->ainv_fee = $payinfo->ainv_fee-$payinvoice->inv_fee;
-         $payinfo->inv_status = ($payinfo->winv_fee==0 &&$payinfo->inv_fee==0)?3:($payinfo->ainv_fee==0?2:1);
-         $this->CheckComonOrder($payinfo);
+          $payinfo->winv_fee = $payinfo->winv_fee+$payinvoice->inv_fee;
+          $payinfo->ainv_fee = $payinfo->ainv_fee-$payinvoice->inv_fee;
+          $payinfo->inv_status = ($payinfo->winv_fee==0 &&$payinfo->inv_fee==0)?3:($payinfo->ainv_fee==0?2:1);
+          $this->CheckComonOrder($payinfo);
           $payinfo->save();
           $invpay->status =2;
           $invpay->save();

+ 5 - 0
app/admin/model/TagLog.php

@@ -27,4 +27,9 @@ class TagLog extends Model
         return $this->belongsTo(Pay::class,'code','payNo')
         ->bind(['companyNo','companyName','supplierNo','supplierName']);
     }
+
+    public function CgdInfo(){
+    	return $this->belongsTo(CgdInfo::class,'code','sequenceNo')
+    	->bind(['companyNo','companyName','supplierNo','supplierName']);
+    }
 }

+ 0 - 1
app/admin/route/app.php

@@ -18,7 +18,6 @@ Route::rule('menuactionstatus', 'admin/Menu/ActionStatus');
 Route::rule('menuactionadd', 'admin/Menu/ActionAdd');
 Route::rule("menulist","admin/Menu/MenuAllList");
 
-
 Route::rule('userlist', 'admin/User/userList');
 Route::rule('usersinglelist', 'admin/User/userSingleList');
 Route::rule('userall', 'admin/User/userAll');