Browse Source

Merge branch 'plm' of ssh://192.168.10.210:10022/wugg/stock into plm

panlumeng 3 years ago
parent
commit
5b1023de39
3 changed files with 100 additions and 29 deletions
  1. 68 18
      app/admin/controller/Purchin.php
  2. 24 11
      app/admin/controller/Resign.php
  3. 8 0
      app/admin/route/app.php

+ 68 - 18
app/admin/controller/Purchin.php

@@ -85,14 +85,21 @@ class Purchin extends BaseController
         try{
             $win = Db::name("purchease_in")->insert($orin);
             if($win){
-                $cgdinfo['wsend_num']-=$send_num;
-                $cgdinfo['send_num']+=$send_num;
-                $cgdinfo['updatetime']=date("Y-m-d H:i:s");
-                $up=Db::name("purchease_order")->save($cgdinfo);
-                if($up){
-                    Db::commit();
-                    return app_show(0,'新建成功');
+                if($status==1){
+                    $cgdinfo['wsend_num']-=$send_num;
+                    $cgdinfo['send_num']+=$send_num;
+                    $cgdinfo['updatetime']=date("Y-m-d H:i:s");
+                    $up=Db::name("purchease_order")->save($cgdinfo);
+                    if($up){
+                        Db::commit();
+                        return app_show(0,'新建成功');
+                    }else{
+                        Db::rollback();
+                        return error_show(1004,"新建失败");
+                    }
                 }
+                Db::commit();
+                return app_show(0,'新建成功');
             }
             Db::rollback();
             return error_show(1004,"新建失败");
@@ -203,17 +210,60 @@ class Purchin extends BaseController
             return error_show(1004,"参数status 不为空");
         }
         $remark = isset($this->post['remark'])&&$this->post['remark']!="" ? trim($this->post['remark']) :"";
-        $info['status'] = $status;
-        $info['remark'] = $remark;
-        $info['updatetime'] = date("Y-m-d H:i:s");
-         $update = Db::name("purchease_in")->save($info);
-         if($update){
-             Db::commit();
-             return app_show(0,"状态修改完成");
-         }else{
-             Db::rollback();
-             return error_show(1002,"状态修改失败");
-         }
+        Db::rollback();
+        try{
+            $info['status'] = $status;
+            $info['remark'] = $remark;
+            $info['updatetime'] = date("Y-m-d H:i:s");
+            $update = Db::name("purchease_in")->save($info);
+            if($update){
+                if($status==0){
+                    $cgdinfo=Db::name("purchease_order")->where(['cgdNo'=>$info['cgdNo'],"is_del"=>0])->find();
+                    if(empty($cgdinfo)){
+                        Db::rollback();
+                        return error_show(1002,"未找到采购单数据");
+                    }
+                    $cgdinfo['wsend_num']+=$info['send_num'];
+                    $cgdinfo['send_num']-=$info['send_num'];
+                    $cgdinfo['updatetime']=date("Y-m-d H:i:s");
+                    $up=Db::name("purchease_order")->save($cgdinfo);
+                    if($up){
+                        Db::commit();
+                        return app_show(0,'取消成功');
+                    }else{
+                        Db::rollback();
+                        return error_show(1002,"取消失败");
+                    }
+                }
+                if($status==1){
+                    $cgdinfo=Db::name("purchease_order")->where(['cgdNo'=>$info['cgdNo'],"is_del"=>0])->find();
+                    if(empty($cgdinfo)){
+                        Db::rollback();
+                        return error_show(1002,"未找到采购单数据");
+                    }
+                    $cgdinfo['wsend_num']-=$info['send_num'];
+                    $cgdinfo['send_num']+=$info['send_num'];
+                    $cgdinfo['updatetime']=date("Y-m-d H:i:s");
+                    $up=Db::name("purchease_order")->save($cgdinfo);
+                    if($up){
+                        Db::commit();
+                        return app_show(0,'发货成功');
+                    }else{
+                        Db::rollback();
+                        return error_show(1002,"发货失败");
+                    }
+                }
+                Db::commit();
+                return app_show(0,"状态修改完成");
+            }
+                Db::rollback();
+                return error_show(1002,"状态修改失败");
+
+        }catch (\Exception $e){
+            Db::rollback();
+            return error_show(1002,"状态修改失败");
+        }
+
     }
 
     public function ReturnAdd(){

+ 24 - 11
app/admin/controller/Resign.php

@@ -28,45 +28,54 @@ class Resign extends 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";
-        $where =['is_del'=>0];
+        $where =[['is_del',"=",0]];
         $bkcode = isset($this->post['bk_code']) && $this->post['bk_code']!="" ? trim($this->post['bk_code']):"";
         if($bkcode!=""){
-           $where['bk_code'] = $bkcode;
+           //$where['bk_code'] = $bk_code;
+            $where[]=['bk_code',"like","%{$bkcode}%"];
         }
         $good_code = isset($this->post['good_code']) && $this->post['good_code']!="" ? trim($this->post['good_code']):"";
         if($good_code!=""){
-            $where['good_code'] = $good_code;
+           // $where['good_code'] = $good_code;
+            $where[]=['good_code',"like","%{$good_code}%"];
         }
 
         $good_type_code = isset($this->post['good_type_code']) && $this->post['good_type_code']!="" ? trim($this->post['good_type_code']):"";
         if($good_type_code!=""){
-            $where['good_type_code'] = $good_type_code;
+           // $where['good_type_code'] = $good_type_code;
+            $where[]=['good_type_code',"like","%{$good_type_code}%"];
         }
         $wsm_code = isset($this->post['wsm_code']) && $this->post['wsm_code']!="" ? trim($this->post['wsm_code']):"";
         if($wsm_code!=""){
-            $where['wsm_code'] = $wsm_code;
+            //$where['wsm_code'] = $wsm_code;
+            $where[]=['wsm_code',"=",$wsm_code];
         }
         $good_name = isset($this->post['good_name']) && $this->post['good_name']!="" ? trim($this->post['good_name']):"";
         if($good_name!=""){
-            $where['good_name'] = Db::raw(" like '%{$good_name}%'");
+          //  $where['good_name'] = Db::raw(" like '%{$good_name}%'");
+            $where[]=['good_name',"like","%{$good_name}%"];
         }
 
         $apply_name = isset($this->post['apply_name']) && $this->post['apply_name']!="" ? trim($this->post['apply_name']):"";
         if($apply_name!=""){
-            $where['apply_name'] =Db::Raw("like '%{$apply_name}%'");
+          //  $where['apply_name'] =Db::Raw("like '%{$apply_name}%'");
+            $where[]=['apply_name',"like","%{$apply_name}%"];
         }
         $status = isset($this->post['status']) && $this->post['status']!=="" ? intval($this->post['status']):"";
         if($status!==""){
-            $where['status'] = $status;
+           // $where['status'] = $status;
+            $where[]=['status',"=",$status];
         }
 
         $start = isset($this->post['start']) && $this->post['start']!=="" ? $this->post['start']:"";
         if($start!==""){
-            $where['addtime'] = Db::Raw(">= '{$start}'");
+            //$where['addtime'] = Db::Raw(">= '{$start}'");
+            $where[]=['addtime',">=",$start];
         }
         $end = isset($this->post['end']) && $this->post['end']!=="" ? $this->post['end']:"";
         if($end!==""){
-            $where['addtime'] = Db::Raw("<= '{$end}'");
+           // $where['addtime'] = Db::Raw("<= '{$end}'");
+            $where[]=['addtime',"<=",$end];
         }
         $count=Db::name("purchease")->where($where)->count();
         $total = ceil($count/$size);
@@ -380,7 +389,11 @@ class Resign extends BaseController
         if($id==""){
             return error_show(1001,'id不能为空');
         }
-        $feed = Db::name("purchease_feedback")->where(['id'=>$id,'is_del'=>0])->find();
+        $info = Db::name("purchease")->where(["id"=>$id,"is_del"=>0])->find();
+        if(empty($info)){
+            return error_show(1002,'未找到备库数据');
+        }
+        $feed = Db::name("purchease_feedback")->where(['bkcode'=>$info['bk_code'],'is_del'=>0])->find();
         if(empty($feed)){
             return error_show(1004,'未找到数据');
         }

+ 8 - 0
app/admin/route/app.php

@@ -166,5 +166,13 @@ Route::rule("feeddel","admin/Resign/delFeed");
 Route::rule("feedchange","admin/Resign/changeFeed");
 Route::rule("feedinfo","admin/Resign/infoFeed");
 
+Route::rule("cgdlist","admin/Purch/list");
+Route::rule("cgdinfo","admin/Purch/info");
+Route::rule("cgdedit","admin/Purch/edit");
+Route::rule("cgdstatus","admin/Purch/status");
+
+Route::rule("orderinadd","admin/Purchin/add");
+Route::rule("purinfo","admin/Purchin/list");
+