panlumeng 3 years ago
parent
commit
4a85d20b6e

+ 16 - 0
app/admin/controller/Allot.php

@@ -166,6 +166,22 @@ class Allot extends BaseController
         if($status==""){
             return error_show(1002,"状态不能为空");
         }
+        try{
+            $data=[
+                "allot_code"=>$allot_code,
+                "apply_id"=>$apply_id,
+                "apply_name"=>$apply_name,
+                "wsm_out"=>$wsm_out,
+                "wsm_in"=>$wsm_in,
+                "post_fee"=>$post_fee,
+                "status"=>$status,
+                "updatetime"=>date('Y-m-d H:i:s'),
+            ];
+            $da = Db::name('allot_stock')->where(["id"=>$id,"is_del"=>0])->save($data);
 
+        }catch (\Exception $e){
+            Db::rollback();
+            return error_show(1005,$e->getMessage());
+        }
     }
 }

+ 143 - 65
app/admin/controller/Check.php

@@ -13,64 +13,75 @@ public function __construct(App $app)
 {
     parent::__construct($app);
     $this->post=$this->request->post();
+    $token = isset($this->post['token']) ? trim($this->post['token']) : "";
+    if($token==""){
+        return error_show(101,'token不能为空');
+    }
+    $effetc = VerifyTokens($token);
+    if(!empty($effetc) && $effetc['code']!=0){
+        return error_show($effetc['code'],$effetc['message']);
+    }
 }
 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";
-    $where = ['is_del' => 0];
+    $where = ['a.is_del' => 0,'b.is_del'=>0];
     $addtime = isset($this->post['addtime']) && $this->post['addtime'] !== "" ? intval($this->post['addtime']) : "";
     if ($addtime !== "") {
-        $where['check_code'] = $addtime;
+        $where['a.addtime'] = $addtime;
     }
     $check_code = isset($this->post['check_code']) && $this->post['check_code'] !== "" ? intval($this->post['check_code']) : "";
     if ($check_code !== "") {
-        $where['check_code'] = $check_code;
+        $where['a.check_code'] = $check_code;
     }
     $wsm_code = isset($this->post['wsm_code ']) && $this->post['wsm_code '] !== "" ? intval($this->post['wsm_code ']) : "";
     if ($wsm_code  !== "") {
-        $where['wsm_code '] = $wsm_code;
+        $where['a.wsm_code'] = $wsm_code;
+    }
+    $apply_name = isset($this->post['apply_name ']) && $this->post['apply_name '] !== "" ? intval($this->post['apply_name ']) : "";
+    if ($apply_name !== "") {
+        $where['a.apply_name'] = $apply_name;
+    }
+    $apply_id = isset($this->post['apply_id ']) && $this->post['apply_id '] !== "" ? intval($this->post['apply_id ']) : "";
+    if ($apply_id!== "") {
+        $where['a.apply_id'] = $apply_id;
     }
     $status= isset($this->post['status ']) && $this->post['status '] !== "" ? intval($this->post['status ']) : "";
     if ($status !== "") {
-        $where['status '] = $status;
+        $where['a.status '] = $status;
     }
     $count = Db::name('good_check')->count();
     $total = ceil($count / $size);
     $page = $page >= $total ? $page : $total;
