Browse Source

Merge branch 'version1.5' into wugg-dev

wugg 2 years ago
parent
commit
ab507d5df7

+ 35 - 10
app/abutment/controller/Order.php

@@ -457,7 +457,7 @@ class Order extends HomeBaseController
             $supplier_cgderid = Db::name('supplier')
                 ->where('is_del',0)
                 ->whereIn('code',array_column($cgdinfo,'supplierNo'))
-                ->column('personid','code');
+                ->column('personid,person','code');
 
             $i = 0;
             $status = 4;//4入库完成
@@ -587,6 +587,14 @@ class Order extends HomeBaseController
                                     $up = Db::name("order_out")->where(["outCode" => $send, "status" => 0])->update(["status" => 1, 'wsm_code' => $cgdinfo[$cgdNo]['wsm_code'], "updatetime" => date('Y-m-d H:i:s')]);
                                     if ($up == false) throw new Exception('出库单出库失败');
                                     else {
+
+                                        //查询是否有非库存品订单
+                                        $is_stock = Db::name('sale')
+                                            ->where([
+                                                ['is_del','=',0],
+                                                ['orderCode','in',array_column($out,'orderCode')]
+                                            ])->column('is_stock','orderCode');
+
                                         foreach ($out as $k => $v_outCode) {
                                             //修改状态,添加待办
                                             ActionLog::logAdd(['id' => $uid, 'nickname' => $nickname], [
@@ -596,14 +604,31 @@ class Order extends HomeBaseController
                                                 "action_type" => "status"//新建create,编辑edit,更改状态status
                                             ], "CKD", 1, $param);
 
-                                            ProcessOrder::AddProcess(['id' => $uid, 'nickname' => $nickname], [
-                                                "order_type" => 'CKD',
-                                                "order_code" => $v_outCode['outCode'],//出库单号
-                                                "order_id" => $v_outCode['id'],
-                                                "order_status" => 1,
-                                                "before_status" => 0,
-                                                'holder_id' => $v_outCode['apply_id']
-                                            ]);
+                                            if(isset($is_stock[$v_outCode['orderCode']]) && $is_stock[$v_outCode['orderCode']]==0){
+                                                //非库存品,推给供应商负责人
+                                                $wait = $supplier_cgderid[$cgdinfo[$cgdNo]['supplierNo']];
+                                                ProcessOrder::AddProcess(['id' => $uid, 'nickname' => $nickname], [
+                                                    "order_type" => 'CKD',
+                                                    "order_code" => $v_outCode['outCode'],//出库单号
+                                                    "order_id" => $v_outCode['id'],
+                                                    "order_status" => 1,
+                                                    "before_status" => 0,
+                                                    'wait_id' => $wait['personid'],
+                                                    'wait_name' => $wait['person'],
+                                                    'holder_id' => $wait['personid'],
+                                                ]);
+                                            }else {
+                                                ProcessOrder::AddProcess(['id' => $uid, 'nickname' => $nickname], [
+                                                    "order_type" => 'CKD',
+                                                    "order_code" => $v_outCode['outCode'],//出库单号
+                                                    "order_id" => $v_outCode['id'],
+                                                    "order_status" => 1,
+                                                    "before_status" => 0,
+                                                    'holder_id' => $v_outCode['apply_id']
+                                                ]);
+                                            }
+
+
                                         }
                                     }
                                     $good1 = Db::name("good_stock")->where(["wsm_code" => $cgdinfo[$cgdNo]['wsm_code'], "spuCode" => $cgdinfo[$cgdNo]['spuCode'], "is_del" => 0])->find();
@@ -628,7 +653,7 @@ class Order extends HomeBaseController
                             }
                         }
                         ActionLog::logAdd(['id' => $uid, 'nickname' => $nickname], $order, "CGD", $cgdinfo[$cgdNo]['status'], $cgdinfo[$cgdNo]);
-                        $process = ["order_code" => $cgdNo, "order_id" => $cgdinfo[$cgdNo]['id'], "order_status" => $cgdinfo[$cgdNo]['status'], "order_type" => 'CGD', "before_status" => $order['status'], 'holder_id' => isset($supplier_cgderid[$cgdinfo[$cgdNo]['supplierNo']]) ? $supplier_cgderid[$cgdinfo[$cgdNo]['supplierNo']] : 0];
+                        $process = ["order_code" => $cgdNo, "order_id" => $cgdinfo[$cgdNo]['id'], "order_status" => $cgdinfo[$cgdNo]['status'], "order_type" => 'CGD', "before_status" => $order['status'], 'holder_id' => isset($supplier_cgderid[$cgdinfo[$cgdNo]['supplierNo']]['personid']) ? $supplier_cgderid[$cgdinfo[$cgdNo]['supplierNo']]['personid'] : 0];
                         ProcessOrder::AddProcess(['id' => $uid, 'nickname' => $nickname], $process);
 //                        Db::commit();
 //                        return json_show(0, '商品入库成功', ["wsm_in_code" => $wsm_in_code]);

+ 93 - 42
app/admin/controller/After.php

@@ -101,12 +101,12 @@ class After extends Base
         if($token==''){
             return error_show(105,"参数token不能为空");
         }
-        $user =GetUserInfo($token);
-        if(empty($user)||$user['code']!=0){
-            return error_show(102,"申请人数据不存在");
-        }
-        $rm= isset($user["data"]['id']) ?  $user["data"]['id'] : "";
-        $ri= isset($user["data"]['nickname']) ?  $user["data"]['nickname'] : "";
+//        $user =GetUserInfo($token);
+//        if(empty($user)||$user['code']!=0){
+//            return error_show(102,"申请人数据不存在");
+//        }
+        $rm = $this->uid;//isset($user["data"]['id']) ?  $user["data"]['id'] : "";
+        $ri = $this->uname;//isset($user["data"]['nickname']) ?  $user["data"]['nickname'] : "";
         $returnCode=makeNo("RS");
         Db::startTrans();
         try{
@@ -140,7 +140,7 @@ class After extends Base
             ];
             $create = Db::name("order_return")->insert($in,true);
             $orde = ["order_code"=>$returnCode,"status"=>$in['status'],"action_remark"=>'',"action_type"=>"create"];
-            ActionLog::logAdd($this->post['token'],$orde,'SHD',1,$orde);
+            ActionLog::logAdd(['id'=>$this->uid,'nickname'=>$this->uname],$orde,'SHD',1,$orde);
             if($create>0){
 
                 //维护台账
@@ -153,7 +153,15 @@ class After extends Base
 
                 Db::execute("UPDATE `wsm_standing_book` SET `returnCode`=CONCAT(IFNULL(`returnCode`,''),',{$returnCode}'),`updatetime`='" . date('Y-m-d H:i:s') . "' WHERE FIND_IN_SET('{$outCode}',`outCode`)");
 
-                $process = ["order_code" => $returnCode, "order_id" => $create, "order_status" => $in['status'], "order_type" => 'SHD', "before_status" => 1,'holder_id'=>$in['apply_id']];
+                //当状态为1(即待业务审核)时,要将待办数据推给销售主管,即角色为'客服负责人'的用户
+                $user = Db::name('user_role')
+                    ->where([
+                        ['is_del', '=', 0],
+                        ['roleid', 'in', [12, 13, 17, 28]],//12客服负责人,13项目负责人,17平台负责人,28网络负责人
+                        ['status', '=', 1],
+                    ])->column('uid');
+
+                $process = ["order_code" => $returnCode, "order_id" => $create, "order_status" => $in['status'], "order_type" => 'SHD', "before_status" => 0, 'handle_user_list'=>implode($user)];
                     ProcessOrder::AddProcess($token,$process);
                     Db::commit();
                     return app_show(0,"售后申请单新建成功",["returnCode"=>$returnCode]);
@@ -396,9 +404,9 @@ class After extends Base
                         return error_show(1004,"发货单更新失败");
                     }
                     $order = ["order_code"=>$orde['outCode'],"status"=>$od_status,"action_remark"=>'',"action_type"=>"edit"];
-                    ActionLog::logAdd($this->post['token'],$order,"CKD", $orde['status'],$this->post);
+                    ActionLog::logAdd(['id'=>$this->uid,'nickname'=>$this->uname],$order,"CKD", $orde['status'],$this->post);
                     $process=["order_code"=>$orde['outCode'],"order_id"=>$orde['id'],"order_status"=>$orde['status'],"order_type"=>"CKD","before_status"=>$od_status];
-                    ProcessOrder::AddProcess($this->post['token'],$process);
+                    ProcessOrder::AddProcess(['id'=>$this->uid,'nickname'=>$this->uname],$process);
                     $sale['th_num'] += $info['error_num'];
                     $sale['th_fee'] += round($info['error_num']*$sale['sale_price'],2);
                     $sale['updatetime']=date("Y-m-d H:i:s");
@@ -429,13 +437,33 @@ class After extends Base
                     }
                 }
                 $order = ["order_code"=>$info['returnCode'],"status"=>$var,"action_remark"=>'',"action_type"=>"edit"];
-                ActionLog::logAdd($this->post['token'],$order,"SHD", $info['status'],$this->post);
+                ActionLog::logAdd(['id'=>$this->uid,'nickname'=>$this->uname],$order,"SHD", $info['status'],$this->post);
 
