panlumeng 3 years ago
parent
commit
74908932b0
3 changed files with 210 additions and 1 deletions
  1. 171 0
      app/admin/controller/Allot.php
  2. 35 1
      app/admin/controller/Resigninfo.php
  3. 4 0
      app/admin/route/app.php

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

@@ -0,0 +1,171 @@
+<?php
+
+namespace app\admin\controller;
+
+use app\BaseController;
+use think\App;
+use think\facade\Db;
+
+class Allot extends BaseController
+{
+    public $post= "";
+    public function __construct(App $app)
+    {
+        parent::__construct($app);
+        $this->post=$this->request->post();
+    }
+    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];
+        $allot_code = isset($this->post['allot_code']) && $this->post['allot_code'] !== "" ? intval($this->post['allot_code']) : "";
+        if ($allot_code !== "") {
+            $where['allot_code'] = $allot_code;
+        }
+        $wsm_out = isset($this->post['wsm_out']) && $this->post['wsm_out'] !== "" ? intval($this->post['wsm_out']) : "";
+        if ($wsm_out !== "") {
+            $where['wsm_out'] = $wsm_out;
+        }
+        $wsm_in = isset($this->post['wsm_in']) && $this->post['wsm_in'] !== "" ? intval($this->post['wsm_in']) : "";
+        if ($wsm_in !== "") {
+            $where['wsm_in'] = $wsm_in;
+        }
+        $addtime = isset($this->post['addtime']) && $this->post['addtime'] !== "" ? intval($this->post['addtime']) : "";
+        if ($addtime !== "") {
+            $where['addtime'] = $addtime;
+        }
+        $count = Db::name('allot_stock')->count();
+        $total = ceil($count/$size);
+        $page = $page >= $total ? $total : $page;
+        $list = Db::name('allot_stock')->where($where)->page($page,$size)->select();
+        return app_show(0,"获取成功",['count'=>$count,'list'=>$list]);
+    }
+    public function create(){
+    $wsm_out = isset($this->post['wsm_out']) && $this->post['wsm_out'] !=="" ? trim($this->post['wsm_out']) :"";
+    if($wsm_out==""){
+        return error_show(1002,"出库仓库编号不能为空");
+    }
+    $wsm_in = isset($this->post['wsm_in']) && $this->post['wsm_in'] !=="" ? trim($this->post['wsm_in']) :"";
+    if($wsm_in==""){
+        return error_show(1002,"入库仓库不能为空");
+    }
+    $good_type_code = isset($this->post['good_type_code']) && $this->post['good_type_code'] !=="" ? trim($this->post['good_type_code']) :"";
+    if($good_type_code==""){
+        return error_show(1002,"商品属性不能为空");
+    }
+    $allot_num = isset($this->post['allot_num']) && $this->post['allot_num'] !=="" ? intval($this->post['allot_num']):"";
+    if($allot_num==""){
+        return error_show(1002,"出库数量不能为空");
+    }
+    $apply_name= isset($this->post['apply_name']) && $this->post['apply_name'] !=="" ? trim($this->post['apply_name']) :"";
+    $apply_id = isset($this->post['apply_id']) && $this->post['apply_id'] !=="" ? intval($this->post['apply_id']) :"" ;
+    $post_name = isset($this->post['post_name']) && $this->post['post_name'] !=="" ? trim($this->post['post_name']) :"" ;
+    $post_code = isset($this->post['post_code']) && $this->post['post_code'] !== "" ? trim($this->post['post_code']) : "";
+    $post_fee = isset($this->post['post_fee']) && $this->post['post_fee'] !== "" ? intval($this->post['post_fee']) : "";
+    $remark = isset($this->post['remark']) && $this->post['remark'] !=="" ? trim($this->post['remark']) : "";
+    $status = isset($this->post['status']) && $this->post['status'] !== "" ? intval($this->post['status']) :"0";
+    $good_name= isset($this->post['good_name']) && $this->post['good_name'] !=="" ? trim($this->post['good_name']) :"";
+    $allot_code = isset($this->post['allot_code']) && $this->post['allot_code'] !=="" ? trim($this->post['allot_code']) :"";
+    $usable_num = isset($this->post['usable_num']) && $this->post['usable_num'] !=="" ? intval($this->post['allot_code']) :"0";
+    $error_num = isset($this->post['error_num']) && $this->post['error_num'] !=="" ? intval($this->post['error_num']) :"0";
+    $error_remark = isset($this->post['error_remark']) && $this->post['error_remark'] !=="" ? trim($this->post['error_remark']) :"";
+    $stock_num = isset($this->post['stock_num']) && $this->post['error_num'] !=="" ? intval($this->post['error_num']) : "0";
+    Db::startTrans();
+    try {
+            $data=[
+                "allot_code"=>$allot_code,
+                "wsm_out"=>$wsm_out,
+                "wsm_in"=>$wsm_in,
+                "apply_name"=>$apply_name,
+                "apply_id"=>$apply_id,
+                "post_name"=>$post_name,
+                "post_code"=>$post_code,
+                "post_fee"=>$post_fee,
+                "remark"=>$remark,
+                "status"=>$status,
+                "is_del"=>0,
+                "addtime"=>date("Y-m-d H:i:s"),
+                "updatetime"=>date("Y-m-d H:i:s"),
+            ];
+            $pd=Db::name('allot_stock')->insert($data,true);
+            if($pd>0){
+                $pdinfo=[
+                    "good_type_code"=>$good_type_code,
+                    "allot_num"=>$allot_num,
+                    "good_name"=>$good_name,
+                   "allot_code"=>$allot_code,
+                    "usable_num"=>$usable_num,
+                    "error_num"=>$error_num,
+                    "error_remark"=>$error_remark,
+                    "stock_num"=>$stock_num,
+                    "addtime"=>date("Y-m-d H:i:s"),
+                    "updatetime"=>date("Y-m-d H:i:s"),
+                ];
+              $cpd = Db::name('allot_info')->insert($pdinfo);
+              if($cpd){
+                  DB::commit();
+                  error_show(0,"调拨创建成功");
+              }
+            }
+            Db::rollback();
+            return error_show(1002,"调拨创建失败");
+        }catch(\Exception $e){
+            Db::rollback();
+            return error_show(1005,$e->getMessage());
+        }
+    }
+    public function info(){
+        $id = isset($this->post['id']) && $this->post['id'] !=="" ? intval($this->post['id']) :"";
+        if($id==""){
+            return error_show(1002,"调拨编号不能为空");
+        }
+        $fio = Db::name('allot_stock')->alias('a')->join("allot_info b","a.allot_code=b.allot_code","left")
+            ->where(['a.id'=>$id,'a.is_del'=>0])->field("a.allot_code,a.apply_id,a.apply_name,a.wsm_out,a.wsm_in,a.post_fee,a.status,a.addtime,
+            b.good_type_code,b.allot_code,b.allot_num")
+            ->find();
+        if(empty($fio)){
+            return error_show(1002,"未找到调拨编号");
+        }else{
+            return app_show(0,"获取成功",$fio);
+        }
+    }
+    public function edit(){
+        $id = isset($this->post['id']) && $this->post['id'] !=="" ? intval($this->post['id']) :"";
+        if($id===""){
+            return  error_show(1002,"参数id不能为空");
+        }
+        $etid = Db::name("allot_stock")->where(["id"=>$id,"is_del"=>0])->find();
+        if(empty($etid)){
+            return error_show(1002,"未找到数据");
+        }
+        $allot_code = isset($this->post['allot_code']) && $this->post['allot_code'] !=="" ? trim($this->post['allot_code']) :"";
+        if($allot_code==""){
+            return error_show(1002,"调拨单编号不能为空");
+        }
+        $apply_id = isset($this->post['apply_id']) && $this->post['apply_id'] !=="" ? intval($this->post['apply_id']) :"" ;
+        if($apply_id==""){
+            return error_show(1002,"申请人id不能为空");
+        }
+        $apply_name = isset($this->post['apply_name']) && $this->post['apply_name'] !=="" ? trim($this->post['apply_name']) :"" ;
+        if($apply_name==""){
+            return error_show(1002,"申请人名称不能为空");
+        }
+        $wsm_out = isset($this->post['wsm_out']) && $this->post['wsm_out'] !=="" ? trim($this->post['wsm_out']) :"" ;
+        if($wsm_out==""){
+            return error_show(1002,"出库仓库不能为空");
+        }
+        $wsm_in= isset($this->post['wsm_in']) && $this->post['wsm_in'] !=="" ? trim($this->post['wsm_in']) :"" ;
+        if($wsm_in==""){
+            return error_show(1002,"入库仓库不能为空");
+        }
+        $post_fee= isset($this->post['post_fee']) && $this->post['post_fee'] !=="" ? trim($this->post['post_fee']) :"" ;
+        if($post_fee==""){
+            return error_show(1002,"物流费用不能为空");
+        }
+        $status= isset($this->post['status']) && $this->post['status'] !=="" ? trim($this->post['status']) :"" ;
+        if($status==""){
+            return error_show(1002,"状态不能为空");
+        }
+
+    }
+}