-    $list = Db::name('good_check')->field('apply_id,apply_name,type,addtime')->where($where)->page($page,$size)->select();
+    $list = Db::name('good_check')->alias('a')->join("warehouse_info b","a.wsm_code = b.wsm_code","left")
+        ->join("depart_user c","c.uid=a.apply_id","left")
+        ->join("company_item d","d.id=c.itemid","left")
+        ->field("a.apply_id,a.apply_name,a.type,a.addtime,a.wsm_code,a.check_code,b.name,c.itemid,d.name as 'rename'")->where($where)->page($page,$size)->select();
     return app_show(0,"获取成功",['count'=>$count,'list'=>$list]);
     }
 public function goodlist(){
     $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";
-    $where = ['is_del'=>0,'status'=>0];
-    $count = Db::name('check_item')->count();
+    $where = ['is_del'=>0];
+    $check_code = isset($this->post['check_code']) && $this->post['check_code'] !== "" ? intval($this->post['check_code']) : "";
+    if ($check_code !== "") {
+        $where['check_code'] = $check_code;
+    }
+    $count = Db::name('check_item')->where($where)->count();
     $total = ceil($count / $size);
     $page = $page >= $total ? $page : $total;
     $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(){
+    $token =isset($this->post['token']) && $this->post['token'] !=="" ? trim($this->post['token']) :"";
+
     $wsm_code = isset($this->post['wsm_code']) && $this->post['wsm_code'] !=="" ? trim($this->post['wsm_code']):"";
     if($wsm_code==""){
         return error_show(1002,"盘点仓库编号不能为空");
     }
-    $type = isset($this->post['type']) && $this->post['type'] !=="" ? trim($this->post['type']) :"";
+    $type = isset($this->post['type']) && $this->post['type'] !=="" ? intval($this->post['type']) :"";
     if($type==""){
         return error_show(1002,"盘点类型不能为空");
     }
@@ -78,19 +89,28 @@ public function create(){
     if($check_code==""){
         return error_show(1002,"盘点编号不能为空");
     }
-    $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']):"";
+    $apply_id=GetUserInfo($token);
+    if(empty($apply_id)||$apply_id['code']!=0){
+        return error_show(1002,"申请人数据不存在");
+    }
+    $rm= isset($apply_id["data"]['id']) ?  $apply_id["data"]['id'] : "";
+    $ri= isset($apply_name["data"]['nickname']) ?  $apply_name["data"]['nickname'] : "";
     $status = isset($this->post['status']) && $this->post['status'] !=="" ? intval($this->post['status']) :"0";
     $dain=isset($this->post['good']) && $this->post['good'] !=="" ? trim($this->post['good']):"";
-    if($type===2){
+    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")
+        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();
@@ -100,22 +120,37 @@ public function create(){
             "wsm_code"=>$wsm_code,
             "type"=>$type,
             "status"=>$status,
-            "apply_id"=>$apply_id,
-            "apply_name"=>$apply_name,
+            "apply_id"=>$rm,
+            "apply_name"=>$ri,
             "is_del"=>0,
             "addtime"=>date('Y-m-d H:i:s'),
             "updatetime"=>date("Y-m-d H:i:s")
         ];
         $da= Db::name('good_check')->insert($data,true);
-        $dain=[];
+        $dio=[];
         if($da>0){
-            foreach ($do as $value){
+            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(['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;
+                ->join("good_stock c","c.good_type_code = b.type_code","left")->where(['c.wsm_code'=>$wsm_code,'good_type_code'=>$value['type_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_stock,c.wait_out_stock,c.usable_stock,c.good_type_code,a.original_price")->find();
+
+            $temp=[];
+            $temp['good_name']=$st['good_name'];
+            $temp['origin_price']=$st['original_price'];
+            $temp['good_type_code']=$st['good_type_code'];
+            $temp['origin_num']=$st['usable_stock'];
+            $temp['check_num']=0;
+            $temp['diff_num']=0;
+            $temp['status']=0;
+            $temp['remark']="";
+            $temp['is_del']=0;
+            $temp['check_time']=date('Y-m-d H:i:s');
+            $temp['check_code']=$check_code;
+            $temp['addtime']=date("Y-m-d H:i:s");
+            $temp['updatetime']=date("Y-m-d H:i:s");
+            $dio[] =$temp;
             }
-            $in= Db::name('check_item')->insertAll($dain);
+            $in= Db::name('check_item')->insertAll($dio);
         }
         if($in){
             Db::commit();
@@ -134,7 +169,23 @@ public function info(){
     if($id==""){
         return error_show(1002,"盘点单号不能为空");
     }
+    $temp=[];
+    $temp['good_name']="";
+    $temp['origin_price']="";
+    $temp['good_type_code']="";
+    $temp['origin_num']=0;
+    $temp['check_num']=0;
+    $temp['diff_num']=0;
+    $temp['status']=0;
+    $temp['remark']="";
+    $temp['is_del']=0;
+    $temp['check_time']=date('Y-m-d H:i:s');
+    $temp['addtime']=date("Y-m-d H:i:s");
+    $temp['updatetime']=date("Y-m-d H:i:s");
     $fo = Db::name('good_check')->where(['id'=>$id,'is_del'=>0])->find();
+
+    $fi = Db::name('check_item')->where(['check_code'=>$fo['check_code'],'is_del'=>0])->select();
+    $fo['item']=$fi;
     if(empty($fo)){
         return error_show(1002,"未找到盘点编号");
     }else{
@@ -143,6 +194,7 @@ public function info(){
 }
 public function edit()
 {
+    $token =isset($this->post['token']) && $this->post['token'] !=="" ? trim($this->post['token']) :"";
     $id = isset($this->post['id']) && $this->post['id'] !== "" ? intval($this->post['id']) : "";
     $eid = Db::name('good_check')->where(['id' => $id, 'is_del' => 0])->find();
     if ($eid ==="") {
@@ -160,46 +212,72 @@ public function edit()
     if ($good_type_code == "") {
         return error_show(1002, "商品属性不能为空");
     }
-    $good_name = isset($this->post['good_name']) && $this->post['good_name'] !== "" ? trim($this->post['good_name']) : "";
-    if ($good_name == "") {
-        return error_show(1002, "商品名称不能为空");
+    $apply_id=GetUserInfo($token);
+    if(empty($apply_id)||$apply_id['code']!=0){
+        return error_show(1002,"申请人数据不存在");
     }
-    $check_code = isset($this->post['check_code']) && $this->post['check_code'] !== "" ? trim($this->post['check_code']) : "";
-    if ($check_code == "") {
-        return error_show(1002, "盘点编号不能为空");
+    $rm= isset($apply_id["data"]['id']) ?  $apply_id["data"]['id'] : "";
+    $ri= isset($apply_name["data"]['nickname']) ?  $apply_name["data"]['nickname'] : "";
+    $dain=isset($this->post['good']) && $this->post['good'] !=="" ? $this->post['good']:"";
+    if($type==2){
+       // var_dump($dain);
+        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,"商品不能为空");
+        }
     }
-    $status = isset($this->post['status']) && $this->post['status'] !== "" ? trim($this->post['status']) : "";
     Db::startTrans();
     try {
         $var = [
-            "id" => $id,
-            "check_code" => $check_code,
             "wsm_code" => $wsm_code,
             "type" => $type,
-           "status" => $status,
-            "is_del" => 0,
+            "apply_id" => $rm,
+            "apply_name" => $ri,
             "updatetime" => date("Y-m-d H:i:s")
         ];
         $up = Db::name('good_check')->where(['id'=>$id,'is_del' => 0])->save($var);
-        if($up){
-            $varn = [
-                "good_type_code" => $good_type_code,
-                "good_name" => $good_name,
-                "status" => $status,
-               // "check_time" => $check_time,
-                "is_del" => 0,
-                "updatetime" => date("Y-m-d H:i:s")
-            ];
-            $np = Db::name('check_item')->where(["id"=>$eid['id']])->save($varn);
-            //var_dump(Db::name('check_item')->getLastSql());
-            if ($np) {
-                Db::commit();
-                return error_show(0, "盘点更新成功");
-            } else {
-                Db::rollback();
-                return error_show(1002, "盘点更新失败");
+            $dn =[];
+            if($up>0){
+                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(['c.wsm_code'=>$wsm_code,'good_type_code'=>$value['type_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_stock,c.wait_out_stock,c.usable_stock,c.good_type_code,a.original_price")->find();
+                    $temp=[];
+                    $temp['good_name']=$st['good_name'];
+                    $temp['origin_price']=$st['original_price'];
+                    $temp['good_type_code']=$st['good_type_code'];
+                    $temp['origin_num']=$st['usable_stock'];
+                    $temp['check_num']=0;
+                    $temp['diff_num']=0;
+                    $temp['status']=0;
+                    $temp['remark']="";
+                    $temp['is_del']=0;
+                    $temp['check_time']=date('Y-m-d H:i:s');
+                    $temp['check_code']=$eid['check_code'];
+                    $temp['addtime']=date("Y-m-d H:i:s");
+                    $temp['updatetime']=date("Y-m-d H:i:s");
+                    $dn[] =$temp;
+                }
+                $np = Db::name('check_item')->where(['check_code'=>$eid['check_code'],'is_del'=>0])->update(['is_del'=>1,'updatetime'=>date('Y-m-d H:i:s')]);
+               $io = db::name('check_item')->insertAll($dn);
+               // var_dump(Db::name('check_item')->getLastSql());
+                if ($io) {
+                    Db::commit();
+                    return error_show(0, "盘点更新成功");
+                }
             }
-        }
+        Db::rollback();
+        return error_show(1003,"盘点更新失败");
     } catch (\Exception $e) {
         Db::rollback();
         return error_show(1005, $e->getMessage());

+ 12 - 4
app/admin/controller/Consult.php

@@ -32,15 +32,23 @@ class Consult extends BaseController
       }
       $salesman = isset($this->post['salesman']) && $this->post['salesman'] !== "" ? trim($this->post['salesman']) : "";
       if ($salesman !== "") {
-          $where['salesman'] = ["like" , "%{$salesman}%"];
+          $where["salesman"] =Db::Raw("like '%$salesman%'");
+        }
+        $cpName = isset($this->post['cpName']) && $this->post['cpName'] !== "" ? trim($this->post['cpName']) : "";
+        if ($cpName !== "") {
+            $where["cpName"]= Db::Raw("like '%$cpName%'");
         }
       $khNo = isset($this->post['khNo']) && $this->post['khNo'] !== "" ? trim($this->post['khNo']) : "";
       if ($khNo !== "") {
           $where['khNo'] = $khNo;
         }
-      $zxtime = isset($this->post['zxtime']) && $this->post['zxtime'] !== "" ? trim($this->post['zxtime']) : "";
-      if ($zxtime !== "") {
-          $where['zxtime'] = $zxtime;
+        $start= isset($this->post['start']) && $this->post['start'] !== "" ? $this->post['start']:"";
+        if ($start !="") {
+            $where = ["zxtime"=>Db::raw(">= '{$start}'")];
+        }
+        $end = isset($this->post['end']) && $this->post['end'] !== "" ? $this->post['end'] :"";
+        if($end !=""){
+            $where = ["zxtime"=>Db::raw("<= '{$end}'")];
         }
       $status = isset($this->post['status']) && $this->post['status'] !== "" ? trim($this->post['status']) : "";
       if ($status !== "") {

+ 4 - 0
app/admin/controller/Resigninfo.php

@@ -34,6 +34,10 @@ class Resigninfo extends BaseController
 //        if ($hand_depart_id !== "") {
 //            $where = ["hand_depart_id"=>$hand_depart_id];
 //        }
+        $status =isset($this->post['status']) && $this->post['status'] !== "" ? intval($this->post['status']) : "";
+        if ($status !== "") {
+            $where = ["status"=>$status];
+        }
         $resign_uid = isset($this->post['resign_uid']) && $this->post['resign_uid'] !== "" ? intval($this->post['resign_uid']) : "";
         if ($resign_uid !== "") {
             $where = ["resign_uid"=>$resign_uid];