123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- <?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 UpdateProcessWaitFinallyData extends Command
- {
- protected function configure()
- {
-
- $this->setName('UpdateProcessWaitFinallyData')
- ->setDescription('更新待办数据表中的字段:最终状态值');
- }
- protected function execute(Input $input, Output $output)
- {
-
- Db::startTrans();
- try {
-
- $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) {
- $order_process_finally = 0;
- switch ($value['order_type']) {
-
- case 'CGD':
- $order_process_finally = Db::name('purchease_order')->where(['id' => $value['order_id'], 'is_del' => 0])->value('status', 0);
- break;
-
- case 'RKD':
- $order_process_finally = Db::name('purchease_in')->where(['id' => $value['order_id'], 'is_del' => 0])->value('status', 0);
- break;
-
- case 'BHD':
- $order_process_finally = Db::name('purchease')->where(['id' => $value['order_id'], 'is_del' => 0])->value('status', 0);
- break;
-
- case 'XSQRD':
- $order_process_finally = Db::name('sale')->where(['id' => $value['order_id'], 'is_del' => 0])->value('status', 0);
- break;
-
- case 'CKD':
- $order_process_finally = Db::name('order_out')->where(['id' => $value['order_id'], 'is_del' => 0])->value('status', 0);
- break;
-
- case 'SHD':
- $order_process_finally = Db::name('order_return')->where(['id' => $value['order_id'], 'is_del' => 0])->value('status', 0);
- break;
-
- case 'CKTHD':
- $order_process_finally = Db::name('order_back')->where(['id' => $value['order_id'], 'is_del' => 0])->value('status', 0);
- break;
-
- case 'XSTHD':
- $order_process_finally = Db::name('sale_return')->where(['id' => $value['order_id'], 'is_del' => 0])->value('status', 0);
- break;
-
- case 'CGGCD':
- $order_process_finally = Db::name('purchease_diff')->where(['id' => $value['order_id'], 'is_del' => 0])->value('status', 0);
- break;
-
- case 'XSGCD':
- $order_process_finally = Db::name('sale_diff')
- ->where(['id' => $value['order_id']])
- ->value('status', 0);
- break;
-
- case 'DBD':
- $order_process_finally = Db::name('allot_stock')->where(['id' => $value['order_id'], 'is_del' => 0])->value('status', 0);
- break;
-
- case 'PDD':
- $order_process_finally = Db::name('good_check')->where(['id' => $value['order_id'], 'is_del' => 0])->value('status', 0);
- break;
-
- case 'YJD':
- $order_process_finally = Db::name('bargain_order')->where(['id' => $value['order_id'], 'is_del' => 0])->value('status', 0);
- break;
-
- case 'PRO':
- $order_process_finally = Db::name('project')->where(['id' => $value['order_id'], 'is_del' => 0])->value('status', 0);
- break;
-
- case 'SPCB':
- $order_process_finally = Db::name('good_basic')->where(['id' => $value['order_id'], 'is_del' => 0])->value('status', 0);
- break;
-
- case 'SPSX':
- $order_process_finally = Db::name('good_platform')
- ->where(['id' => $value['order_id']])
- ->value('exam_status', 0);
- break;
-
- case 'HD':
- $order_process_finally = Db::name('good_activity')->where(['id' => $value['order_id'], 'is_del' => 0])->value('status', 0);
- break;
-
- case 'YZSX':
- $order_process_finally = Db::name('platform_youzan')
- ->where(['id' => $value['order_id']])
- ->value('exam_status', 0);
- break;
-
-
- case 'LZJJ':
- $order_process_finally = Db::name('resign_info')->where(['id' => $value['order_id'], 'is_del' => 0])->value('status', 0);
- break;
-
- case 'CGTHD':
- $order_process_finally = Db::name('purchease_return')->where(['id' => $value['order_id'], 'is_del' => 0])->value('status', 0);
- break;
-
- case 'ZXD':
- $order_process_finally = Db::name('consult_order')->where(['id' => $value['order_id'], 'is_del' => 0])->value('status', 0);
- break;
-
- }
- if ($order_process_finally) Db::name('process_wait')
- ->where('order_code', $value['order_code'])
- ->where('order_type', $value['order_type'])
- ->update(['order_process_finally' => $order_process_finally]);
- }
- Db::commit();
- $output->writeln('update success');
-
- } catch (Exception $exception) {
- Db::rollback();
- $output->writeln('update fail,' . $exception->getMessage());
-
- }
- }
- }
|