wugg 2 years ago
parent
commit
099b027819

+ 25 - 20
app/admin/controller/Allot.php

@@ -190,12 +190,12 @@ class Allot extends BaseController
                 $order = ["order_code"=>$allot_code,"status"=>$status,"action_remark"=>'',"action_type"=>"create"];
                 ActionLog::logAdd($this->post['token'],$order,"DBD",$status,$this->post);
                 foreach ($dain as $value) {
-                    $st = Db::name("good_type")->alias("b")->join("good a", "a.good_code = b.good_code", "left")
-                        ->join("good_stock c", "c.good_type_code = b.type_code", "left")
+                    $st = Db::name("good")->alias("b")
+                        ->join("good_stock c", "c.spuCode = b.spuCode", "left")
                         ->join("warehouse_info v","v.wsm_code=c.wsm_code","left")
                         ->join("supplier n","n.code=v.supplierNo","left")
-                        ->where(['c.wsm_code' => $wsm_out,"v.wsm_type"=>1, 'good_type_code' => $value['good_code'], 'b.is_del' => 0, 'a.is_del' => 0])->where("c.is_del=0 or c.is_del is null")
-                        ->field("b.type_code,a.good_name,a.unit,c.wsm_code,c.usable_stock,c.good_type_code,c.wait_out_stock,c.wait_in_stock,n.name")->find();
+                        ->where(['c.wsm_code' => $wsm_out,"v.wsm_type"=>1, 'b.spuCode' => $value['good_code'], 'b.is_del' => 0, 'a.is_del' => 0])->where("c.is_del=0 or c.is_del is null")
+                        ->field("b.spuCode,b.good_name,b.unit,c.wsm_code,c.usable_stock,c.good_type_code,c.wait_out_stock,c.wait_in_stock,n.name")->find();
                     if (empty($st)) {
                         Db::rollback();
                         return error_show(1003, "商品不能为空");
@@ -274,7 +274,8 @@ class Allot extends BaseController
 
             $data=[];
         foreach ($vmp as $k=>$value){
-            $s =Db::name('good_stock')->where(['good_type_code'=>$value['good_type_code'],'wsm_code'=>$str['wsm_out']])->find();
+            $s =Db::name('good_stock')->where(['spuCode'=>$value['spuCode'],'wsm_code'=>$str['wsm_out']])
+                ->find();
             if($str['status']<=1) {
                 $value['usable_num'] = $s['usable_stock'];
             }
@@ -344,9 +345,12 @@ class Allot extends BaseController
                 $order = ["order_code"=>$etid['allot_code'],"status"=>$etid['status'],"action_remark"=>'',"action_type"=>"edit"];
                 ActionLog::logAdd($this->post['token'],$order,"DBD",$etid['status'],$this->post);
                 foreach ($dain as $value) {
-                    $st = Db::name("good_type")->alias("b")->join("good a", "a.good_code = b.good_code", "left")
-                        ->join("good_stock c", "c.good_type_code = b.type_code", "left")->where(['wsm_code' => $wsm_out, 'good_type_code' => $value['good_code'], 'b.is_del' => 0, 'a.is_del' => 0])->where("c.is_del=0 or c.is_del is null")
-                        ->field("b.type_code,a.good_name,a.unit,c.wsm_code,c.usable_stock,c.good_type_code,c.wait_out_stock,c.wait_in_stock")->find();
+                    $st =Db::name("good")->alias("b")
+                        ->join("good_stock c", "c.spuCode = b.spuCode", "left")
+                        ->join("warehouse_info v","v.wsm_code=c.wsm_code","left")
+                        ->join("supplier n","n.code=v.supplierNo","left")
+                        ->where(['c.wsm_code' => $wsm_out,"v.wsm_type"=>1, 'b.spuCode' => $value['good_code'], 'b.is_del' => 0, 'a.is_del' => 0])->where("c.is_del=0 or c.is_del is null")
+                        ->field("b.spuCode,b.good_name,b.unit,c.wsm_code,c.usable_stock,c.good_type_code,c.wait_out_stock,c.wait_in_stock,n.name")->find();
                     if (empty($st)) {
                         Db::rollback();
                         return error_show(1003, "商品不能为空");
@@ -443,7 +447,7 @@ class Allot extends BaseController
                 if($status==2 || $status==1){
                     $vmp = Db::name('allot_info')->where(['allot_code'=>$st['allot_code'],"is_del"=>0])->select();
                     foreach ($vmp as $value){
-                        $stock = Db::name("good_stock")->where(["good_type_code"=>$value['good_type_code'],"wsm_code"=>$st['wsm_out'],"is_del"=>0])->find();
+                        $stock = Db::name("good_stock")->where(["spuCode"=>$value['good_type_code'],"wsm_code"=>$st['wsm_out'],"is_del"=>0])->find();
                         //var_dump($value['allot_num'],$stock['usable_stock']);
                         if($value['allot_num']>$stock['usable_stock']){
                             Db::rollback();
@@ -516,7 +520,7 @@ class Allot extends BaseController
                    // var_dump(Db::name('allot_info')->getLastSql());
                 $good_data=[];
                     foreach ($vnp as $value){
-                        $stock = Db::name("good_stock")->where(["good_type_code"=>$value['good_type_code'],"wsm_code"=>$al['wsm_out'],"is_del"=>0])->find();
+                        $stock = Db::name("good_stock")->where(["spuCode"=>$value['good_type_code'],"wsm_code"=>$al['wsm_out'],"is_del"=>0])->find();
                        if($stock['wait_out_stock']<$value['allot_num']){
                            Db::rollback();
                            return error_show(2000,"超出库存数量");
@@ -574,9 +578,9 @@ class Allot extends BaseController
             ActionLog::logAdd($this->post['token'],$order,"DBD",4,$this->post);
             $good_data=[];
             foreach ($dain as $value) {
-                $st = Db::name("good_type")->alias("b")->join("good a", "a.good_code = b.good_code", "left")
-                    ->join("good_stock c", "c.good_type_code = b.type_code", "left")->where(['wsm_code' => $al['wsm_out'], 'good_type_code' => $value['good_code'], 'b.is_del' => 0, 'a.is_del' => 0])->where("c.is_del=0 or c.is_del is null")
-                    ->field("b.type_code,a.good_name,c.wsm_code,c.usable_stock,c.good_type_code")->find();
+                $st = Db::name("good")->alias("b")
+                    ->join("good_stock c", "c.spuCode = b.spuCode", "left")->where(['wsm_code' => $al['wsm_out'], 'b.spuCode' => $value['good_code'], 'b.is_del' => 0, 'a.is_del' => 0])->where("c.is_del=0 or c.is_del is null")
+                    ->field("b.spuCode,b.good_name,c.wsm_code,c.usable_stock")->find();
                 if (empty($st)) {
                     Db::rollback();
                     return error_show(1003, "未找到商品");
@@ -603,7 +607,8 @@ class Allot extends BaseController
                     return error_show(1001,"数据更新失败");
                 }
 
-                $stock = Db::name("good_stock")->where(["good_type_code"=>$value['good_code'],"wsm_code"=>$al['wsm_out'],"is_del"=>0])->find();
+                $stock = Db::name("good_stock")->where(["spuCode"=>$value['good_code'],"wsm_code"=>$al['wsm_out'],
+                    "is_del"=>0])->find();
                 if($stock['intra_stock']<$n['allot_num']){
                     Db::rollback();
                     return error_show(2000,"超出库存数量");
@@ -616,10 +621,10 @@ class Allot extends BaseController
                     return error_show(1002,"数据更新失败");
                 }
                 $good_data[]=["stock_id"=>$stock['id'],"type"=>2,'stock'=>$n['allot_num'],"stock_name"=>"intra_stock"];
-                $instock = Db::name("good_stock")->where(["good_type_code"=>$value['good_code'],"wsm_code"=>$al['wsm_in'],"is_del"=>0])->find();
+                $instock = Db::name("good_stock")->where(["spuCode"=>$value['good_code'],"wsm_code"=>$al['wsm_in'],"is_del"=>0])->find();
                 if($instock==false){
                    $instock =[];
-                    $instock['good_type_code']=$value['good_code'];
+                    $instock['spuCode']=$value['good_code'];
                     $instock['wsm_code']=$al['wsm_in'];
                     $instock['wait_in_stock']=0;
                     $instock['wait_out_stock']=0;
@@ -681,9 +686,9 @@ public function vesio(){
             $order = ["order_code"=>$al['allot_code'],"status"=>$al['status'],"action_remark"=>'',"action_type"=>"del"];
             ActionLog::logAdd($this->post['token'],$order,"DBD",5,$this->post);
             foreach ($dain as $value) {
-                $st = Db::name("good_type")->alias("b")->join("good a", "a.good_code = b.good_code", "left")
-                    ->join("good_stock c", "c.good_type_code = b.type_code", "left")->where(['wsm_code' => $al['wsm_in'], 'good_type_code' => $value['good_code'], 'b.is_del' => 0, 'a.is_del' => 0])->where("c.is_del=0 or c.is_del is null")
-                    ->field("b.type_code,a.good_name,c.wsm_code,c.usable_stock")->find();
+                $st = Db::name("good")->alias("b")
+                    ->join("good_stock c", "c.spuCode = b.spuCode", "left")->where(['wsm_code' => $al['wsm_in'], 'b.spuCode' => $value['good_code'], 'b.is_del' => 0, 'a.is_del' => 0])->where("c.is_del=0 or c.is_del is null")
+                    ->field("b.spuCode,b.good_name,c.wsm_code,c.usable_stock")->find();
                 if (empty($st)) {
                     Db::rollback();
                     return error_show(1003, "商品不能为空");
@@ -705,7 +710,7 @@ public function vesio(){
                     Db::rollback();
                     return error_show(1002,"未找到数据");
                 }
-                $stock = Db::name("good_stock")->where(["good_type_code"=>$value['good_code'],"wsm_code"=>$al['wsm_in'],"is_del"=>0])->find();
+                $stock = Db::name("good_stock")->where(["spuCode"=>$value['good_code'],"wsm_code"=>$al['wsm_in'],"is_del"=>0])->find();
                 if($stock['wait_in_stock']<$p['stock_num']){
                     Db::rollback();
                    return error_show(2000,"超出待入库存数量");

+ 9 - 22
app/admin/controller/Check.php

@@ -241,23 +241,6 @@ public function create(){
     $ri= isset($apply_id["data"]['nickname']) ?  $apply_id["data"]['nickname'] : "";
     $status = isset($this->post['status']) && $this->post['status'] !=="" ? intval($this->post['status']) :"0";
     $remark = isset($this->post['remark']) && $this->post['remark'] !=="" ? intval($this->post['remark']) :"";
-//    $dain=isset($this->post['good']) && $this->post['good'] !=="" ? trim($this->post['good']):"";
-//    if($type==2){
-//        if($dain==""||empty($dain)){
-//            return error_show(1002,"商品不能为空");
-//        }
-//    }else{
-//        if($type==1) {
-//
-//        $dain= Db::name("good_type")->alias("b")->join("good a","a.good_code = b.good_code","left")
-//              ->join("good_stock c","c.good_type_code = b.type_code","left")->where(['c.wsm_code'=>$wsm_code,'b.is_del'=>0,'a.is_del'=>0])->where("c.is_del=0 or c.is_del is null")
-//              ->field("b.type_code,a.good_name")->select();
-//        //var_dump($dain);
-//        }
-//        if($dain==""){
-//            return error_show(1003,"商品不能为空");
-//        }
-//    }
     Db::startTrans();
     try{
         $data=[
@@ -525,11 +508,11 @@ public function edit()
         if(empty($fo)){
             return error_show(1003,"未找到盘点信息");
         }
-        $list = Db::name("good_type")->alias("b")->join("good a","a.good_code = b.good_code","left")
-            ->join("good_stock c","c.good_type_code=b.type_code","left")
-            ->where(['c.wsm_code'=>$fo['wsm_code'],"a.is_del"=>0,"b.is_del"=>0,"c.is_del"=>0])->field("a.good_code '商品编码',b.type_code '商品属性编码',
-            a.good_name '商品名称',a.good_desc '商品描述',a.brand '品牌',a.unit '单位',a.gys_code '供应商编码','' as '供应商名称',a.sort_f '一级分类',a.sort_s '二级分类',a.sort_t '三级分类',
-            a.addtime '新建时间',c.wsm_code '仓库编码','' as '仓库名称',c.usable_stock '可用库存','' as '盘点库存'")
+        $list = Db::name("good")->alias("b")
+            ->join("good_stock c","c.spuCode=b.spuCode","left")
+            ->where(['c.wsm_code'=>$fo['wsm_code'],"a.is_del"=>0,"b.is_del"=>0,"c.is_del"=>0])->field("b.spuCode'商品编码',
+            b.good_name '商品名称',b.good_desc '商品描述',b.brand_id '品牌',b.good_unit '单位',b.supplierNo '供应商编码','' as '供应商名称','' as  '一级分类','' as '二级分类','' as  '三级分类',
+            b.addtime '新建时间',c.wsm_code '仓库编码','' as '仓库名称',c.usable_stock '可用库存','' as '盘点库存'")
             ->select();
         $data=[];
         foreach ($list as $key=>$value){
@@ -537,6 +520,10 @@ public function edit()
             $supplier = Db::name("supplier")->where(["code"=>$value['供应商编码']])->find();
             $value['供应商名称'] =isset($supplier['name']) ?$supplier['name'] :"";
             $value['仓库名称'] =isset($wsm['name']) ?$wsm['name'] :"";
+            $unit =Db::name("unit")->where(["id"=>$value['单位']])->find();
+            $brand =Db::name("brand")->where(["id"=>$value['品牌']])->find();
+            $value['单位'] =isset($unit['unit']) ?$unit['unit'] :"";
+            $value['品牌'] =isset($brand['brand_name']) ?$brand['brand_name'] :"";
             $data[]=$value;
         }
         if(empty($data)){

+ 0 - 8
app/admin/controller/Goodup.php

@@ -269,10 +269,6 @@ class Goodup extends Base
         if($market_price===""){
             return error_show(1004,"参数market_price不能为空");
         }
-        $nake_price = isset($this->post['nake_price'])&&$this->post['nake_price']!==""? floatval($this->post['nake_price']):"";
-        if($nake_price===""){
-            return error_show(1004,"参数nake_price不能为空");
-        }
         $is_step = isset($this->post['is_step'])&&$this->post['is_step']!==""? intval($this->post['is_step']):"";
         if($is_step===""){
             return error_show(1004,"参数is_step不能为空");
@@ -675,10 +671,6 @@ class Goodup extends Base
         if($market_price===""){
             return error_show(1004,"参数market_price不能为空");
         }
-        $nake_price = isset($this->post['nake_price'])&&$this->post['nake_price']!==""? floatval($this->post['nake_price']):"";
-        if($nake_price===""){
-            return error_show(1004,"参数nake_price不能为空");
-        }
         $is_step = isset($this->post['is_step'])&&$this->post['is_step']!==""? intval($this->post['is_step']):"";
         if($is_step===""){
             return error_show(1004,"参数is_step不能为空");

+ 1 - 6
app/admin/controller/Orderback.php

@@ -152,11 +152,6 @@ class Orderback extends \app\BaseController
       if(empty($info)){
           return error_show(1004,"未找到数据");
       }
-//      $receive = isset($this->post['receive']) && $this->post['receive']!="" ? intval($this->post['receive']):"";
-//      if($receive==""){
-//          return error_show(1004,"参数receive不能为空");
-//      }
-
       $normal = isset($this->post['normal']) && $this->post['normal']!=="" ? intval($this->post['normal']):"";
       if($normal===""){
           return error_show(1004,"参数normal不能为空");
@@ -185,7 +180,7 @@ class Orderback extends \app\BaseController
                   Db::commit();
                   return app_show(0,'更新成功');
               }
-              //$temp =[];
+
               foreach($errorlist as $value){
                   $data=[];
                   isset($value['id'])&&$value['id']!=''?$data['id']=$value['id']:"";

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

@@ -2100,7 +2100,7 @@ class Sale extends Base
                     }
                     $good_data[]=  ["stock_id"=>$str['id'],"type"=>2,'stock'=>$send_num,"stock_name"=>"wait_out_stock"];
                     $good_data[]=  ["stock_id"=>$str['id'],"type"=>1,'stock'=>$send_num,"stock_name"=>"intra_stock"];
-                    GoodLog::LogAdd($this->post['token'],$good_data,$der['order_type'] == 2?"ZXQRD":"XSQRD");
+                    GoodLog::LogAdd($this->post['token'],$good_data,$der['order_type'] != 1?"ZXQRD":"XSQRD");
                 }
 
                 Db::commit();