-                if (in_array($status, [2, 3])) $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $status, "order_type" => "SHD", "before_status" => $var, 'wait_id' => $info['cgderid'], 'wait_name' => $info['cgder'],'holder_id'=>$info['cgderid']];
-                elseif ($status == 4) $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $status, "order_type" => "SHD", "before_status" => $var, 'wait_id' => $info['apply_id'], 'wait_name' => $info['apply_name'],'holder_id'=>$info['apply_id']];
-                else $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $status, "order_type" => "SHD", "before_status" => $var,'holder_id'=>$info['apply_id']];
+//                switch ($status) {
+//                    //待采购审核
+//                    case 2:
+//                        $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $status, "order_type" => "SHD", "before_status" => $var, 'wait_id' => $info['person_id'], 'wait_name' => $info['person'], 'holder_id' => $info['person_id']];
+//                        break;
+//
+//                    //待设置仓库
+//                    case 3:
+//                        $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $status, "order_type" => "SHD", "before_status" => $var, 'wait_id' => $info['cgderid'], 'wait_name' => $info['cgder'], 'holder_id' => $info['cgderid']];
+//                        break;
+//
+//                    //待客户退货
+//                    case 4:
+//                        $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $status, "order_type" => "SHD", "before_status" => $var, 'wait_id' => $info['apply_id'], 'wait_name' => $info['apply_name'], 'holder_id' => $info['apply_id']];
+//                        break;
+//
+//                    default:
+//                        $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $status, "order_type" => "SHD", "before_status" => $var, 'holder_id' => $info['apply_id']];
+//                }
+//                if (in_array($status, [2, 3])) $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $status, "order_type" => "SHD", "before_status" => $var, 'wait_id' => $info['cgderid'], 'wait_name' => $info['cgder'],'holder_id'=>$info['cgderid']];
+//                elseif ($status == 4) $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $status, "order_type" => "SHD", "before_status" => $var, 'wait_id' => $info['apply_id'], 'wait_name' => $info['apply_name'],'holder_id'=>$info['apply_id']];
+//                else $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $status, "order_type" => "SHD", "before_status" => $var,'holder_id'=>$info['apply_id']];
+                $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $status, "order_type" => "SHD", "before_status" => $var, 'wait_id' => $info['person_id'], 'wait_name' => $info['person'], 'holder_id' => $info['person_id']];
 
