updateAct.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. declare (strict_types = 1);
  3. namespace app\txx\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. class updateAct extends Command
  10. {
  11. protected function configure()
  12. {
  13. // 指令配置
  14. $this->setName('updateact')
  15. ->setDescription('the updateact command');
  16. }
  17. protected function execute(Input $input, Output $output)
  18. {
  19. // 指令输出
  20. $actGood=new \app\txx\model\ActGood();//同步券码
  21. $actGood->startTrans();
  22. try{
  23. $info = $actGood->with(['act','promocode'])
  24. ->where(['version'=>'2.0','status'=>2,'is_del'=>0])->findOrEmpty();
  25. if(!$info->isEmpty()){
  26. if($info->promocode_status==1){
  27. $info->status=3;
  28. $info->save();
  29. }else{
  30. $info->status=5;
  31. $info->remark=$info->promocode_remark;
  32. $info->save();
  33. $info->act->status=6;
  34. $info->act->save();
  35. }
  36. }
  37. $actGood->commit();
  38. }catch (\Exception $e){
  39. $actGood->rollback();
  40. $output->writeln('<error>'.$e->getMessage().'</error>');
  41. }
  42. $output->writeln('updateact');
  43. }
  44. }