Browse Source

Merge branch 'dev_wf' of wugg/phpstock into version1.5

wufeng 2 years ago
parent
commit
f38d96b038

+ 29 - 6
app/admin/controller/After.php

@@ -1118,12 +1118,35 @@ class After extends Base
                             "action_type" => "create"//新建create,编辑edit,更改状态status
                         ], "CKTHD", $thdata['status'], $thdata);
 
-                        ProcessOrder::AddProcess(['id'=>$this->uid,'nickname'=>$this->uname], [
-                            "order_type" => 'CKTHD',
-                            "order_code" => $thdata['thNo'],//销售单code
-                            "order_id" => $sav,
-                            "order_status" => $thdata['status'],"before_status"=>1
-                        ]);
+
+                        //售后退货单,供应商不同意退货,退回到业务公司仓的时候,要把待办数据推给供应商负责人和库管人员
+                        if($thdata['status']==1){
+
+                            //31库管人员,41库管-张凯旋
+                            $uids = Db::name('user_role')
+                                ->where(['is_del' => 0, 'roleid' => [31, 41], 'status' => 1])
+                                ->column('uid');
+
+                            ProcessOrder::AddProcess(['id' => $this->uid, 'nickname' => $this->uname], [
+                                "order_type" => 'CKTHD',
+                                "order_code" => $thdata['thNo'],//销售单code
+                                "order_id" => $sav,
+                                "order_status" => $thdata['status'],
+                                "before_status" => 0,
+                                'handle_user_list' => implode(',', array_merge($uids,$sale['cgderid'])),
+                            ]);
+                        }else{
+                            ProcessOrder::AddProcess(['id'=>$this->uid,'nickname'=>$this->uname], [
+                                "order_type" => 'CKTHD',
+                                "order_code" => $thdata['thNo'],//销售单code
+                                "order_id" => $sav,
+                                "order_status" => $thdata['status'],
+                                "before_status"=>0
+                            ]);
+                        }
+
+
+
 
                         //维护台账记录
 //                        Db::name('standing_book')

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

@@ -5,6 +5,7 @@ namespace app\admin\controller;
 use app\admin\model\ActionLog;
 use app\admin\model\GoodLog;
 use app\admin\model\GoodStockInfo;use app\admin\model\ProcessOrder;
+use app\admin\model\ProcessWait;
 use app\BaseController;
 use think\App;
 use think\facade\Db;
@@ -425,6 +426,15 @@ class Allot extends Base
             ActionLog::logAdd($this->post['token'],$order,"DBD",$str['status'],$this->post);
             $process=["order_code"=>$str['allot_code'],"order_status"=>$str['status'],"order_type"=>'DBD'];
             ProcessOrder::workdel($process);
+            //将对应的调拨单流程的数据都删掉(没有相关的中断节点,所以这里直接操作process_wait表)
+            Db::name('process_wait')
+                ->where([
+                    'order_type' => 'DBD',
+                    'order_code' => $str['allot_code'],
+                    'order_id' => $id,
+                    'status' => ProcessWait::$status_wait,
+                ])->update(['status' => ProcessWait::$status_interrupt]);
+
             return error_show(0,"删除成功");
         }else{
             return error_show(1002,"删除失败");

+ 20 - 10
app/admin/controller/Check.php

@@ -3,6 +3,7 @@
 namespace app\admin\controller;
 
 use app\admin\model\ProcessOrder;
+use app\admin\model\ProcessWait;
 use app\BaseController;
 use think\App;
 use think\facade\Db;
@@ -272,12 +273,12 @@ public function __construct(App $app)
 	        return error_show(1002,"未找到业务公司");
 	    }
 	    $check_code = makeNo("CK");
-	    $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_id["data"]['nickname']) ?  $apply_id["data"]['nickname'] : "";
+//	    $apply_id=GetUserInfo($token);
+//	    if(empty($apply_id)||$apply_id['code']!=0){
+//	        return error_show(1002,"申请人数据不存在");
+//	    }
+	    $rm= $this->uid;//isset($apply_id["data"]['id']) ?  $apply_id["data"]['id'] : "";
+	    $ri= $this->uname;//isset($apply_id["data"]['nickname']) ?  $apply_id["data"]['nickname'] : "";
 	    $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']) :"";
 	    Db::startTrans();