-                ProcessOrder::AddProcess($this->post['token'],$process);
+                ProcessOrder::AddProcess(['id'=>$this->uid,'nickname'=>$this->uname],$process);
                 Db::commit();
                 return app_show(0,"更新成功");
             }else{
@@ -527,14 +555,14 @@ class After extends Base
                 if($up){
 
                     //修改状态,添加待办
-                    ActionLog::logAdd($this->post['token'], [
+                    ActionLog::logAdd(['id'=>$this->uid,'nickname'=>$this->uname], [
                         "order_code" => $info['returnCode'],//销售单code
                         "status" => $old_info_status,//这里的status是之前的值
                         "action_remark" => '',//备注
                         "action_type" => "status"//新建create,编辑edit,更改状态status
                     ], "SHD", $info['status'], $info);
 
-                    ProcessOrder::AddProcess($this->post['token'], [
+                    ProcessOrder::AddProcess(['id'=>$this->uid,'nickname'=>$this->uname], [
                         "order_type" => 'SHD',
                         "order_code" => $info['returnCode'],//销售单code
                         "order_id" => $info['id'],
@@ -655,9 +683,9 @@ class After extends Base
                 $in=Db::name("order_returninfo")->save($returninfo);
                 if($in){
                     $order = ["order_code"=>$info['returnCode'],"status"=>$var,"action_remark"=>'',"action_type"=>"edit"];
-                    ActionLog::logAdd($this->post['token'],$order,"SHD",$info['status'],$this->post);
+                    ActionLog::logAdd(['id'=>$this->uid,'nickname'=>$this->uname],$order,"SHD",$info['status'],$this->post);
                     $process=["order_code"=>$info['returnCode'],"order_id"=>$info['id'],"order_status"=>$info['status'],"order_type"=>"SHD","before_status"=>$var,'holder_id'=>$info['apply_id']];
-                    ProcessOrder::AddProcess($this->post['token'],$process);
+                    ProcessOrder::AddProcess(['id'=>$this->uid,'nickname'=>$this->uname],$process);
                     Db::commit();
                     return app_show(0,"更新成功");
                 }
@@ -729,9 +757,9 @@ class After extends Base
             $up =Db::name("order_return")->save($info);
             if($up){
                 $order = ["order_code"=>$info['orderCode'],"status"=>$str,"action_remark"=>'',"action_type"=>"edit"];
-                ActionLog::logAdd($this->post['token'],$order,"SHD",$info['status'],$this->post);
+                ActionLog::logAdd(['id'=>$this->uid,'nickname'=>$this->uname],$order,"SHD",$info['status'],$this->post);
                 $process=["order_code"=>$info['returnCode'],"order_id"=>$info['id'],"order_status"=>$info['status'],"order_type"=>"SHD","before_status"=>$str,'holder_id'=>$info['apply_id']];
-                ProcessOrder::AddProcess($this->post['token'],$process);
+                ProcessOrder::AddProcess(['id'=>$this->uid,'nickname'=>$this->uname],$process);
                 $in=Db::name("order_returninfo")->save($return_info);
                 if($in){
                     $data=[
@@ -772,9 +800,9 @@ class After extends Base
 
 
                         $order = ["order_code"=>$data['thNo'],"status"=>0,"action_remark"=>'',"action_type"=>"create"];
-                        ActionLog::logAdd($this->post['token'],$order,"CKTHD", 0,$data);
+                        ActionLog::logAdd(['id'=>$this->uid,'nickname'=>$this->uname],$order,"CKTHD", 0,$data);
                         $process=["order_code"=>$data['thNo'],"order_id"=>$back,"order_status"=>0,"order_type"=>"CKTHD","before_status"=>0];
-                        ProcessOrder::AddProcess($this->post['token'],$process);
+                        ProcessOrder::AddProcess(['id'=>$this->uid,'nickname'=>$this->uname],$process);
                         Db::commit();
                         return app_show(0,"更新成功");
                     }
@@ -867,9 +895,9 @@ class After extends Base
                 $in=Db::name("order_returninfo")->save($returninfo);
                 if($in){
                     $order = ["order_code"=>$info['returnCode'],"status"=>$stat,"action_remark"=>'',"action_type"=>"edit"];
-                    ActionLog::logAdd($this->post['token'],$order,"SHD", $info['status'],$this->post);
+                    ActionLog::logAdd(['id'=>$this->uid,'nickname'=>$this->uname],$order,"SHD", $info['status'],$this->post);
                     $process=["order_code"=>$info['returnCode'],"order_id"=>$info['id'],"order_status"=>$info['status'],"SHD","before_status"=>$stat,'holder_id'=>$info['apply_id']];
-                    ProcessOrder::AddProcess($this->post['token'],$process);
+                    ProcessOrder::AddProcess(['id'=>$this->uid,'nickname'=>$this->uname],$process);
                     Db::commit();
                     return app_show(0,"更新成功");
                 }
@@ -1022,14 +1050,14 @@ class After extends Base
                 if($ro){
 
                     //修改状态,添加待办
-                    ActionLog::logAdd($this->post['token'], [
+                    ActionLog::logAdd(['id'=>$this->uid,'nickname'=>$this->uname], [
                         "order_code" => $info['returnCode'],//销售单code
                         "status" => $old_info_status,//这里的status是之前的值
                         "action_remark" => '',//备注
                         "action_type" => "status"//新建create,编辑edit,更改状态status
                     ], "SHD", $info['status'], $this->post);
 
-                    ProcessOrder::AddProcess($this->post['token'], [
+                    ProcessOrder::AddProcess(['id'=>$this->uid,'nickname'=>$this->uname], [
                         "order_type" => 'SHD',
                         "order_code" => $info['returnCode'],//销售单code
                         "order_id" => $info['id'],
@@ -1078,19 +1106,42 @@ class After extends Base
                     if($sav){
 
                         //修改状态,添加待办
-                        ActionLog::logAdd($this->post['token'], [
+                        ActionLog::logAdd(['id'=>$this->uid,'nickname'=>$this->uname], [
                             "order_code" => $thdata['thNo'],//销售单code
                             "status" => $thdata['status'],//这里的status是之前的值
                             "action_remark" => '',//备注
                             "action_type" => "create"//新建create,编辑edit,更改状态status
                         ], "CKTHD", $thdata['status'], $thdata);
 
-                        ProcessOrder::AddProcess($this->post['token'], [
-                            "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')
@@ -1287,7 +1338,7 @@ class After extends Base
 
             //记录日志
             ActionLog::logAdd($data['token'], ["order_code" => $data['returnCode'], "status" => $rs['status'], "action_remark" => '', "action_type" => "delete"], 'SHD', 8, $this->post);
-            ProcessOrder::AddProcess($this->post['token'], ["order_code" => $data['returnCode'], "order_id" => $rs['id'], "order_status" => 8, "order_type" => 'SHD',"before_status"=>$rs['status'],'holder_id'=>$rs['apply_id']]);
+            ProcessOrder::AddProcess(['id'=>$this->uid,'nickname'=>$this->uname], ["order_code" => $data['returnCode'], "order_id" => $rs['id'], "order_status" => 8, "order_type" => 'SHD',"before_status"=>$rs['status'],'holder_id'=>$rs['apply_id']]);
 
             //提交
             Db::commit();
@@ -1557,14 +1608,14 @@ class After extends Base
                 ];
 
                 //修改状态,添加待办
-                ActionLog::logAdd($this->post['token'], [
+                ActionLog::logAdd(['id'=>$this->uid,'nickname'=>$this->uname], [
                     "order_code" => $orderCode,//销售单code
                     "status" => 0,//这里的status是之前的值
                     "action_remark" => '',//备注
                     "action_type" => "create"//新建create,编辑edit,更改状态status
                 ], "XSQRD", $data['status'], $data);
 
-                ProcessOrder::AddProcess($this->post['token'], [
+                ProcessOrder::AddProcess(['id'=>$this->uid,'nickname'=>$this->uname], [
                     "order_type" => 'XSQRD',
                     "order_code" => $orderCode,//销售单code
                     "order_id" => $datainfo,
@@ -1581,7 +1632,7 @@ class After extends Base
 //                    return error_show(1002,"咨询单修改失败");
 //                }else{
 //                    //修改状态,添加待办
-//                    ActionLog::logAdd($this->post['token'], [
+//                    ActionLog::logAdd(['id'=>$this->uid,'nickname'=>$this->uname], [
 //                        "order_code" => $zx['infoNo'],//咨询单详情编号
 //                        "status" => $old_zx_status,//这里的status是之前的值
 //                        "action_remark" => '',//备注
@@ -1714,14 +1765,14 @@ class After extends Base
                 if ($ou == false) throw new Exception('发货地址添加创建失败');
                 else {
                     //修改状态,添加待办
-                    ActionLog::logAdd($this->post['token'], [
+                    ActionLog::logAdd(['id'=>$this->uid,'nickname'=>$this->uname], [
                         "order_code" => $outCode,//出库单号
                         "status" => 0,//这里的status是之前的值
                         "action_remark" => '',//备注
                         "action_type" => "create"//新建create,编辑edit,更改状态status
                     ], "CKD", 0, $out);
 
-                    ProcessOrder::AddProcess($this->post['token'], [
+                    ProcessOrder::AddProcess(['id'=>$this->uid,'nickname'=>$this->uname], [
                         "order_type" => 'CKD',
                         "order_code" => $outCode,//出库单号
                         "order_id" => Db::name("order_out")->getLastInsID(),
@@ -1863,14 +1914,14 @@ class After extends Base
         $up =Db::name("purchease_order")->insertGetId($cg);
         if($up){
             //修改状态,添加待办
-            ActionLog::logAdd($this->post['token'], [
+            ActionLog::logAdd(['id'=>$this->uid,'nickname'=>$this->uname], [
                 "order_code" => $cg['cgdNo'],//销售单code
                 "status" => 0,//这里的status是之前的值
                 "action_remark" => '',//备注
                 "action_type" => "create"//新建create,编辑edit,更改状态status
             ], "CGD", $cg['status'], $cg);
 
-            ProcessOrder::AddProcess($this->post['token'], [
+            ProcessOrder::AddProcess(['id'=>$this->uid,'nickname'=>$this->uname], [
                 "order_type" => 'CGD',
                 "order_code" => $cg['cgdNo'],//销售单code
                 "order_id" => $up,

+ 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,"删除失败");

+ 58 - 15
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']="";
@@ -227,9 +227,17 @@ class Orderback extends Base
           $up=Db::name("order_back")->save($info);
           if($up){
               $stn = ["order_code"=>$info['thNo'],"status"=>$str,"action_remark"=>'',"action_type"=>"edit"];
-              ActionLog::logAdd($this->post['token'],$stn,"CKTHD",$info['status'],$info);
-              $process=["order_code"=>$info['thNo'],"order_id"=>$info['id'],"order_status"=>$info['status'],'order_type'=>"CKTHD","before_status"=>$str];
-              ProcessOrder::AddProcess($this->post['token'],$process);
+              ActionLog::logAdd(['id' => $this->uid, 'nickname' => $this->uname],$stn,"CKTHD",$info['status'],$info);
+
+              if($info['status'] == 2) $roleid = [10, 31, 41];//特殊处理,写入到10采购负责人、31库管人员、41库管-张凯旋这三个角色下的所有人
+              else $roleid = [31,41];//特殊处理,写入到31库管人员、41库管-张凯旋这三个角色下的所有人
+
+              $handle_user_list = Db::name('user_role')
+                  ->where('is_del', 0)
+                  ->whereIn('roleid', $roleid)
+                  ->column('uid');
+              $process = ["order_code" => $info['thNo'], "order_id" => $info['id'], "order_status" => $info['status'], 'order_type' => "CKTHD", "before_status" => $str, 'handle_user_list' => implode(',', $handle_user_list)];
+              ProcessOrder::AddProcess(['id' => $this->uid, 'nickname' => $this->uname], $process);
               if(empty($errorlist)){
                   Db::commit();
                   return app_show(0,'更新成功');
@@ -280,9 +288,16 @@ class Orderback extends Base
           $up=Db::name("order_back")->save($info);
           if($up){
               $stn = ["order_code"=>$thNo,"status"=>$temp,"action_remark"=>'',"action_type"=>"edit"];
-              ActionLog::logAdd($this->post['token'],$stn,"CKTHD",$info['status'],$stn);
-              $process=["order_code"=>$info['thNo'],"order_id"=>$info['id'],"order_status"=>3,"order_type"=>"CKTHD","before_status"=>$temp];
-              ProcessOrder::AddProcess($this->post['token'],$process);
+              ActionLog::logAdd(['id' => $this->uid, 'nickname' => $this->uname], $stn, "CKTHD", $info['status'], $stn);
+
+              //特殊处理,写入到31库管人员、41库管-张凯旋这三个角色下的所有人
+              $handle_user_list = Db::name('user_role')
+                  ->where('is_del', 0)
+                  ->whereIn('roleid', [31, 41])
+                  ->column('uid');
+              $process = ["order_code" => $info['thNo'], "order_id" => $info['id'], "order_status" => 3, "order_type" => "CKTHD", "before_status" => $temp, 'handle_user_list' => implode(',', $handle_user_list)];
+              ProcessOrder::AddProcess(['id' => $this->uid, 'nickname' => $this->uname], $process);
+
               if(empty($errorlist)){
                   $up =Db::name("order_backinfo")->where(["thNo"=>$thNo,"is_del"=>0])->save(["status"=>1,
                       "updatetime"=>date("Y-m-d H:i:s")]);
@@ -373,9 +388,22 @@ class Orderback extends Base
             $up=Db::name("order_back")->save($info);
             if($up){
                 $stn = ["order_code"=>$thNo,"status"=>$var,"action_remark"=>'',"action_type"=>"edit"];
-                ActionLog::logAdd($this->post['token'],$stn,"CKTHD",$info['status'],$this->post);
-                $process=["order_code"=>$info['thNo'],"order_id"=>$info['id'],"order_status"=>$status,"order_type"=>"CKTHD","before_status"=>$var];
-                ProcessOrder::AddProcess($this->post['token'],$process);
+                ActionLog::logAdd(['id'=>$this->uid,'nickname'=>$this->uname],$stn,"CKTHD",$info['status'],$this->post);
+
+                if (in_array($status, [2, 3])) {
+
+                    if ($status == 2) $roleid = [10, 31, 41];//特殊处理,写入到10采购负责人、31库管人员、41库管-张凯旋这三个角色下的所有人
+                    else $roleid = [31, 41];//特殊处理,写入到、31库管人员、41库管-张凯旋这三个角色下的所有人
+
+                    $handle_user_list = Db::name('user_role')
+                        ->where('is_del', 0)
+                        ->whereIn('roleid', $roleid)
+                        ->column('uid');
+                    $process = ["order_code" => $info['thNo'], "order_id" => $info['id'], "order_status" => $status, "order_type" => "CKTHD", "before_status" => $var, 'handle_user_list' => implode(',', $handle_user_list)];
+
+                } else $process = ["order_code" => $info['thNo'], "order_id" => $info['id'], "order_status" => $status, "order_type" => "CKTHD", "before_status" => $var];
+
+                ProcessOrder::AddProcess(['id' => $this->uid, 'nickname' => $this->uname], $process);
                 Db::commit();
                 return app_show(0,'更新成功');
             }
@@ -434,8 +462,7 @@ class Orderback extends Base
                 Db::rollback();
                 return error_show(1004,"未找到售后单数据");
             }
-			$sabebn =Db::name("sale_info")->where([["orderCode",'=',$info['orderCode']],["num",">",0]])->select()
-			->toArray();
+			$sabebn =Db::name("sale_info")->where([["orderCode",'=',$info['orderCode']],["num",">",0]])->select()->toArray();
             if($param['can_sell_num']!=0&& $param['can_sell_wsm']!=''){
 //                    if($sale['is_stock']==1){ //库存品退回原仓库 备库单释放数量 采购单
 //                        $param['can_sell_wsm'] = $out['wsm_code'];
@@ -749,9 +776,25 @@ class Orderback extends Base
                 }
 
                 $stn = ["order_code" => $param['thNo'], "status" => $info['status'], "action_remark" => '', "action_type" => "edit"];
-                ActionLog::logAdd($this->post['token'], $stn, "CKTHD",  $param['status'], $stn);
-                $process = ["order_code" => $param['thNo'], "order_id" => $info['id'], "order_status" => $param['status'], "order_type" =>"CKTHD","before_status"=>$info['status']];
-                ProcessOrder::AddProcess($this->post['token'], $process);
+                ActionLog::logAdd(['id'=>$this->uid,'nickname'=>$this->uname], $stn, "CKTHD",  $param['status'], $stn);
+
+                if (in_array($param['status'], [1,2, 3])) {
+                    if ($param['status'] == 2) $roleid = [10, 31, 41];//特殊处理,写入到10采购负责人、31库管人员、41库管-张凯旋这三个角色下的所有人
+                    else $roleid = [31, 41];//特殊处理,写入到、31库管人员、41库管-张凯旋这三个角色下的所有人
+
+                    $handle_user_list = Db::name('user_role')
+                        ->where('is_del', 0)
+                        ->whereIn('roleid', $roleid)
+                        ->column('uid');
+
+                    //如果是退货商品验收(节点1),把供应商负责人也加进去
+                    if ($param['status'] == 1) $handle_user_list[] = $sale['cgderid'];
+
+                    $process = ["order_code" => $param['thNo'], "order_id" => $info['id'], "order_status" => $param['status'], "order_type" => "CKTHD", "before_status" => $info['status'], 'handle_user_list' => implode(',', $handle_user_list)];
+
+                } else $process = ["order_code" => $param['thNo'], "order_id" => $info['id'], "order_status" => $param['status'], "order_type" => "CKTHD", "before_status" => $info['status']];
+
+                ProcessOrder::AddProcess(['id' => $this->uid, 'nickname' => $this->uname], $process);
 
                 Db::commit();
                 return app_show(0, '操作成功');

+ 30 - 17
app/admin/controller/Proorder.php

@@ -27,10 +27,10 @@ class Proorder extends Base
          * if(!empty($role['write'])){
          * $where[]=["a.action_uid","in",$role['write']];
          * }
-         * $count = Db::name('process_order')->alias("a")->leftJoin("workflow b","a.order_type=b.order_type and a.order_code=b.order_code")->where($where)->count();
+         * $count = Db::name('process_order')->alias("a")->leftJoin("workflow b","a.order_id=b.order_id and a.order_code=b.order_code")->where($where)->count();
          * $total = ceil("$count/$size");
          * $page = $page>$total ? $total:$page;
-         * $list = Db::name('process_order')->alias("a")->leftJoin("workflow b","a.order_type=b.order_type and a.order_code=b.order_code")
+         * $list = Db::name('process_order')->alias("a")->leftJoin("workflow b","a.order_id=b.order_id and a.order_code=b.order_code")
          * ->field("b.apply_id,b.apply_name,a.addtime,a.action_uid,a.action_name,a.order_status,a.action_status,a.order_type,a.action_process,a.order_code,a.order_id,a.id")
          * ->where($where)->page($page,$size)->order("a.addtime desc")->select();
          * $data=[];
@@ -50,7 +50,7 @@ class Proorder extends Base
             $param = $this->request->filter('trim')->only(['token', 'apply_id' => '', 'action_uid' => '', 'order_code' => '', 'page' => 1, 'size' => 10], 'post');
 
             $db = ProcessWait::alias("a")
-                ->leftJoin("workflow b", "a.order_type=b.order_type and a.order_code=b.order_code")
+                ->leftJoin('workflow b', 'a.order_type=b.order_type and a.order_id=b.order_id')//这个地方不适宜用order_code,因为特殊单子没有编码,例如离职交接单
                 ->where(['is_del' => 0, 'a.status' => ProcessWait::$status_finish]);
 
             $db->where(function ($query) use ($param) {
@@ -60,8 +60,9 @@ class Proorder extends Base
                 $query->whereFindInSet('roleid', $role['roleid']);
 
                 //本人id
-                $user = GetUserInfo($param['token']);
-                if (isset($user['data']['id'])) $query->whereOr('wait_id', $user['data']['id']);
+//                $user = GetUserInfo($param['token']);
+                //if (isset($user['data']['id']))
+                $query->whereOr('wait_id', $this->uid);
             });
 
             if ($param['order_code'] != '') $db->whereLike("a.order_code", '%' . $param['order_code'] . '%');
@@ -96,9 +97,21 @@ class Proorder extends Base
                 ->toArray();
 
             $list = ProcessWait::alias("a")
-                ->field("b.apply_id,b.apply_name,a.addtime,a.action_uid,a.action_name,a.order_status,a.order_type,a.order_process,a.order_code,a.order_id,a.id,a.order_process_finally")
+                ->field([
+                    'b.apply_id',
+                    'b.apply_name',
+                    'a.addtime',
+                    'a.action_uid_finally' => 'action_uid',//取实时操作人id
+                    'a.action_name_finally' => 'action_name',//取实时操作人
+                    'a.order_status',
+                    'a.order_type',
+                    'a.order_code',
+                    'a.order_id',
+                    'a.id',
+                    'a.order_process_finally' => 'order_process',//取实时状态值
+                ])
                 ->whereIn('a.id', array_column($order_types, 'ids'))
-                ->leftJoin("workflow b", "a.order_type=b.order_type and a.order_code=b.order_code")
+                ->leftJoin("workflow b", "a.order_type=b.order_type and a.order_id=b.order_id")
 //                ->page($page, $param['size'])
                 ->order("a.addtime desc")
                 ->select()
@@ -112,15 +125,15 @@ class Proorder extends Base
             $data = [];
             foreach ($list as $value) {
                 $var = Db::name("action_process")
-                    ->where(['order_type' => $value['order_type']])
-                    ->whereIn('order_process', [$value['order_process'], $value['order_process_finally']])
-//                    ->field("status_name,order_process,order_name,roleid")
-                    ->column('status_name,order_process,order_name,roleid', 'order_process');
-//                    ->find();
+                    ->where(['order_type' => $value['order_type'], 'order_process' => $value['order_process']])
+//                    ->whereIn('order_process', [$value['order_process'], $value['order_process_finally']])
+                    ->field("status_name,order_process,order_name,roleid")
+//                    ->column('status_name,order_process,order_name,roleid', 'order_process');
+                    ->findOrEmpty();
                 $value['process_name'] = isset($all_process[$value['order_type']]) ? $all_process[$value['order_type']] : '';
-                $value['order_name'] = $var[$value['order_process']]['order_name'];
-                $value['status_name'] = $var[$value['order_process']]['status_name'];
-                $value['order_process_finally_status_name'] = $var[$value['order_process_finally']]['status_name'] ?? '';
+                $value['order_name'] = $var['order_name'];
+                $value['status_name'] = $var['status_name'];
+//                $value['order_process_finally_status_name'] = $var[$value['order_process_finally']]['status_name'] ?? '';
                 $data[] = $value;
             }
             return app_show(0, "获取成功", ['count' => $count, 'list' => $data]);
@@ -136,7 +149,7 @@ class Proorder extends Base
         $param = $this->request->filter('trim')->only(['token', 'apply_id' => '', 'action_uid' => '', 'order_code' => '', 'page' => 1, 'size' => 10], 'post');
 
         $db = ProcessWait::alias("a")
-            ->leftJoin('workflow b', 'a.order_type=b.order_type and a.order_code=b.order_code')
+            ->leftJoin('workflow b', 'a.order_type=b.order_type and a.order_id=b.order_id')//这个地方不适宜用order_code,因为特殊单子没有编码,例如离职交接单
 //            ->leftJoin('process p', 'p.process_type=a.order_type AND p.is_del=0 AND p.status=1')
             ->where(['a.status' => ProcessWait::$status_wait]);
 
@@ -161,7 +174,7 @@ class Proorder extends Base
         $total = ceil($count / $param['size']);
         $page = $param['page'] > $total ? $total : $param['page'];
         $list = $db
-            ->field("a.id,a.addtime,a.action_name,a.order_status,a.order_type,a.order_process,a.order_code,a.order_id,a.handle_user_list")
+            ->field("a.id,a.addtime,a.action_name,a.order_status,a.order_type,a.order_process,a.order_code,a.order_id,a.handle_user_list,b. apply_id,b.apply_name")
             ->page($page, $param['size'])
             ->order("a.addtime desc")
 //            ->append(['handle_user_list'])

+ 49 - 22
app/admin/controller/Purchin.php

@@ -188,11 +188,11 @@ class Purchin extends Base
             return error_show(1004,"参数 sendtype 不能为空");
         }
 
-        $data = GetUserInfo($this->post['token']);
-        if((!empty($data) && $data['code']!=0) ||empty($data) ){
-            return error_show($data['code'],$data['message']);
-        }
-        $userinfo = $data['data'];
+//        $data = GetUserInfo($this->post['token']);
+//        if((!empty($data) && $data['code']!=0) ||empty($data) ){
+//            return error_show($data['code'],$data['message']);
+//        }
+//        $userinfo = $data['data'];
         $post_company = isset($this->post['post_company'])&&$this->post['post_company']!="" ? trim($this->post['post_company']):"";
         $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']!="" ? $this->post['post_fee']:"0";
@@ -221,8 +221,8 @@ class Purchin extends Base
             "post_code"=>$post_code,
             "post_fee"=>$post_fee,
             "sendtime"=>$post_time,
-            "apply_id"=>$userinfo['id'],
-            "apply_name"=>$userinfo['nickname'],
+            "apply_id"=>$this->uid,
+            "apply_name"=>$this->uname,
             "wait_num"=>0,
             "wsm_num"=>0,
             "sendtype"=>$sendtype,
@@ -235,9 +235,9 @@ class Purchin extends Base
             $win = Db::name("purchease_in")->insert($orin,true);
             if($win){
                 $sto = ["order_code"=>$wsm_in_code,"status"=>$status,"action_remark"=>'',"action_type"=>"edit"];
-                ActionLog::logAdd($this->post['token'],$sto,"RKD",$status,$this->post);
+                ActionLog::logAdd(['id'=>$this->uid,'nickname'=>$this->uname],$sto,"RKD",$status,$this->post);
                 $process=["order_code"=>$wsm_in_code,"order_id"=>$win,"order_status"=>$status,"order_type"=>'RKD',"before_status"=>$status,'holder_id' => $orin['apply_id']];
-                ProcessOrder::AddProcess($this->post['token'],$process);
+                ProcessOrder::AddProcess(['id'=>$this->uid,'nickname'=>$this->uname],$process);
                 $order = ["order_code"=>$cgdNo,"status"=>$cgdinfo['status'],"action_remark"=>'',"action_type"=>"edit"];
 
                 //维护台账信息
@@ -281,7 +281,7 @@ class Purchin extends Base
                     $good_data[]=['good_log_code'=>$wsm_in_code,"stock_id"=>$stockid,"type"=>1,'stock'=>$send_num,"stock_name"=>"usable_stock"];
                     $good_data[]=['good_log_code'=>$wsm_in_code,"stock_id"=>$stockid,"type"=>2,'stock'=>$send_num,"stock_name"=>"wait_in_stock"];
                     if($upd){
-                    	GoodLog::LogAdd($this->post['token'],$good_data,'RKD');
+                    	GoodLog::LogAdd(['id'=>$this->uid,'nickname'=>$this->uname],$good_data,'RKD');
                         //todo:: 新增bn编号库存数据修改
                         if($cgdinfo['order_type']==1){
                         	$bnin=GoodStockInfo::AddBn($stockid,$bn_code,$send_num,$cgdinfo['good_price']);
@@ -328,22 +328,49 @@ class Purchin extends Base
                                         Db::rollback();
                                         return error_show(1004,"出库单出库失败");
                                     }else{
+
+                                        //查询是否有非库存品订单
+                                        $is_stock = Db::name('sale')
+                                            ->where([
+                                                ['is_del','=',0],
+                                                ['orderCode','in',array_column($out,'orderCode')]
+                                            ])->column('is_stock','orderCode');
+
+                                        $supplier = Db::name('supplier')
+                                            ->field('person,personid')
+                                            ->where(['code'=>$cgdinfo['supplierNo'],'is_del'=>0])
+                                            ->findOrEmpty();
+
                                         foreach ($out as $k => $v_outCode) {
-                                            ActionLog::logAdd($this->post['token'], [
+                                            ActionLog::logAdd(['id' => $this->uid, 'nickname' => $this->uname], [
                                                 "order_code" => $v_outCode['outCode'],//出库单号
                                                 "status" => 0,//这里的status是之前的值
                                                 "action_remark" => '',//备注
                                                 "action_type" => "status"//新建create,编辑edit,更改状态status
                                             ], "CKD", 1, $this->post);
+                                            if (isset($is_stock[$v_outCode['orderCode']]) && $is_stock[$v_outCode['orderCode']] == 0) {
+                                                //非库存品,推给供应商负责人
+                                                ProcessOrder::AddProcess(['id' => $this->uid, 'nickname' => $this->uname], [
+                                                    "order_type" => 'CKD',
+                                                    "order_code" => $v_outCode['outCode'],//出库单号
+                                                    "order_id" => $v_outCode['id'],
+                                                    "order_status" => 1,
+                                                    "before_status" => 0,
+                                                    'wait_id' => $supplier['personid'],
+                                                    'wait_name' => $supplier['person'],
+                                                    'holder_id' => $supplier['personid'],
+                                                ]);
+                                            } else {
+                                                ProcessOrder::AddProcess(['id' => $this->uid, 'nickname' => $this->uname], [
+                                                    "order_type" => 'CKD',
+                                                    "order_code" => $v_outCode['outCode'],//出库单号
+                                                    "order_id" => $v_outCode['id'],
+                                                    "order_status" => 1,
+                                                    "before_status" => 0,
+                                                    'holder_id' => $v_outCode['apply_id']
+                                                ]);
+                                            }
 
-                                            ProcessOrder::AddProcess($this->post['token'], [
-                                                "order_type" => 'CKD',
-                                                "order_code" => $v_outCode['outCode'],//出库单号
-                                                "order_id" => $v_outCode['id'],
-                                                "order_status" => 1,
-                                                "before_status"=>0,
-                                                'holder_id' => $v_outCode['apply_id']
-                                            ]);
                                         }
                                     }
                                     $good1 = Db::name("good_stock")->where(["wsm_code"=>$cgdinfo['wsm_code'], "spuCode"=>$cgdinfo['spuCode'],"is_del"=>0])->find();
@@ -369,7 +396,7 @@ class Purchin extends Base
 
                                     $good_data[]=['good_log_code'=>$wsm_in_code,"stock_id"=>$stockid,"type"=>1,'stock'=>$send_num,"stock_name"=>"wait_out_stock"];
                                     $good_data[]=['good_log_code'=>$wsm_in_code,"stock_id"=>$stockid,"type"=>1,'stock'=>$send_num,"stock_name"=>"usable_stock"];
-                                    GoodLog::LogAdd($this->post['token'],$good_data,'RKD');
+                                    GoodLog::LogAdd(['id'=>$this->uid,'nickname'=>$this->uname],$good_data,'RKD');
                                     $sendp=Db::name("order_send")->where(["cgdNo"=>$cgdNo,"outCode"=>$send,"status"=>1])->save (["status"=>2]);
                                     if($sendp==false){
                                         Db::rollback();
@@ -379,9 +406,9 @@ class Purchin extends Base
                             }
                         }
 
-                        ActionLog::logAdd($this->post['token'],$order,"CGD", $cgdinfo['status'],$cgdinfo);
+                        ActionLog::logAdd(['id'=>$this->uid,'nickname'=>$this->uname],$order,"CGD", $cgdinfo['status'],$cgdinfo);
                         $process = ["order_code" => $cgdNo, "order_id" => $cgdinfo['id'], "order_status" => $cgdinfo['status'], "order_type" => 'CGD', "before_status" => $order['status'], 'holder_id' => Db::name('supplier')->where(['code' => $cgdinfo['supplierNo'], 'is_del' => 0])->value('personid', 0)];
-                        ProcessOrder::AddProcess($this->post['token'],$process);
+                        ProcessOrder::AddProcess(['id'=>$this->uid,'nickname'=>$this->uname],$process);
                         Db::commit();
                         return app_show(0,'商品入库成功',["wsm_in_code"=>$wsm_in_code]);
                     }else{

+ 8 - 3
app/admin/controller/Reorder.php

@@ -654,10 +654,15 @@ class Reorder extends Base
             $info["updatetime"]=date("Y-m-d H:i:s");
             $up = Db::name("sale_return")->save($info);
             if($up) {
-                $process = ["order_code" => $code, "order_id" => $info['id'], "order_status" => $status,  "order_type"=>"XSTHD",'before_status'=>$temp,'holder_id'=>$info['apply_id']];
-                ProcessOrder::AddProcess($this->post['token'], $process);
+
+                //如果是节点2(待专员审核),要将待办数据推给供应商负责人
+                if ($info['status'] == 2) $process = ["order_code" => $code, "order_id" => $info['id'], "order_status" => $status, "order_type" => "XSTHD", 'before_status' => $temp, 'wait_id' => $info['person_id'], 'wait_name' => $info['person']];
+                else $process = ["order_code" => $code, "order_id" => $info['id'], "order_status" => $status, "order_type" => "XSTHD", 'before_status' => $temp, 'holder_id' => $info['apply_id']];
+
+                ProcessOrder::AddProcess(['id' => $this->uid, 'nickname' => $this->uname], $process);
+
                 $ste = ["order_code" => $code, "status" => $temp, "action_remark" => '', "action_type" => "status"];
-                ActionLog::logAdd($this->post['token'], $ste,  "XSTHD", $status, $info);
+                ActionLog::logAdd(['id' => $this->uid, 'nickname' => $this->uname], $ste, "XSTHD", $status, $info);
                 if ($status == 4) {
                     if ($info['is_addr'] == 1) {
                         if (isset($addr) && !empty($addr)) {

+ 54 - 29
app/admin/controller/Resign.php

@@ -177,11 +177,11 @@ class Resign extends Base
         if($lastime===""){
             return error_show(1004,"参数lastime不能为空");
         }
-        $data = GetUserInfo($token);
-        if((!empty($data) && $data['code']!=0) ||empty($data) ){
-            return error_show($data['code'],$data['message']);
-        }
-        $userinfo = $data['data'];
+//        $data = GetUserInfo($token);
+//        if((!empty($data) && $data['code']!=0) ||empty($data) ){
+//            return error_show($data['code'],$data['message']);
+//        }
+//        $userinfo = $data['data'];
         $bk_code=makeNo("BK");
         $info = [
             "spuCode"=>$good['spuCode'],
@@ -198,16 +198,16 @@ class Resign extends Base
             "cgderid"=>$good['createrid'],
             "addtime"=>date("Y-m-d H:i:s"),
             "updatetime"=>date("Y-m-d H:i:s"),
-            "apply_id"=>$userinfo['id'],
-            "apply_name"=>$userinfo['nickname'],
+            "apply_id"=>$this->uid,
+            "apply_name"=>$this->uname,
             "bk_code"=>$bk_code
         ];
         $in = Db::name("purchease")->insert($info,true);
         if($in>0){
-            $order=["order_type"=>'BHD',"order_code"=>$bk_code,"order_id"=>$in,"order_status"=>1,"before_status"=>1, 'holder_id' => $info['cgderid']];
-            ProcessOrder::AddProcess($token,$order);
-            $ste = ["order_code"=>$bk_code,"status"=>0,"action_remark"=>'',"action_type"=>"create"];
-            ActionLog::logAdd($token,$ste,"BHD",1,$info);
+            $order = ["order_type" => 'BHD', "order_code" => $bk_code, "order_id" => $in, "order_status" => 1, "before_status" => 1, 'wait_id' => $supplier['personid'], 'wait_name' => $supplier['person']];
+            ProcessOrder::AddProcess(['id' => $this->uid, 'nickname' => $this->uname], $order);
+            $ste = ["order_code" => $bk_code, "status" => 0, "action_remark" => '', "action_type" => "create"];
+            ActionLog::logAdd(['id' => $this->uid, 'nickname' => $this->uname], $ste, "BHD", 1, $info);
 
             //台账记录
             Db::name('standing_book')
@@ -239,31 +239,35 @@ class Resign extends Base
         if(empty($info)){
             return error_show(1002,'未找到数据');
         }
-        $data = GetUserInfo($this->post['token']);
-        if((!empty($data) && $data['code']!=0) ||empty($data) ){
-            return error_show($data['code'],$data['message']);
-        }
+//        $data = GetUserInfo($this->post['token']);
+//        if((!empty($data) && $data['code']!=0) ||empty($data) ){
+//            return error_show($data['code'],$data['message']);
+//        }
         //查验仓库库存数量
 //        $stock =Db::name("good_stock")->alias("a")->leftJoin("warehouse_info b","a.wsm_code=b.wsm_code")->where
 //        (["spuCode"=>$info['spuCode'], "a.is_del"=>0,"a.status"=>1,"b.companyNo"=>$info['companyNo']])->field("a.id,a.usable_stock,a.wait_out_stock")->find();
 //        if(isset($stock['usable_stock'])&& $stock['usable_stock']!=0){
 //            return error_show(1003,"库存数量为 {$stock['usable_stock']} 无法备库");
 //        }
-        $userinfo = $data['data'];
+//        $userinfo = $data['data'];
         $bk_code=makeNo("BK");
         $info['bk_code']=$bk_code;
         $info['status']=1;
         $info['addtime']=date("Y-m-d H:i:s");
         $info['updatetime']=date("Y-m-d H:i:s");
-        $info['apply_id']=$userinfo['id'];
-        $info['apply_name']=$userinfo['nickname'];
+        $info['apply_id']=$this->uid;
+        $info['apply_name']=$this->uname;
         unset($info['id']);
         $in = Db::name("purchease")->insert($info,true);
         if($in>0){
-            $order=["order_type"=>'BHD',"order_code"=>$bk_code,"order_id"=>$in,"order_status"=>1,"before_status"=>1, 'holder_id' => $info['apply_id']];
-            ProcessOrder::AddProcess($this->post['token'],$order);
+            $supplier = Db::name('supplier')
+                ->field('id,person,personid')
+                ->where('code', $info['supplierNo'])
+                ->findOrEmpty();
+            $order = ["order_type" => 'BHD', "order_code" => $bk_code, "order_id" => $in, "order_status" => 1, "before_status" => 1, 'wait_id' => $supplier['personid'], 'wait_name' => $supplier['person']];
+            ProcessOrder::AddProcess(['id' => $this->uid, 'nickname' => $this->uname], $order);
             $ste = ["order_code"=>$bk_code,"status"=>0,"action_remark"=>'',"action_type"=>"create"];
-            ActionLog::logAdd($this->post['token'],$ste,"BHD",1,$info);
+            ActionLog::logAdd(['id' => $this->uid, 'nickname' => $this->uname],$ste,"BHD",1,$info);
             return app_show(0,"新建成功",['bk_code'=>$bk_code]);
         }else{
             return error_show(1005,"新建失败");
@@ -354,11 +358,11 @@ class Resign extends Base
         if($good==false){
             return error_show(1004,"未找到商品数据");
         }
-        $data = GetUserInfo($token);
-        if((!empty($data) && $data['code']!=0) ||empty($data) ){
-            return error_show($data['code'],$data['message']);
-        }
-        $userinfo = $data['data'];
+//        $data = GetUserInfo($token);
+//        if((!empty($data) && $data['code']!=0) ||empty($data) ){
+//            return error_show($data['code'],$data['message']);
+//        }
+//        $userinfo = $data['data'];
         $up =  [
             "spuCode"=>$good_code,
             "good_name"=>$good['good_name'],
@@ -421,8 +425,17 @@ class Resign extends Base
         $info['updatetime']=date("Y-m-d H:i:s");
         $up = Db::name("purchease")->update($info);
         if($up){
+
+            if($status==1){
+                $supplier = Db::name('supplier')
+                    ->field('id,person,personid')
+                    ->where('code', $info['supplierNo'])
+                    ->findOrEmpty();
+                $order = ["order_type" => 'BHD', "order_code" => $info['bk_code'], "order_id" => $info['id'], "order_status" => $status, "before_status" => $temp,'wait_id' => $supplier['personid'], 'wait_name' => $supplier['person']];
+            }else $order = ["order_type" => 'BHD', "order_code" => $info['bk_code'], "order_id" => $info['id'], "order_status" => $status, "before_status" => $temp, 'holder_id' => $info['apply_id']];
             $order = ["order_type" => 'BHD', "order_code" => $info['bk_code'], "order_id" => $info['id'], "order_status" => $status, "before_status" => $temp, 'holder_id' => $info['apply_id']];
             ProcessOrder::AddProcess($this->post['token'],$order);
+
             $ste = ["order_code"=>$info['bk_code'],"status"=> $temp,"action_remark"=>'',"action_type"=>"status"];
             ActionLog::logAdd($this->post['token'],$ste,"BHD",$status,$info);
             return app_show(0,"更新成功",['bk_code'=>$info['bk_code']]);
@@ -628,8 +641,14 @@ class Resign extends Base
             $feed['updatetime']=date("Y-m-d H:i:s");
             $up = Db::name("purchease")->update($feed);
             if($up){
-                $order=["order_type"=>'BHD',"order_code"=>$feed['bk_code'],"order_id"=>$feed['id'], "order_status"=>$feed['status'],"before_status"=>$tem, 'holder_id' => $feed['apply_id']];
-                ProcessOrder::AddProcess($this->post['token'],$order);
+                if ($feed['status'] == 1) {
+                    $supplier = Db::name('supplier')
+                        ->field('id,person,personid')
+                        ->where('code', $feed['supplierNo'])
+                        ->findOrEmpty();
+                    $order = ["order_type" => 'BHD', "order_code" => $feed['bk_code'], "order_id" => $feed['id'], "order_status" => $feed['status'], "before_status" => $tem, 'holder_id' => $feed['apply_id'], 'wait_id' => $supplier['personid'], 'wait_name' => $supplier['person']];
+                } else $order = ["order_type" => 'BHD', "order_code" => $feed['bk_code'], "order_id" => $feed['id'], "order_status" => $feed['status'], "before_status" => $tem, 'holder_id' => $feed['apply_id']];
+                ProcessOrder::AddProcess($this->post['token'], $order);
                 $ste = ["order_code"=>$feed['bk_code'],"status"=>$tem,"action_remark"=>'',"action_type"=>"edit"];
                 ActionLog::logAdd($this->post['token'],$ste,"BHD",$feed['status'],$feed);
                 if($status==3){
@@ -785,13 +804,19 @@ class Resign extends Base
                 "action_type" => "edit"//新建create,编辑edit,更改状态status
             ], "BHD", $info['status'], $info);
 
+            $supplier = Db::name('supplier')
+                ->field('id,person,personid')
+                ->where('code', $info['supplierNo'])
+                ->findOrEmpty();
             ProcessOrder::AddProcess($this->post['token'], [
                 "order_type" => 'BHD',
                 "order_code" => $info['bk_code'],//销售单code
                 "order_id" => $info['id'],
                 "order_status" => $info['status'],
                 "before_status"=>$old_info_status,
-                'holder_id' => $info['apply_id']
+                //'holder_id' => $info['apply_id'],
+                'wait_id' => $supplier['personid'],
+                'wait_name' => $supplier['person'],
             ]);
 
             return app_show(0,"备库单仓库选择成功");

+ 54 - 16
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;
 
@@ -174,7 +176,7 @@ class Resigninfo extends Base
       if($it){
           $stn = ["order_code"=>$id,"status"=>0,"action_remark"=>'',"action_type"=>"edit"];
           ActionLog::logAdd($this->post['token'],$stn,"LZJJ",0,$stn);
-          $process=["order_code"=>'',"order_id"=>$id,"order_status"=>$eid['status'],"order_type"=>'LZJJ',"before_status"=>0, 'holder_id' => $eid['hand_uid']];
+          $process=["order_code"=>'',"order_id"=>$id,"order_status"=>$eid['status'],"order_type"=>'LZJJ',"before_status"=>0, 'holder_id' => $this->uid];
           ProcessOrder::AddProcess(['id'=>$hand_id,'nickname'=>$r],$process);
           return error_show(0,"编辑成功");
       }else{
@@ -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']) :"";
@@ -217,9 +255,9 @@ class Resigninfo extends Base
         $sv = Db::name('resign_info')->save($st);
         if($sv){
             $stn = ["order_code"=>$id,"status"=>$tn,"action_remark"=>'',"action_type"=>"edit"];
-            ActionLog::logAdd($this->post['token'],$stn,"LZJJ",$stauts,$st);
-            $process = ["order_code" => '', "order_id" => $id, "order_status" => $stauts, "order_type" => 'LZJJ', "before_status" => $tn, 'holder_id' => $st['hand_uid']];
-            ProcessOrder::AddProcess($this->post['token'],$process);
+            ActionLog::logAdd(['id'=>$this->uid,'nickname'=>$this->uname],$stn,"LZJJ",$stauts,$st);
+            $process = ["order_code" => '', "order_id" => $id, "order_status" => $st['status'], "order_type" => 'LZJJ', "before_status" => $tn, 'holder_id' => $this->uid];
+            ProcessOrder::AddProcess(['id'=>$this->uid,'nickname'=>$this->uname],$process);
             return error_show(0,"状态更新成功");
         }else{
             return error_show(1002,"状态更新失败");

+ 106 - 41
app/admin/controller/Sale.php

@@ -767,14 +767,36 @@ class Sale extends Base
                             "action_type" => "create"//新建create,编辑edit,更改状态status
                         ], "CKD", 0, $out);
 
-                        ProcessOrder::AddProcess(['id'=>$rm,'nickname'=>$ri], [
-                            "order_type" => 'CKD',
-                            "order_code" => $outCode,//出库单号
-                            "order_id" => $ou,
-                            "order_status" => $status,
-                            "before_status" => 0,
-                            'holder_id'=>$out['apply_id'],
-                        ]);
+                        //区分是否是库存品订单
+                        if($status===1 && $etid['is_stock']==0){
+
+                            $supplier = Db::name('supplier')
+                                ->field('person,personid')
+                                ->where('code',$cgdinfo['supplierNo'])
+                                ->findOrEmpty();
+
+                            ProcessOrder::AddProcess(['id'=>$rm,'nickname'=>$ri], [
+                                "order_type" => 'CKD',
+                                "order_code" => $outCode,//出库单号
+                                "order_id" => $ou,
+                                "order_status" => $status,
+                                "before_status" => 0,
+                                'wait_id'=>$supplier['personid'],
+                                'wait_name'=>$supplier['person'],
+                                'holder_id'=>$supplier['personid'],
+                            ]);
+                        }else{
+                            ProcessOrder::AddProcess(['id'=>$rm,'nickname'=>$ri], [
+                                "order_type" => 'CKD',
+                                "order_code" => $outCode,//出库单号
+                                "order_id" => $ou,
+                                "order_status" => $status,
+                                "before_status" => 0,
+                                'holder_id'=>$out['apply_id'],
+                            ]);
+                        }
+
+
 
                         //处理台账-既然是根据orderCode更新的数据,那么肯定是有数据的,只需要更新就行了
                         Db::execute("UPDATE `wsm_standing_book` SET `outCode`=CONCAT(IFNULL(`outCode`,''),',{$outCode}'),`updatetime`='" . date('Y-m-d H:i:s') . "' WHERE `orderCode`='{$orderCode}'");
@@ -2781,12 +2803,12 @@ class Sale extends Base
         if ($send_num > $der['wsend_num']) {
             return error_show(1002, "超出可发货数量");
         }
-        $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;
+        $ri = $this->uname;
         $addrid = isset($this->post['addrid']) && $this->post['addrid'] !== "" ? intval($this->post['addrid']) : "";
         $dr = Db::name('order_addr')->where(['id' => $addrid, 'is_del' => 0])->find();
         if (empty($dr)) {
@@ -2825,10 +2847,21 @@ class Sale extends Base
             $datainfo = Db::name('order_out')->insert($data, true);
             if ($datainfo > 0) {
                 $stx = ["order_code" => $outCode, "status" => $status, "action_remark" => '', "action_type" => "create"];
-                ActionLog::logAdd($this->post['token'], $stx, $der['order_type'] == 1 ? "CKD" : 'ZXCKD', $status, $data);
-                $order = ["order_type" => "CKD", "order_code" => $outCode, "order_id" => $datainfo, "order_status" => $data['status'], "before_status" => 0,                                    'holder_id'=>$data['apply_id']
-                ];
-                ProcessOrder::AddProcess($this->post['token'], $order);
+                ActionLog::logAdd(['id'=>$rm,'nickname'=>$ri], $stx, $der['order_type'] == 1 ? "CKD" : 'ZXCKD', $status, $data);
+
+                //是否库存品,待办数据推送到的人有区别,
+                //库存品——>推到库管,非库存品——>推送供应商负责人
+                if ($data['status'] == 1 && $der['is_stock'] == 0) {
+                    $supplier = Db::name('supplier')
+                        ->alias('a')
+                        ->field('a.id,a.person,a.personid')
+                        ->leftJoin('purchease_order b', 'b.is_del=0 AND b.supplierNo=a.code')
+                        ->leftJoin('order_num c', 'c.cgdNo=b.cgdNo')
+                        ->where('c.orderCode', $orderCode)
+                        ->findOrEmpty();
+                    $order = ["order_type" => "CKD", "order_code" => $outCode, "order_id" => $datainfo, "order_status" => $data['status'], "before_status" => 0, 'holder_id' => $data['apply_id'], 'wait_id' => $supplier['personid'] ?? 0, 'wait_name' => $supplier['person'] ?? ''];
+                } else  $order = ["order_type" => "CKD", "order_code" => $outCode, "order_id" => $datainfo, "order_status" => $data['status'], "before_status" => 0, 'holder_id' => $data['apply_id']];
+                ProcessOrder::AddProcess(['id'=>$rm,'nickname'=>$ri], $order);
                 if ($status == 1) {
                     $item = $der['status'];
                     $der['send_num'] += $send_num;
@@ -2843,10 +2876,10 @@ class Sale extends Base
                     }
                     $stx = ["order_code" => $orderCode, "status" => $item, "action_remark" => '', "action_type" => "edit"];
 
-                    ActionLog::logAdd($this->post['token'], $stx, "XSQRD", $der['status'], $der);
+                    ActionLog::logAdd(['id'=>$rm,'nickname'=>$ri], $stx, "XSQRD", $der['status'], $der);
                     $order = ["order_type" => "XSQRD", "order_code" => $orderCode, "order_id" => $der['id'], "order_status" => $data['status'], "before_status" => 0,'holder_id'=>$der['apply_id']];
 
-                    ProcessOrder::AddProcess($this->post['token'], $order);
+                    ProcessOrder::AddProcess(['id'=>$rm,'nickname'=>$ri], $order);
                 }
 
                 Db::commit();
@@ -2892,9 +2925,20 @@ class Sale extends Base
             $cust = Db::name('order_out')->save($codeinfo);
             if ($cust) {
                 $stx = ["order_code" => $outCode, "status" => $time, "action_remark" => '', "action_type" => "status"];
-                ActionLog::logAdd($this->post['token'], $stx, "CKD", $codeinfo['status'], $codeinfo);
-                $order = ["order_type" => "CKD", "order_code" => $outCode, "order_id" => $codeinfo['id'], "order_status" => $codeinfo['status'], "before_status" => 0,            'holder_id'=>$codeinfo['apply_id']];
-                ProcessOrder::AddProcess($this->post['token'], $order);
+                ActionLog::logAdd(['id'=>$this->uid,'nickname'=>$this->uname], $stx, "CKD", $codeinfo['status'], $codeinfo);
+
+                if ($status == 1 && $dr['is_stock'] == 0) {
+                    $supplier = Db::name('supplier')
+                        ->alias('a')
+                        ->field('a.id,a.person,a.personid')
+                        ->leftJoin('purchease_order b', 'b.is_del=0 AND b.supplierNo=a.code')
+                        ->leftJoin('order_num c', 'c.cgdNo=b.cgdNo')
+                        ->where('c.orderCode', $codeinfo['orderCode'])
+                        ->findOrEmpty();
+                    $order = ["order_type" => "CKD", "order_code" => $outCode, "order_id" => $codeinfo['id'], "order_status" => $codeinfo['status'], "before_status" => 0, 'holder_id' => $codeinfo['apply_id'], 'wait_id' => $supplier['personid'] ?? 0, 'wait_name' => $supplier['person'] ?? ''];
+                }else $order = ["order_type" => "CKD", "order_code" => $outCode, "order_id" => $codeinfo['id'], "order_status" => $codeinfo['status'], "before_status" => 0,'holder_id'=>$codeinfo['apply_id']];
+
+                ProcessOrder::AddProcess(['id'=>$this->uid,'nickname'=>$this->uname], $order);
                 if ($status == 1) {
                     $stokc = Db::name("good_stock")->where(['spuCode' => $codeinfo['spuCode'], "wsm_code" => $codeinfo['wsm_code'],
                         "is_del" => 0])->find();
@@ -2927,14 +2971,14 @@ class Sale extends Base
                         return error_show(1003, "更新失败");
                     }
                     $stx = ["order_code" => $dr['orderCode'], "status" => $item, "action_remark" => '', "action_type" => "edit"];
-                    ActionLog::logAdd($this->post['token'], $stx, $dr['order_type'] == 2 ? "ZXQRD" : "XSQRD", $dr['status'],$dr);
+                    ActionLog::logAdd(['id'=>$this->uid,'nickname'=>$this->uname], $stx, $dr['order_type'] == 2 ? "ZXQRD" : "XSQRD", $dr['status'],$dr);
                     $order = ["order_type" => "XSQRD", "order_code" => $dr['orderCode'], "order_id" => $dr['id'], "order_status" => $dr['status'], "before_status" => 0, 'holder_id' => $dr['apply_id']];
-                    ProcessOrder::AddProcess($this->post['token'], $order);
+                    ProcessOrder::AddProcess(['id'=>$this->uid,'nickname'=>$this->uname], $order);
 
                     //商品变动日志表,good_log_code字段存储销售订单编号
                     $good_data[] = ['good_log_code' => $outCode, "stock_id" => $stoc['id'], "type" => 1, 'stock' => $codeinfo['send_num'], "stock_name" => "wait_out_stock"];
                     $good_data[] = ['good_log_code' => $outCode, "stock_id" => $stoc['id'], "type" => 2, 'stock' => $codeinfo['send_num'], "stock_name" => "usable_stock"];
-                    GoodLog::LogAdd($this->post['token'], $good_data, 'CKD');
+                    GoodLog::LogAdd(['id'=>$this->uid,'nickname'=>$this->uname], $good_data, 'CKD');
                 }
                 if ($status == 3) {
                     $var = Db::name('good_stock')->where(['wsm_code' => $codeinfo['wsm_code'], 'good_type_code' => $dr['good_code']])->find();
@@ -2952,7 +2996,7 @@ class Sale extends Base
 
                     //商品变动日志表,good_log_code字段存储销售订单编号
                     $good_data[] = ['good_log_code' => $outCode, "stock_id" => $var['id'], "type" => 2, 'stock' => $codeinfo['send_num'], "stock_name" => "intra_stock"];
-                    GoodLog::LogAdd($this->post['token'], $good_data, $codeinfo['order_type'] == 2 ? "ZXCKD" : "CKD");
+                    GoodLog::LogAdd(['id'=>$this->uid,'nickname'=>$this->uname], $good_data, $codeinfo['order_type'] == 2 ? "ZXCKD" : "CKD");
                     if ($stre == false) {
                         Db::rollback();
                         return error_show(1002, "状态更新失败");
@@ -3487,12 +3531,12 @@ class Sale extends Base
         if ($addr_code == "") {
             return error_show(1002, "参数addr_code不能为空");
         }
-        $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'] : "";
         $sendtime = isset($this->post['sendtime']) && $this->post['sendtime'] !== "" ? $this->post['sendtime'] : date("Y-m-d H:i:s");
 
         Db::startTrans();
@@ -3622,14 +3666,35 @@ class Sale extends Base
                         "action_type" => "create"//新建create,编辑edit,更改状态status
                     ], "CKD", $data['status'], $data);
 
-                    ProcessOrder::AddProcess(['id'=>$rm,'nickname'=>$ri], [
-                        "order_type" => 'CKD',
-                        "order_code" => $data['outCode'],//出库单号
-                        "order_id" => $datainfo,
-                        "order_status" => $data['status'],
-                        "before_status" => 0,
-                        'holder_id'=>$data['apply_id']
-                    ]);
+                    //是否库存品,待办数据推送到的人有区别,
+                    //库存品——>推到库管,非库存品——>推送供应商负责人
+                    if ($data['status'] == 1 && $der['is_stock'] == 0) {
+
+                        $supplier = Db::name('supplier')
+                            ->field('person,personid')
+                            ->where('code', $cgd['supplierNo'])
+                            ->findOrEmpty();
+
+                        ProcessOrder::AddProcess(['id' => $rm, 'nickname' => $ri], [
+                            "order_type" => 'CKD',
+                            "order_code" => $data['outCode'],//出库单号
+                            "order_id" => $datainfo,
+                            "order_status" => $data['status'],
+                            "before_status" => 0,
+                            'holder_id' => $data['apply_id'],
+                            'wait_id' => $supplier['personid'],
+                            'wait_name' => $supplier['person'],
+                        ]);
+                    } else {
+                        ProcessOrder::AddProcess(['id' => $rm, 'nickname' => $ri], [
+                            "order_type" => 'CKD',
+                            "order_code" => $data['outCode'],//出库单号
+                            "order_id" => $datainfo,
+                            "order_status" => $data['status'],
+                            "before_status" => 0,
+                            'holder_id' => $data['apply_id']
+                        ]);
+                    }
 
                     //维护台账记录
                     Db::name('standing_book')

+ 16 - 1
app/admin/controller/Salezx.php

@@ -588,7 +588,22 @@ class Salezx extends \app\BaseController
             if($datainfo) {
                 $st = ["order_code"=>$der['outCode'],"status"=>$var,"action_remark"=>'',"action_type"=>"edit"];
                 ActionLog::logAdd($this->post['token'],$st,"CKD",1,$der);
-                $ord=["order_type"=>"CKD","order_code"=>$der['outCode'],"order_id"=>$der['id'], "order_status"=>$der['status'],'holder_id' => $der['apply_id']];
+
+                //是否库存品,待办数据推送到的人有区别,
+                //库存品——>推到库管,非库存品——>推送供应商负责人
+                if($order['is_stock']==1) $ord=["order_type"=>"CKD","order_code"=>$der['outCode'],"order_id"=>$der['id'], "order_status"=>$der['status'],'holder_id' => $der['apply_id']];
+                else {
+
+                    $supplier = Db::name('supplier')
+                        ->alias('a')
+                        ->field('a.id,a.person,a.personid')
+                        ->leftJoin('purchease_order b', 'b.is_del=0 AND b.supplierNo=a.code')
+                        ->leftJoin('order_num c', 'c.cgdNo=b.cgdNo')
+                        ->where('c.orderCode', $der['orderCode'])
+                        ->findOrEmpty();
+
+                    $ord = ["order_type" => "CKD", "order_code" => $der['outCode'], "order_id" => $der['id'], "order_status" => $der['status'], 'holder_id' => $der['apply_id'], 'wait_id' => $supplier['personid'], 'wait_name' => $supplier['person']];
+                }
                 ProcessOrder::AddProcess($this->post['token'],$ord);
 //                    $send =Db::name("order_out")->where(["wsm_code"=>$der['wsm_code'],'orderCode'=>$der['orderCode']])->sum("send_num");
 //                    $order['send_num']+= $der['send_num'];

+ 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;

+ 6 - 4
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=[
@@ -38,7 +38,7 @@ class ProcessWait extends Model
         //修改各个节点的最终节点
         Db::name('process_wait')
             ->where(['order_type' => $data['order_type'], 'order_code' => $data['order_code'], 'order_id' => $data['order_id']])
-            ->update(['order_process_finally' => $data['action_process']]);
+            ->update(['order_process_finally' => $data['action_process'], 'action_uid_finally' => $data['action_uid'], 'action_name_finally' => $data['action_name']]);
 
         //把上一个节点改成已完成
         Db::name('process_wait')
@@ -136,6 +136,8 @@ class ProcessWait extends Model
                 'status' => self::$status_wait,
                 'order_process' => $data['action_process'],
                 'order_process_finally' => $data['action_process'],
+                'action_uid_finally' => $data['action_uid'],
+                'action_name_finally' => $data['action_name'],
                 'addtime' => date('Y-m-d H:i:s'),
                 'updatetime' => date('Y-m-d H:i:s'),
             ];
@@ -153,8 +155,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集合
             }
 
             //增加新的节点

+ 2 - 1
app/admin/model/Workflow.php

@@ -23,7 +23,8 @@ class Workflow extends \think\Model
         if((is_array($header)&&in_array($data['action_process'],$header))||$header==$data['action_process']){
             $order_status=1; //流程新建
         }
-        $proces = self::where(["order_type"=>$data['order_type'],"order_code"=>$data['order_code'],"is_del"=>0])->find();
+        $proces = self::where(["order_type"=>$data['order_type'],"order_id"=>$data['order_id'],"is_del"=>0])->find();
+
         if($proces){
             $info=[
                 "order_process"=>$data['order_status'],

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

@@ -78,12 +78,12 @@ Route::rule('resultedit','admin/Result/edit');
 Route::rule('resultdel','admin/Result/del');
 Route::rule('resultstatu','admin/Result/statu');
 
-Route::rule('Resigninfolist','admin/Resigninfo/list');
-Route::rule('Resigninfocreate','admin/Resigninfo/create');
+Route::rule('Resigninfolist','admin/Resigninfo/list');//离职交接单列表
+Route::rule('Resigninfocreate','admin/Resigninfo/create');//离职交接单创建
 Route::rule('Resigninfoselect','admin/Resigninfo/selec');
-Route::rule('Resigninfoedit','admin/Resigninfo/edit');
-Route::rule('Resigninfodel','admin/Resigninfo/del');
-Route::rule('Resigninfostatu','admin/Resigninfo/statu');
+Route::rule('Resigninfoedit','admin/Resigninfo/edit');//离职交接单编辑
+Route::rule('Resigninfodel','admin/Resigninfo/del');//离职交接单作废
+Route::rule('Resigninfostatu','admin/Resigninfo/statu');//离职交接单审核
 
 Route::rule('Consultlist','admin/Consult/list');
 Route::rule('Consultinfo','admin/Consult/info');
@@ -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');

+ 71 - 0
app/command/UpdateProcessWaitFinallyActionData.php

@@ -0,0 +1,71 @@
+<?php
+declare (strict_types=1);
+
+namespace app\command;
+
+use think\console\Command;
+use think\console\Input;
+use think\console\input\Argument;
+use think\console\input\Option;
+use think\console\Output;
+use think\Exception;
+use think\facade\Db;
+
+class UpdateProcessWaitFinallyActionData extends Command
+{
+    protected function configure()
+    {
+        // 指令配置
+        $this->setName('UpdateProcessWaitFinallyActionData')
+            ->setDescription('更新待办数据表中的字段:最终操作人');
+    }
+
+    protected function execute(Input $input, Output $output)
+    {
+        Db::startTrans();
+        try {
+
+            Db::name('process_wait')
+                ->where('action_uid_finally','<>',0)
+                ->update(['action_uid_finally'=>0,'action_name_finally'=>'']);
+
+            $data = Db::name('process_wait')
+                ->field('order_code,order_type,order_id')
+                ->group('order_code,order_type,order_id')
+                ->whereIn('status', [1, 2])
+                ->cursor();
+
+            foreach ($data as $value) {
+
+                if($value['order_type'] == 'LZJJ') $order_code = $value['order_id'];//离职交接单,取id
+                else $order_code = $value['order_code'];
+
+                $action = Db::name('action_log')
+                    ->field('id,action_id,action_name')
+                    ->where([
+                        'order_code'=>$order_code,
+                        'order_type'=>$value['order_type']
+                    ])
+                    ->order('id','desc')
+                    ->findOrEmpty();
+
+                if ($action) Db::name('process_wait')
+                    ->where('order_code', $value['order_code'])
+                    ->where('order_type', $value['order_type'])
+                    ->update(['action_uid_finally' => $action['action_id'],'action_name_finally' => $action['action_name']]);
+            }
+
+            Db::commit();
+
+            $output->writeln('update success');
+
+        } catch (Exception $exception) {
+            Db::rollback();
+            $output->writeln('update fail,' . $exception->getMessage());
+        }
+
+
+    }
+
+
+}

+ 3 - 3
app/command/handleYzOrderData.php

@@ -476,7 +476,7 @@ class handleYzOrderData extends Command
                                 "addtime" => date("Y-m-d H:i:s"),
                                 "updatetime" => date("Y-m-d H:i:s")
                             ];
-                            $ou = Db::name("order_out")->insert($out);
+                            $ou = Db::name("order_out")->insertGetId($out);
                             if ($ou == false) throw new Exception('发货地址添加创建失败');
                             else {
                                 //修改状态,添加待办
@@ -490,8 +490,8 @@ class handleYzOrderData extends Command
                                 ProcessOrder::AddProcess(['id' => $rm, 'nickname' => $ri], [
                                     "order_type" => 'CKD',
                                     "order_code" => $outCode,//出库单号
-                                    "order_id" => 0,
-                                    "order_status" => 0,
+                                    "order_id" => $ou,
+                                    "order_status" => $out['status'],
                                     "before_status" => 0,
                                     'holder_id'=>$data['apply_id']
                                 ]);

+ 22 - 4
app/youzan/logic/Goodup.php

@@ -222,7 +222,7 @@ class Goodup
 
             $old_exam_status = $rs->exam_status;
 
-//            $userinfo = GetUserInfo($data['token']);
+            $userinfo = GetUserInfo($data['token']);
 
             //platform_youzan 更新信息
             $update_data = [
@@ -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' => $uid];
+            ProcessOrder::AddProcess(['id' => $uid, 'nickname' => $nickname], $process);
+
             Db::commit();
 
             return app_show(0, '操作成功');
@@ -630,6 +640,8 @@ class Goodup
 
             $userinfo = GetUserInfo($data['token']);
 
+            $old_status = $rs->exam_status;
+
             $curl_data = [
                 'item_no' => $rs->skuCode,//商品自定义编码 skuCode
                 'uid' => isset($userinfo['data']['id']) ? $userinfo['data']['id'] : 0,
@@ -676,6 +688,12 @@ class Goodup
                     'addtime' => date('Y-m-d H:i:s')
                 ]);
 
+            $stn = ["order_code" => $rs->skuCode, "status" => $old_status, "action_remark" => '', "action_type" => "status"];
+            ActionLog::logAdd(['id' => $curl_data['uid'], ['nickname' => $curl_data['nickname']]], $stn, "YZSX", $db::$exam_status_8, $data);
+
+            $process = ["order_code" => $rs->skuCode, "order_id" => $rs->id, "order_status" => $db::$exam_status_8, "order_type" => 'YZSX', "before_status" => $old_status, 'holder_id' => $curl_data['uid']];
+            ProcessOrder::AddProcess(['id' => $curl_data['uid'], ['nickname' => $curl_data['nickname']]], $process);
+
             Db::commit();
 
             return app_show(0, '操作成功');