12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?php
- declare (strict_types = 1);
- namespace app\txx\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\facade\Cache;
- class updateAct extends Command
- {
- protected function configure()
- {
- // 指令配置
- $this->setName('updateact')
- ->setDescription('the updateact command');
- }
- protected function execute(Input $input, Output $output)
- {
- // 指令输出
- if(Cache::get('createPro2')==1) return;
- Cache::set('createPro2',1,60);
- $actGood=new \app\txx\model\ActGood();//同步券码
- $actGood->startTrans();
- try{
- $info = $actGood->with(['act','promocode'])
- ->where(['version'=>'2.0','status'=>2,'is_del'=>0])->order("updatetime asc")->findOrEmpty();
- if(!$info->isEmpty()){
- if($info->promocode_status==0){
- $info->updatetime=date("Y-m-d H:i:s");
- $info->save();
- }elseif($info->promocode_status==1){
- $info->status=3;
- $info->save();
- }else{
- $info->status=5;
- $info->remark=$info->promocode_remark;
- $info->save();
- }
- }
- $actGood->commit();
- }catch (\Exception $e){
- $actGood->rollback();
- $output->writeln('<error>'.$e->getMessage().'</error>');
- }
- Cache::set('createPro2',0);
- }
- }
|