Browse Source

Merge branch 'wugg-dev' of wugg/phpstock into version1.5

wugg 2 years ago
parent
commit
9b3627d553
1 changed files with 15 additions and 11 deletions
  1. 15 11
      app/admin/controller/Purch.php

+ 15 - 11
app/admin/controller/Purch.php

@@ -448,7 +448,11 @@ class Purch extends Base
         if($cg==""){
         if($cg==""){
             return error_show(1002,"未找到采购单数据");
             return error_show(1002,"未找到采购单数据");
         }
         }
-        $gd= Db::name('good')->where(['spuCode'=>$cg['spuCode']])->find();
+        if($cg['order_type']==3|| $cg['order_type']==4){
+            $gd = Db::name("good_zixun")->where(["spuCode"=>$cg['spuCode']])->find();
+        }else {
+            $gd =Db::name('good_basic')->where(['spuCode'=>$cg['spuCode']])->find();
+        }
         if($gd==""){
         if($gd==""){
             return error_show(1002,"未找到商品数据");
             return error_show(1002,"未找到商品数据");
         }
         }
@@ -488,23 +492,23 @@ class Purch extends Base
 //                ActionLog::logAdd($this->post['token'],$stm,"CGGCD",1,$stm);
 //                ActionLog::logAdd($this->post['token'],$stm,"CGGCD",1,$stm);
 //                $process=["order_code"=>$cgdNo,"order_id"=>$item,"order_status"=>1,"order_type"=>'CGGCD'];
 //                $process=["order_code"=>$cgdNo,"order_id"=>$item,"order_status"=>1,"order_type"=>'CGGCD'];
 //                ProcessOrder::AddProcess($this->post['token'],$process);
 //                ProcessOrder::AddProcess($this->post['token'],$process);
-                $orderCode = Db::name("order_num")->where([["cgdNo","=",$cg['cgdNo']],["status","=",1]])->column("orderCode");
+                $orderCode = Db::name("order_num")->where([["cgdNo","=",$cg['cgdNo']],["status","=",1]])->find();
 
 
-                if(!empty($orderCode)){
-                    $order = Db::name("sale")->where("orderCode", 'in', $orderCode)->select()->toArray();
-                    if(empty($order)){
+                if($orderCode!=false){
+                    $order = Db::name("sale")->where("orderCode", '=', $orderCode['orderCode'])->find();
+                    if($order==false){
                         Db::rollback();
                         Db::rollback();
                         return error_show(1002,"未找到确认单信息");
                         return error_show(1002,"未找到确认单信息");
                     }
                     }
-                    foreach ($orderCode as $value){
+
                         $data=[
                         $data=[
                             "cgd_diffid"=>$item,
                             "cgd_diffid"=>$item,
-                            "orderCode"=>$value,
+                            "orderCode"=>$orderCode['orderCode'],
                             "good_code"=>$cg['spuCode'],
                             "good_code"=>$cg['spuCode'],
                             "good_name"=>$cg['good_name'],
                             "good_name"=>$cg['good_name'],
                             "diff_weight"=>$diff_weight,
                             "diff_weight"=>$diff_weight,
-                            "diff_price"=>$diff_weight*$cg['good_price'],
-                            "gold_price"=>$cg['good_price'],
+                            "diff_price"=>$diff_weight*$order['sale_price'],
+                            "gold_price"=>$order['sale_price'],
                             "status"=>1,
                             "status"=>1,
                             "addtime"=>date("Y-m-d H:i:s"),
                             "addtime"=>date("Y-m-d H:i:s"),
                             "updatetime"=>date("Y-m-d H:i:s")
                             "updatetime"=>date("Y-m-d H:i:s")
@@ -520,7 +524,7 @@ class Purch extends Base
 //                        }else{
 //                        }else{
                             Db::rollback();
                             Db::rollback();
                             return error_show(1002,"新建失败");
                             return error_show(1002,"新建失败");
-                        }
+
                     }
                     }
 
 
                 }
                 }
@@ -634,7 +638,7 @@ class Purch extends Base
         }
         }
         $dio = Db::name('purchease_diff')->where(['id'=>$id,'is_del'=>0])->find();
         $dio = Db::name('purchease_diff')->where(['id'=>$id,'is_del'=>0])->find();
         if(empty($dio)){
         if(empty($dio)){
-            return error_show(1002,"退货订单未找到");
+            return error_show(1002,"工差订单未找到");
         }
         }
         $cgd = Db::name("purchease_order")->where(['cgdNo'=>$dio['cgdNo']])->find();
         $cgd = Db::name("purchease_order")->where(['cgdNo'=>$dio['cgdNo']])->find();
         if(empty($cgd)){
         if(empty($cgd)){