@@ -297,10 +298,10 @@ public function __construct(App $app)
 	        ];
 	        $da= Db::name('good_check')->insert($data,true);
 	        if($da){
-	            $orde = ["order_code"=>$check_code,"status"=>$data['status'],"action_remark"=>'',"action_type"=>"create"];
-	            ActionLog::logAdd($this->post['token'],$orde,'PDD',$data['status'],$orde);
-	            $process=["order_code"=>$check_code,"order_id"=>$da,"order_status"=>$data['status'],"order_type"=>'PDD',"before_status"=>$data['status']];
-	            ProcessOrder::AddProcess($this->post['token'],$process);
+                $orde = ["order_code" => $check_code, "status" => $data['status'], "action_remark" => '', "action_type" => "create"];
+                ActionLog::logAdd(['id' => $rm, 'nickname' => $ri], $orde, 'PDD', $data['status'], $orde);
+                $process = ["order_code" => $check_code, "order_id" => $da, "order_status" => $data['status'], "order_type" => 'PDD', "before_status" => $data['status'], 'holder_id' => $rm];
+                ProcessOrder::AddProcess(['id' => $rm, 'nickname' => $ri], $process);
 	           Db::commit();
 	            return error_show(0,"盘点创建成功");
 	        }else{
@@ -443,6 +444,15 @@ public function __construct(App $app)
             ActionLog::logAdd($this->post['token'],$orde,'PDD',$deln['status'],['id'=>$id,'is_del'=>1, 'updatetime'=>date("Y-m-d H:i:s")]);
             $process=["order_code"=>$deln['check_code'],"order_status"=>$deln['status'],"order_type"=>'PDD'];
             ProcessOrder::workdel($process);
+
+            //将对应的盘点单流程的数据都删掉(没有相关的中断节点,所以这里直接操作process_wait表)
+            Db::name('process_wait')
+                ->where([
+                    'order_type' => 'PDD',
+                    'order_code' => $deln['check_code'],
+                    'order_id' => $id,
+                    'status' => ProcessWait::$status_wait,
+                ])->update(['status' => ProcessWait::$status_interrupt]);
             return error_show(0,"删除成功");
         }else{
             return error_show(1002,"删除失败");

+ 1 - 1
app/admin/controller/Orderback.php

@@ -76,7 +76,7 @@ class Orderback extends Base
         $count=Db::name("order_back")->where($where)->where($condition)->count();
         $total = ceil($count/$size);
         $page = $page >= $total ? $total : $page;
-        $list = Db::name("order_back")->where($where)->where($condition)->page($page,$size)->order("addtime desc")->select();
+        $list = Db::name("order_back")->where($where)->where($condition)->page($page,$size)->order("addtime desc")->select()->toArray();
         $data=[];
         foreach ($list as $value){
             $value['wsm_name']="";

+ 50 - 12
app/admin/controller/Resigninfo.php

@@ -3,8 +3,10 @@
 namespace app\admin\controller;
 
 use app\admin\model\ProcessOrder;
+use app\admin\model\ProcessWait;
 use app\BaseController;
 use think\App;
+use think\Exception;
 use think\facade\Db;
 use app\admin\model\ActionLog;
 
@@ -182,19 +184,55 @@ class Resigninfo extends Base
       }
     }
     public function del(){
-        $id = isset($this->post['id']) && $this->post['id'] !=="" ? $this->post['id']:"";
-        $fid = Db::name('resign_info')->where(['is_del'=>0,'id'=>$id])->find();
-        if($fid==false){
-            return error_show(1002,"离职人员不存在");
-        }
-        $num = Db::name('resign_info')->update(['is_del'=>1,'id'=>$id,"updatetime"=>date("Y-m-d H:i:s")]);
-        if($num){
-            $stn = ["order_code"=>"BH","status"=>0,"action_remark"=>'',"action_type"=>"delete"];
-            ActionLog::logAdd($this->post['token'],$stn,"LZJJ",0,$stn);
-            return error_show(0,"删除成功");
-        }else{
-            return error_show(1002,"删除失败");
+
+        $id = isset($this->post['id']) && $this->post['id'] !== "" ? $this->post['id'] : "";
+
+        $fid = Db::name('resign_info')->where(['is_del' => 0, 'id' => $id])->find();
+
+        if ($fid == false) return error_show(1002, "离职人员不存在");
+
+        Db::startTrans();
+
+        try {
+            $num = Db::name('resign_info')
+                ->where(['is_del' => 0, 'id' => $id])
+                ->update(['is_del' => 1, 'id' => $id, "updatetime" => date("Y-m-d H:i:s")]);
+            if ($num) {
+                $stn = ["order_code" => "BH", "status" => 0, "action_remark" => '', "action_type" => "delete"];
+                ActionLog::logAdd($this->post['token'], $stn, "LZJJ", 0, $stn);
+
+                //将对应的离职交接单流程的数据都删掉(没有相关的中断节点,所以这里直接操作process_wait表)
+                Db::name('process_wait')
+                    ->where([
+                        'order_type' => 'LZJJ',
+                        'order_id' => $id,
+                        'status' => ProcessWait::$status_wait,
+                    ])->update(['status' => ProcessWait::$status_interrupt]);
+
+                Db::commit();
+                return app_show(0, "删除成功");
+            } else throw new Exception("删除失败");
+
+        } catch (Exception $exception) {
+            Db::rollback();
+
+            return error_show(1004, $exception->getMessage());
         }
+
+
+//        $id = isset($this->post['id']) && $this->post['id'] !=="" ? $this->post['id']:"";
+//        $fid = Db::name('resign_info')->where(['is_del'=>0,'id'=>$id])->find();
+//        if($fid==false){
+//            return error_show(1002,"离职人员不存在");
+//        }
+//        $num = Db::name('resign_info')->update(['is_del'=>1,'id'=>$id,"updatetime"=>date("Y-m-d H:i:s")]);
+//        if($num){
+//            $stn = ["order_code"=>"BH","status"=>0,"action_remark"=>'',"action_type"=>"delete"];
+//            ActionLog::logAdd($this->post['token'],$stn,"LZJJ",0,$stn);
+//            return error_show(0,"删除成功");
+//        }else{
+//            return error_show(1002,"删除失败");
+//        }
     }
     public function statu(){
         $id = isset($this->post['id']) && $this->post['id'] !=="" ? intval($this->post['id']) :"";

+ 1 - 1
app/admin/model/ProcessOrder.php

@@ -42,7 +42,7 @@ class ProcessOrder extends \think\Model
 
         //手动排除竞价单ZXD
         if($order['order_type']!='ZXD') {
-            ProcessWait::add(array_merge($data, ['holder_id' => $order['holder_id'] ?? 0,'person_id' => $order['person_id'] ?? 0]), isset($order['wait_id']) ? $order['wait_id'] : 0, isset($order['wait_name']) ? $order['wait_name'] : '');
+            ProcessWait::add(array_merge($data, ['holder_id' => $order['holder_id'] ?? 0,'person_id' => $order['person_id'] ?? 0]), isset($order['wait_id']) ? $order['wait_id'] : 0, isset($order['wait_name']) ? $order['wait_name'] : '',$order['handle_user_list']??'');
         }
 
         $insert = $data;

+ 3 - 3
app/admin/model/ProcessWait.php

@@ -20,7 +20,7 @@ class ProcessWait extends Model
     public static $status_interrupt = 3;//状态,3中断
 
     //添加待办记录
-    public static function add(array $data = [], int $wait_id = 0, string $wait_name = '')
+    public static function add(array $data = [], int $wait_id = 0, string $wait_name = '', string $handle_user_list = '')
     {
 //        $data数据格式实例
 //        $data=[
@@ -153,8 +153,8 @@ class ProcessWait extends Model
                 $insert_data['roleid'] = implode(',', $roleid);
 
                 //针对议价单流程,待boss审核节点,做特殊处理
-                if ($data['order_type'] == 'YJD' && $data['action_process'] == 7) $insert_data['handle_user_list'] = implode(',', Db::name('user_role')->whereIn('roleid', $roleid)->where(['is_del' => 0, 'status' => 1])->where('roleid','<>',1)->column('uid'));
-                else $insert_data['handle_user_list'] = implode(',', get_handle_user_list($info['id'], $data['holder_id'] ?? 0, $info['api_url'], $data['person_id'] ?? 0));//handle_user_list当前待处理人的uid集合
+                if ($data['order_type'] == 'YJD' && $data['action_process'] == 7) $insert_data['handle_user_list'] = implode(',', Db::name('user_role')->whereIn('roleid', $roleid)->where(['is_del' => 0, 'status' => 1])->where('roleid', '<>', 1)->column('uid'));
+                else $insert_data['handle_user_list'] = $handle_user_list ? $handle_user_list : implode(',', get_handle_user_list($info['id'], $data['holder_id'] ?? 0, $info['api_url'], $data['person_id'] ?? 0));//handle_user_list当前待处理人的uid集合
             }
 
             //增加新的节点

+ 1 - 1
app/admin/route/app.php

@@ -117,7 +117,7 @@ Route::rule('checkgood','admin/Check/goodlist');
 Route::rule('checkcreate','admin/Check/create');
 Route::rule('checkinfo','admin/Check/info');
 Route::rule('checkedit','admin/Check/edit');
-Route::rule('checkedell','admin/Check/dell');
+Route::rule('checkedell','admin/Check/dell');//作废盘点单
 Route::rule('checkestatus','admin/Check/statu');
 Route::rule('checkexport','admin/Check/exportGood');
 Route::rule('checkimport','admin/Check/importGood');

+ 13 - 3
app/youzan/logic/Goodup.php

@@ -444,7 +444,7 @@ class Goodup
             $db = new PlatformYouzan();
 
             $rs = $db
-                ->field('id,spuCode,skuCode,platform_id')
+                ->field('id,spuCode,skuCode,platform_id,exam_status')
                 ->where(['id' => $platform_youzan_id, 'is_del' => $db::$del_normal])
                 ->whereIn('exam_status', [$db::$exam_status_7, $db::$exam_status_8])
                 ->findOrEmpty();
@@ -452,14 +452,18 @@ class Goodup
             if ($rs->isEmpty()) return error_show(1005, '该商品上线记录不存在或不允许重新上线');
 
             $userinfo = GetUserInfo($token);
+            $uid = isset($userinfo['data']['id']) ? $userinfo['data']['id'] : 0;
+            $nickname = isset($userinfo['data']['nickname']) ? $userinfo['data']['nickname'] : '';
+
+            $old_status = $rs->exam_status;
 
             //更新
             $db
                 ->where('id', $platform_youzan_id)
                 ->save([
                     'exam_status' => $db::$exam_status_0,
-                    'updaterid' => isset($userinfo['data']['id']) ? $userinfo['data']['id'] : 0,
-                    'updater' => isset($userinfo['data']['nickname']) ? $userinfo['data']['nickname'] : '',
+                    'updaterid' => $uid,
+                    'updater' => $nickname,
                     'updatetime' => date('Y-m-d H:i:s'),
                 ]);
 
@@ -469,6 +473,12 @@ class Goodup
                 ->where('exam_status', '<>', 0)
                 ->update(['exam_status' => 0, 'updatetime' => date('Y-m-d H:i:s')]);
 
+            $stn = ["order_code" => $rs->skuCode, "status" => $old_status, "action_remark" => '', "action_type" => "status"];
+            ActionLog::logAdd(['id' => $uid, ['nickname' => $nickname]], $stn, "YZSX", $db::$exam_status_0, ['id'=>$platform_youzan_id]);
+
+            $process = ["order_code" => $rs->skuCode, "order_id" => $rs->id, "order_status" => $db::$exam_status_0, "order_type" => 'YZSX', "before_status" => $old_status, 'holder_id' => 0];
+            ProcessOrder::AddProcess(['id' => $uid, ['nickname' => $nickname]], $process);
+
             Db::commit();
 
             return app_show(0, '操作成功');