updateAct.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. }
  34. }
  35. $actGood->commit();
  36. }catch (\Exception $e){
  37. $actGood->rollback();
  38. $output->writeln('<error>'.$e->getMessage().'</error>');
  39. }
  40. $output->writeln('updateact');
  41. }
  42. }