Browse Source

维护已办列表的上一步申请人的历史数据的脚本完善

wufeng 2 years ago
parent
commit
8b8d66a2cb

+ 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());
+        }
+
+
+    }
+
+
+}

+ 1 - 1
app/command/UpdateProcessWaitFinallyData.php

@@ -17,7 +17,7 @@ class UpdateProcessWaitFinallyData extends Command
     {
         // 指令配置
         $this->setName('UpdateProcessWaitFinallyData')
-            ->setDescription('更新待办数据表中的字段:实时状态值和实时操作人');
+            ->setDescription('更新待办数据表中的字段:最终状态值');
     }
 
     protected function execute(Input $input, Output $output)

+ 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']
                                 ]);