+ 35 - 1
app/admin/controller/Resigninfo.php

@@ -26,10 +26,34 @@ class Resigninfo extends BaseController
         $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];
+//       $resign_depart_id = isset($this->post['resign_depart_id']) && $this->post['resign_depart_id'] !== "" ? intval($this->post['resign_depart_id']) : "";
+//       if ($resign_depart_id !== "") {
+//            $where = ["resign_depart_id"=>$resign_depart_id];
+//        }
+//        $hand_depart_id = isset($this->post['hand_depart_id']) && $this->post['hand_depart_id'] !== "" ? intval($this->post['hand_depart_id']) : "";
+//        if ($hand_depart_id !== "") {
+//            $where = ["hand_depart_id"=>$hand_depart_id];
+//        }
+        $resign_uid = isset($this->post['resign_uid']) && $this->post['resign_uid'] !== "" ? intval($this->post['resign_uid']) : "";
+        if ($resign_uid !== "") {
+            $where = ["resign_uid"=>$resign_uid];
+        }
+        $hand_uid = isset($this->post['hand_uid']) && $this->post['hand_uid'] !== "" ? intval($this->post['hand_uid']) : "";
+        if ($hand_uid !== "") {
+            $where = ["hand_uid"=>$hand_uid];
+        }
+        $start= isset($this->post['start']) && $this->post['start'] !== "" ? $this->post['start']:"";
+        if ($start !="") {
+            $where = ["addtime"=>Db::raw(">= '{$start}'")];
+        }
+        $end = isset($this->post['end']) && $this->post['end'] !== "" ? $this->post['end'] :"";
+        if($end !=""){
+            $where = ["addtime"=>Db::raw("<= '{$end}'")];
+        }
         $count = Db::name('resign_info')->where($where)->count();
         $total = ceil($count/$size);
         $page = $page >= $total ? $total : $page;
