UpdateProcessWaitFinallyData.php 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <?php
  2. declare (strict_types=1);
  3. namespace app\command;
  4. use think\console\Command;
  5. use think\console\Input;
  6. use think\console\input\Argument;
  7. use think\console\input\Option;
  8. use think\console\Output;
  9. use think\Exception;
  10. use think\facade\Db;
  11. class UpdateProcessWaitFinallyData extends Command
  12. {
  13. protected function configure()
  14. {
  15. // 指令配置
  16. $this->setName('UpdateProcessWaitFinallyData')
  17. ->setDescription('更新待办数据表中的字段:最终状态值');
  18. }
  19. protected function execute(Input $input, Output $output)
  20. {
  21. //判断是否在执行中
  22. Db::startTrans();
  23. try {
  24. //设置标识,执行中
  25. $data = Db::name('process_wait')
  26. ->field('order_code,order_type,order_id')
  27. ->group('order_code,order_type,order_id')
  28. ->whereIn('status', [1, 2])
  29. ->cursor();
  30. foreach ($data as $value) {
  31. $order_process_finally = 0;
  32. switch ($value['order_type']) {
  33. //1.采购单流程
  34. case 'CGD':
  35. $order_process_finally = Db::name('purchease_order')->where(['id' => $value['order_id'], 'is_del' => 0])->value('status', 0);
  36. break;
  37. //2.采购单入库流程
  38. case 'RKD':
  39. $order_process_finally = Db::name('purchease_in')->where(['id' => $value['order_id'], 'is_del' => 0])->value('status', 0);
  40. break;
  41. //3.备货申请单流程
  42. case 'BHD':
  43. $order_process_finally = Db::name('purchease')->where(['id' => $value['order_id'], 'is_del' => 0])->value('status', 0);
  44. break;
  45. //4.销售订单流程
  46. case 'XSQRD':
  47. $order_process_finally = Db::name('sale')->where(['id' => $value['order_id'], 'is_del' => 0])->value('status', 0);
  48. break;
  49. //5.发货申请单流程
  50. case 'CKD':
  51. $order_process_finally = Db::name('order_out')->where(['id' => $value['order_id'], 'is_del' => 0])->value('status', 0);
  52. break;
  53. //6.售后申请单流程
  54. case 'SHD':
  55. $order_process_finally = Db::name('order_return')->where(['id' => $value['order_id'], 'is_del' => 0])->value('status', 0);
  56. break;
  57. //7.售后退货单流程
  58. case 'CKTHD':
  59. $order_process_finally = Db::name('order_back')->where(['id' => $value['order_id'], 'is_del' => 0])->value('status', 0);
  60. break;
  61. //8.销售退货单流程
  62. case 'XSTHD':
  63. $order_process_finally = Db::name('sale_return')->where(['id' => $value['order_id'], 'is_del' => 0])->value('status', 0);
  64. break;
  65. //9.采购工差单流程
  66. case 'CGGCD':
  67. $order_process_finally = Db::name('purchease_diff')->where(['id' => $value['order_id'], 'is_del' => 0])->value('status', 0);
  68. break;
  69. //10.销售工差单流程
  70. case 'XSGCD':
  71. $order_process_finally = Db::name('sale_diff')
  72. ->where(['id' => $value['order_id']])
  73. ->value('status', 0);
  74. break;
  75. //11.调拨单流程
  76. case 'DBD':
  77. $order_process_finally = Db::name('allot_stock')->where(['id' => $value['order_id'], 'is_del' => 0])->value('status', 0);
  78. break;
  79. //12.盘点单流程
  80. case 'PDD':
  81. $order_process_finally = Db::name('good_check')->where(['id' => $value['order_id'], 'is_del' => 0])->value('status', 0);
  82. break;
  83. //13.议价单流程
  84. case 'YJD':
  85. $order_process_finally = Db::name('bargain_order')->where(['id' => $value['order_id'], 'is_del' => 0])->value('status', 0);
  86. break;
  87. //14.项目单流程
  88. case 'PRO':
  89. $order_process_finally = Db::name('project')->where(['id' => $value['order_id'], 'is_del' => 0])->value('status', 0);
  90. break;
  91. //15.商品成本流程
  92. case 'SPCB':
  93. $order_process_finally = Db::name('good_basic')->where(['id' => $value['order_id'], 'is_del' => 0])->value('status', 0);
  94. break;
  95. //16.商品上线流程
  96. case 'SPSX':
  97. $order_process_finally = Db::name('good_platform')
  98. ->where(['id' => $value['order_id']])
  99. ->value('exam_status', 0);
  100. break;
  101. //17.活动流程
  102. case 'HD':
  103. $order_process_finally = Db::name('good_activity')->where(['id' => $value['order_id'], 'is_del' => 0])->value('status', 0);
  104. break;
  105. //19.有赞商品上架流程
  106. case 'YZSX':
  107. $order_process_finally = Db::name('platform_youzan')
  108. ->where(['id' => $value['order_id']])
  109. ->value('exam_status', 0);
  110. break;
  111. //20.有赞订单审核流程
  112. // case 'YZQRD':
  113. // $order_process_finally = Db::name('')->where(['id' => $value['order_id'], 'is_del' => 0])->value('', 0);
  114. // break;
  115. //22.离职交接流程
  116. case 'LZJJ':
  117. $order_process_finally = Db::name('resign_info')->where(['id' => $value['order_id'], 'is_del' => 0])->value('status', 0);
  118. break;
  119. //23.采购单退货流程
  120. case 'CGTHD':
  121. $order_process_finally = Db::name('purchease_return')->where(['id' => $value['order_id'], 'is_del' => 0])->value('status', 0);
  122. break;
  123. //24.竞价单流程
  124. case 'ZXD':
  125. $order_process_finally = Db::name('consult_order')->where(['id' => $value['order_id'], 'is_del' => 0])->value('status', 0);
  126. break;
  127. //25.商品下线流程
  128. // case 'GOL':
  129. // $order_process_finally = Db::name('good_offline_log')->where(['id' => $value['order_id'], 'is_del' => 0])->value('status', 0);
  130. // break;
  131. }
  132. if ($order_process_finally) Db::name('process_wait')
  133. ->where('order_code', $value['order_code'])
  134. ->where('order_type', $value['order_type'])
  135. ->update(['order_process_finally' => $order_process_finally]);
  136. }
  137. Db::commit();
  138. $output->writeln('update success');
  139. //解除标识,执行完毕
  140. } catch (Exception $exception) {
  141. Db::rollback();
  142. $output->writeln('update fail,' . $exception->getMessage());
  143. //解除标识,执行完毕
  144. }
  145. }
  146. }