wugg 2 年 前
コミット
f7c7862fc3
2 ファイル変更39 行追加2 行削除
  1. 38 1
      app/admin/controller/InterOrder.php
  2. 1 1
      app/admin/controller/OrderInv.php

+ 38 - 1
app/admin/controller/InterOrder.php

@@ -289,13 +289,28 @@ class InterOrder extends \app\admin\BaseController{
 					"addtime"=>date("Y-m-d H:i:s"),
 					"updatetime"=>date("Y-m-d H:i:s")
 				];
+		 $repostinsert=[
+						    "qrdNo"=>$qrdcode ,
+						    "seller_id"=>$param['sale_id'] ,
+						    "seller"=>$param['sale_name'] ,
+						    "cgder_id"=>$param['buyerid'] ,
+						    "cgder"=>$param['buyer'] ,
+						    "customerName"=>$customer['companyName']??"",
+						    "customerNo"=>$param['khNo'],//客户编号,
+						    "companyNo"=>$param['companyNo'],
+						    "companyName"=> $companyName ,
+						    "supplierNo"=>$param['supplierNo'],
+						    "supplierName"=> $supplierName ,
+						    "cgdNo"=>$cgddcode,
+					    ];
 				 Db::startTrans();
         try {
             $a = Db::name("qrd_info")->insert($qrd);
             $d = Db::name("inter_order")->insert($inter);
             $b = Db::name('cgd_info')->insert($cgd);
             $c = Db::name('good')->insert($good);
-            if ($a && $b && $c&&$d) {
+            $e=Db::name("report_code")->insert($repostinsert);
+            if ($a && $b && $c && $d && $e) {
                 Db::commit();
                 return app_show(0,'新建成功');
             } else {
@@ -354,6 +369,8 @@ class InterOrder extends \app\admin\BaseController{
 		$supplierName =Db::name("supplier_info")->where('code', "=", $param['supplierNo'])->value("name","");
 		$companyName =Db::name("supplier_info")->where('code', "=", $param['companyNo'])->value("name","");
 		$taxinfo = Db::name("order_rate")->where(["id"=>$param["tax"],"status"=>1])->value("rate",0);
+		$report = Db::name("report_code")->where(["qrdNo"=>$inter_order['orderCode'],"cgdNo"=>$inter_order['cgdNo']])
+		->findOrEmpty();
 		$cat = [];
 		if($qrd_order['status']!=0) return error_show(1004,"销售单已对账,无法修改");
 		if($cgd_order['status']!=0) return error_show(1004,"采购单已对账,无法修改");
@@ -444,12 +461,32 @@ class InterOrder extends \app\admin\BaseController{
 					"cat_name"=>$cat[2]['cat_name'],
 					"updatetime"=>date("Y-m-d H:i:s")
 				];
+						$repostinsert=[
+						    "seller_id"=>$param['sale_id'] ,
+						    "seller"=>$param['sale_name'] ,
+						    "cgder_id"=>$param['buyerid'] ,
+						    "cgder"=>$param['buyer'] ,
+						    "customerName"=>$customer['companyName']??"",
+						    "customerNo"=>$param['khNo'],//客户编号,
+						    "companyNo"=>$param['companyNo'],
+						    "companyName"=> $companyName ,
+						    "supplierNo"=>$param['supplierNo'],
+						    "supplierName"=> $supplierName ,
+					    ];
+					if(empty($report)){
+						$repostinsert['qrdNo'] =$inter_order['orderCode'];
+						$repostinsert['cgdNo'] =$inter_order['cgdNo'];
+					}else{
+						$repostinsert['id']  = $report['id'];
+					}
+
 		Db::startTrans();
         try {
             $a = Db::name("qrd_info")->save($qrd);
             $d = Db::name("inter_order")->save($inter);
             $b = Db::name('cgd_info')->save($cgd);
             $c = Db::name('good')->save($good);
+             Db::name('report_code')->save($repostinsert);
             if ($a && $b && $d &&$c) {
                 Db::commit();
                 return app_show(0,'更新成功');

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

@@ -834,7 +834,7 @@ class OrderInv extends BaseController{
 	                    	if(in_array($ticket['inv_type'],['007','026'])) $result= $this->addRedOpen($ticket,$return_reason,$invinfo['company_type'], $returnCode);
 	                    	if(in_array($ticket['inv_type'],['004','028'])) $result= $this->addApplyRed($ticket,$returnCode);
 	                    }
-						if($result['code']==0){
+						if(isset($result['code'])&&$result['code']==0){
 							if($discard==1){
 								$status=2;
 							}