-        $list = Db::name('resign_info')->where($where)->page($page,$size)->select();
+        $list = Db::name('resign_info')->where($where)->order("addtime desc")->page($page,$size)->select();
         return app_show(0,"获取成功",['list'=>$list,'count'=>$count]);
     }
     public function create(){
@@ -59,12 +83,22 @@ class Resigninfo extends BaseController
         if($resign_date==""){
             return error_show(1005,'离职日期不能为空');
         }
+//        $resign_depart_id = isset($this->post['resign_depart_uid']) && $this->post['resign_depart_uid'] !=="" ?$this->post['resign_depart_uid'] :"";
+//        if($resign_depart_id==""){
+//            return error_show(1005,"离职人部门id不能为空");
+//        }
+//        $hand_depart_id = isset($this->post['hand_depart_uid']) && $this->post['hand_depart_uid'] !=="" ? $this->post['hand_depart_uid']:"";
+//        if($hand_depart_id==""){
+//            return error_show(1005,"交接人部门id不能为空");
+//        }
         $is_hand = isset($this->post['is_hand']) && $this->post['is_hand'] !=="" ? trim($this->post['is_hand']):"0";
         $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']) : "";
         $data=[
             "resign_uid"=>$resign_id,
             "hand_uid"=>$hand_id,
+//            "resign_depart_id"=>$resign_depart_id,
+//            "hand_depart_id"=>$hand_depart_id,
             "resign_name"=>$ri,
             "hand_name"=>$rp,
             "resign_date"=>date("Y-m-d H:i:s"),

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

@@ -98,6 +98,10 @@ Route::rule('checkinfo','admin/Check/info');
 Route::rule('checkedit','admin/Check/edit');
 Route::rule('checkedell','admin/Check/dell');
 
+Route::rule('allotlist','admin/Allot/list');
+Route::rule('allotcreate','admin/Allot/create');
+Route::rule('allotinfo','admin/Allot/info');
+
 Route::rule('userlist', 'admin/User/list');
 Route::rule('userinfo', 'admin/User/userInfo');
 Route::rule('userall', 'admin/User/userAll');