panlumeng 3 yıl önce
ebeveyn
işleme
16763803bf
2 değiştirilmiş dosya ile 36 ekleme ve 36 silme
  1. 34 30
      app/admin/controller/Check.php
  2. 2 6
      app/admin/controller/Good.php

+ 34 - 30
app/admin/controller/Check.php

@@ -51,6 +51,20 @@ public function goodlist(){
     $list = Db::name('check_item')->where($where)->page($page,$size)->select();
     return app_show(0,"获取成功",['count'=>$count,'list'=>$list]);
 }
+//    $good_type_code = isset($this->post['good_type_code']) && $this->post['good_type_code'] !=="" ? $this->post['good_type_code']:"";
+//    if($good_type_code==""){
+//        return error_show(1002,"商品属性不能为空");
+//    }
+//    $good_name = isset($this->post['good_name']) && $this->post['good_name'] !=="" ? $this->post['good_name'] : "";
+//    if($good_name==""){
+//        return error_show(1002,"商品名称不能为空");
+//    }
+//    $origin_price = isset($this->post['origin_price']) && $this->post['origin_price'] !=="" ? $this->post['origin_price'] :"";
+//    $origin_num = isset($this->post['origin_num']) && $this->post['origin_num'] !=="" ? $this->post['origin_num'] :"";
+//    $check_num = isset($this->post['check_num']) && $this->post['check_num'] !=="" ? $this->post['check_num'] :"";
+//    $diff_num = isset($this->post['diff_num']) && $this->post['diff_num'] !=="" ? $this->post['diff_num'] :"";
+//    $remark = isset($this->post['remark']) && $this->post['remark'] !=="" ? $this->post['remark'] :"";
+//    $check_time = isset($this->post['check_time']) && $this->post['check_time'] !=="" ? $this->post['startTime']:date("Y-m-d H:i:s");
 public function create(){
     $wsm_code = isset($this->post['wsm_code']) && $this->post['wsm_code'] !=="" ? trim($this->post['wsm_code']):"";
     if($wsm_code==""){
@@ -67,20 +81,18 @@ public function create(){
     $apply_id = isset($this->post['apply_id']) && $this->post['apply_id'] !=="" ? trim($this->post['apply_id']):"";
     $apply_name = isset($this->post['apply_name']) && $this->post['apply_name'] !=="" ? trim($this->post['apply_name']):"";
     $status = isset($this->post['status']) && $this->post['status'] !=="" ? intval($this->post['status']) :"0";
-    $good_type_code = isset($this->post['good_type_code']) && $this->post['good_type_code'] !=="" ? $this->post['good_type_code']:"";
-    if($good_type_code==""){
-        return error_show(1002,"商品属性不能为空");
-    }
-    $good_name = isset($this->post['good_name']) && $this->post['good_name'] !=="" ? $this->post['good_name'] : "";
-    if($good_name==""){
-        return error_show(1002,"商品名称不能为空");
-    }
-    $origin_price = isset($this->post['origin_price']) && $this->post['origin_price'] !=="" ? $this->post['origin_price'] :"";
-    $origin_num = isset($this->post['origin_num']) && $this->post['origin_num'] !=="" ? $this->post['origin_num'] :"";
-    $check_num = isset($this->post['check_num']) && $this->post['check_num'] !=="" ? $this->post['check_num'] :"";
-    $diff_num = isset($this->post['diff_num']) && $this->post['diff_num'] !=="" ? $this->post['diff_num'] :"";
-    $remark = isset($this->post['remark']) && $this->post['remark'] !=="" ? $this->post['remark'] :"";
-    $check_time = isset($this->post['check_time']) && $this->post['check_time'] !=="" ? $this->post['startTime']:date("Y-m-d H:i:s");
+    $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) {
+          $do = 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();
+        }
+    }
     Db::startTrans();
     try{
         $data=[
@@ -95,22 +107,15 @@ public function create(){
             "updatetime"=>date("Y-m-d H:i:s")
         ];
         $da= Db::name('good_check')->insert($data,true);
+        $dain=[];
         if($da>0){
-            $dain=[
-                "good_type_code"=>$good_type_code,
-                "good_name"=>$good_name,
-                "status"=>$status,
-               "origin_price" =>$origin_price,
-                "origin_num"=>$origin_num,
-                "check_num"=>$check_num,
-                "diff_num"=>$diff_num,
-                "remark"=>$remark,
-                "check_time"=>$check_time,
-                "is_del"=>0,
-                "addtime"=>date('Y-m-d H:i:s'),
-                "updatetime"=>date("Y-m-d H:i:s")
-            ];
-            $in= Db::name('check_item')->insert($dain);
+            foreach ($do 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(['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,c.wsm_code,c.wait_in_")->select();
+            $dain[] =$value;
+            }
+            $in= Db::name('check_item')->insertAll($dain);
         }
         if($in){
             Db::commit();
@@ -124,7 +129,6 @@ public function create(){
         return error_show(1005,$e->getMessage());
     }
     }
-
 public function info(){
     $id = isset($this->post['id']) && $this->post['id'] !=="" ? intval($this->post['id']) :"";
     if($id==""){

+ 2 - 6
app/admin/controller/Good.php

@@ -25,14 +25,10 @@ class Good extends \app\BaseController
     public function list(){
         $page = isset($this->post['page']) &&$this->post['page'] !=="" ? intval($this->post['page']):1;
         $size = isset($this->post['size']) &&$this->post['size'] !=="" ? intval($this->post['size']):10;
-        $condtion=[['a.is_del',"=",0],['b.is_del',"=",0]];
+        $condtion=['a.is_del'=>0,'b.is_del'=>0];
         $wsmcode =isset($this->post['wsm_code']) &&$this->post['wsm_code'] !=="" ? trim($this->post['wsm_code']):"";
         if($wsmcode!=""){
-            $condtion[] = ["wsm_code","=",$wsmcode];
-        }
-        $good_name =isset($this->post['good_name']) &&$this->post['good_name'] !=="" ? trim($this->post['good_name']):"";
-        if($good_name!=""){
-            $condtion[] = ["good_name","like","%{$good_name}%"];
+            $condtion["wsm_code"]= $wsmcode;
         }
         $goodcode =isset($this->post['good_code']) &&$this->post['good_code'] !=="" ? trim($this->post['good_code'])
             :"";