wugg 2 年之前
父节点
当前提交
f026cd73b7
共有 2 个文件被更改,包括 50 次插入96 次删除
  1. 2 56
      app/admin/controller/Consult.php
  2. 48 40
      app/admin/controller/Purchin.php

+ 2 - 56
app/admin/controller/Consult.php

@@ -13,58 +13,7 @@ class Consult extends Base
         parent::__construct($app);
         $this->noble =\think\facade\Config::get("noble");
     }
-//    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],["cat_id","<>",0]];
-//      $zxNo = isset($this->post['zxNo']) && $this->post['zxNo'] !== "" ? trim($this->post['zxNo']) : "";
-//      if ($zxNo !== "") {
-//          $where[] = ['zxNo','=',$zxNo];
-//      }
-//      $sequenceNo = isset($this->post['sequenceNo']) && $this->post['sequenceNo'] !== "" ? trim($this->post['sequenceNo']) : "";
-//      if ($sequenceNo !== "") {
-//            $where[] = ['sequenceNo','like',"%$sequenceNo%"];
-//        }
-//      $salesman = isset($this->post['salesman']) && $this->post['salesman'] !== "" ? trim($this->post['salesman']) : "";
-//      if ($salesman !== "") {
-//          //$where["salesman"] =Db::Raw("like '%$salesman%'");
-//          $where[]= ["salesman",'like',"%$salesman%"];
-//        }
-//        $cpName = isset($this->post['cpName']) && $this->post['cpName'] !== "" ? trim($this->post['cpName']) : "";
-//        if ($cpName !== "") {
-//            //$where["cpName"]= Db::Raw("like '%$cpName%'");
-//            $where[]= ["cpName",'like',"%$cpName%"];
-//        }
-//      $khNo = isset($this->post['khNo']) && $this->post['khNo'] !== "" ? trim($this->post['khNo']) : "";
-//      if ($khNo !== "") {
-//         // $where['khNo'] = $khNo;
-//          $where[]= ["khNo",'like',"%$khNo%"];
-//        }
-//        $start= isset($this->post['start']) && $this->post['start'] !== "" ? $this->post['start']:"";
-//        if ($start !="") {
-//            //$where = ["zxtime"=>Db::raw(">= '{$start}'")];
-//            $where[]= ["zxtime",'>=',$start];
-//        }
-//        $end = isset($this->post['end']) && $this->post['end'] !== "" ? $this->post['end'] :"";
-//        if($end !=""){
-//            $where[]= ["zxtime",'<=',$end];
-//        }
-//      $status = isset($this->post['status']) && $this->post['status'] !== "" ? trim($this->post['status']) : "";
-//      if ($status !== "") {
-//          $where[]= ["status",'=',$status];
-//        }
-//        $count = Db::name('consult')->where($where)->count();
-//        $total = ceil($count / $size);
-//        $page = $page >= $total ? $total : $page;
-//      $list = Db::name('consult')->where($where)->page($page,$size)
-//          ->select();
-//     $data=[];
-//      foreach ($list as $value){
-//          $value['can']= isset($value['cat_id']) && $value['cat_id'] !=0 ? made($value['cat_id']):[];
-//          $data[]=$value;
-//      }
-//      return app_show(0,"获取成功",['count'=>$count,'list'=>$data]);
-//    }
+
     public function conlist(){
         $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";
@@ -73,10 +22,7 @@ class Consult extends Base
         if ($infoNo !== "") {
             $where[] = ['a.infoNo','=',$infoNo];
         }
-//        $sequenceNo = isset($this->post['sequenceNo']) && $this->post['sequenceNo'] !== "" ? trim($this->post['sequenceNo']) : "";
-//        if ($sequenceNo !== "") {
-//            $where[] = ['sequenceNo','like',"%$sequenceNo%"];
-//        }
+
         $salesman = isset($this->post['salesman']) && $this->post['salesman'] !== "" ? trim($this->post['salesman']) : "";
         if ($salesman !== "") {
             //$where["salesman"] =Db::Raw("like '%$salesman%'");

+ 48 - 40
app/admin/controller/Purchin.php

@@ -111,6 +111,7 @@ class Purchin extends BaseController
        if($cgdinfo['status']==0){
            return error_show(1005,"采购单未发货");
        }
+
         $wsm_in_code = makeNo("IC");
 //       $wsm_code = isset($this->post['wsm_code'])&&$this->post['wsm_code']!="" ? trim($this->post['wsm_code']):"";
 //       if($wsm_code==""){
@@ -144,6 +145,15 @@ class Purchin extends BaseController
         if($send_num>$cgdinfo['wsend_num']){
             return error_show(1004,"采购单剩余未发货数量不足");
         }
+        if($cgdinfo['order_type']==1||$cgdinfo['order_type']==2 ){
+            $goodinfo = Db::name("good")->where(["spuCode"=>$cgdinfo['spuCode'],"is_del"=>0])->find();
+            if($goodinfo==false){
+                return error_show(1004,"商品数据未找到");
+            }
+            if($goodinfo['is_stock']==0){
+                $status=4;
+            }
+        }
         $orin = [
             "wsm_in_code"=>$wsm_in_code,
             "cgdNo"=>$cgdNo,
@@ -182,48 +192,53 @@ class Purchin extends BaseController
                     $cgdinfo['updatetime']=date("Y-m-d H:i:s");
                     $up=Db::name("purchease_order")->save($cgdinfo);
                     if($up){
-//                        $good = Db::name("good_stock")->where(["wsm_code"=>$cgdinfo['wsm_code'],"spuCode"=>$cgdinfo['spuCode'],"is_del"=>0])->find();
-//                        if(empty($good)) {
-//                            $good=[
-//                                "spuCode"=>$cgdinfo['skpuCode'],
-//                                "wsm_code"=>$cgdinfo['wsm_code'],
-//                                "usable_stock"=>0,
-//                                "wait_out_stock"=>0,
-//                                "wait_in_stock"=>0,
-//                                "total_stock"=>0,
-//                                "addtime"=>date("Y-m-d H:i:s"),
-//                                "updatetime"=>date("Y-m-d H:i:s"),
-//                            ];
-//                            $order = ["order_code"=>$good['good_type_code'],"status"=>1,"action_remark"=>'',
-//                                "action_type"=>"create"];
-//
-//                        }else{
-//                            $order = ["order_code"=>$good['good_type_code'],"status"=>1,"action_remark"=>'', "action_type"=>"edit"];
-//                        }
-//                        $good['wait_in_stock']+=$send_num;
-//                        $good['updatetime'] = date("Y-m-d H:i:s");
-//                        $upd=  Db::name("good_stock")->save($good);
-//                        $good_data[]=["stock_id"=>isset($good['id'])? $good['id']:Db::name("good_stock")->getLastInsID(),"type"=>1,
-//                            'stock'=>$send_num,"stock_name"=>"wait_in_stock"];
-//                        if($upd){
-//                            GoodLog::LogAdd($this->post['token'],$good_data,'入库单');
-//                            ActionLog::logAdd($this->post['token'],$order,"仓库库存", 1,$good  );
                             $process=["order_code"=>$cgdNo,"order_id"=>$cgdinfo['id'],"order_status"=>$cgdinfo['status'],"order_type"=>'CGD'];
                             ProcessOrder::AddProcess($this->post['token'],$process);
                             Db::commit();
                             return app_show(0,'新建成功',["wsm_in_code"=>$wsm_in_code]);
-//                        }else{
-//                            Db::rollback();
-//                            return error_show(1002,"商品入库失败");
-//                        }
-
-//                        Db::commit();
-//                        return app_show(0,'新建成功',["wsm_in_code"=>$wsm_in_code]);
                     }else{
                         Db::rollback();
                         return error_show(1004,"新建失败");
                     }
                 }
+                if($status==4){
+                    $good = Db::name("good_stock")->where(["wsm_code"=>$cgdinfo['wsm_code'],
+                        "spuCode"=>$cgdinfo['spuCode'],"is_del"=>0])->find();
+
+                    if(empty($good)) {
+                        $good=[
+                            "spuCode"=>$cgdinfo['spuCode'],
+                            "wsm_code"=>$cgdinfo['wsm_code'],
+                            "usable_stock"=>0,
+                            "wait_out_stock"=>0,
+                            "wait_in_stock"=>0,
+                            "total_stock"=>0,
+                            "addtime"=>date("Y-m-d H:i:s"),
+                            "updatetime"=>date("Y-m-d H:i:s"),
+                        ];
+                        $order = ["order_code"=>$good['spuCode'],"status"=>1,"action_remark"=>'',
+                            "action_type"=>"create"];
+
+                    }else{
+                        $order = ["order_code"=>$good['spuCode'],"status"=>1,"action_remark"=>'', "action_type"=>"edit"];
+                    }
+                    $good['usable_stock']+=$send_num;
+                    $good['wait_in_stock']-=$send_num;
+                    $good['total_stock']=$good['usable_stock']+$good['wait_out_stock'];
+                    $good['updatetime'] = date("Y-m-d H:i:s");
+                    $upd=  Db::name("good_stock")->save($good);
+                    $good_data[]=["stock_id"=>isset($good['id'])? $good['id']:Db::name("good_stock")->getLastInsID(),"type"=>1,
+                        'stock'=>$send_num,"stock_name"=>"usable_stock"];
+                    if($upd){
+                        GoodLog::LogAdd($this->post['token'],$good_data,'入库单');
+                        ActionLog::logAdd($this->post['token'],$order,"仓库库存", 1,$good  );
+                        Db::commit();
+                        return app_show(0,'商品入库成功',["wsm_in_code"=>$wsm_in_code]);
+                    }else{
+                        Db::rollback();
+                        return error_show(1002,"商品入库失败");
+                    }
+                }
                 Db::commit();
                 return app_show(0,'新建成功',["wsm_in_code"=>$wsm_in_code]);
             }
@@ -301,12 +316,6 @@ class Purchin extends BaseController
             return error_show(1004,"参数 order_num 不为空");
         }
         $error_list = isset($this->post['error_list']) && $this->post['error_list']!==''?$this->post['error_list']:"";
-
-//        $wait_num = isset($this->post['wait_num']) && $this->post['wait_num']!==''?intval($this->post['wait_num'])
-//            :"";
-//        if($wait_num===''){
-//            return error_show(1004,"参数 wait_num 不为空");
-//        }
         $result = GetUserInfo($this->post['token']);
         if((!empty($result) && $result['code']!=0) ||empty($result) ){
             return error_show($result['code'],$result['message']);
@@ -342,7 +351,6 @@ class Purchin extends BaseController
                         $data[]=$temp;
                     }
                     $derr= Db::name("purchease_info")->insertAll($data);
-                  //  echo Db::name("purchease_info")->getLastSql();
                     if($derr){
                         Db::commit();
                         return app_show(0,"验货完成");