1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <?php
- declare (strict_types = 1);
- namespace app\command;
- use app\admin\model\OrderOutChild;use app\model\FhdChild;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 OutChildSend extends Command
- {
- protected function configure()
- {
- // 指令配置
- $this->setName('outchildsend')
- ->setDescription('the outchildsend command');
- }
- protected function execute(Input $input, Output $output)
- {
- // 指令输出
- $key='outchildsend';
- $rs = Cache::store('redis')->get($key);
- if ($rs==1)return true;
- Cache::store('redis')->set($key,1,3000);
- $date = date("Y-m-d H:i:s",time()-3600);
- $list = OrderOutChild::where([["addtime",">=",$date],["is_del","=",0]])->hidden(["id"])->select();
- if($list->isEmpty()==false){
- $Insert=[];
- foreach ($list->toArray() as $item){
- $isT =FhdChild::where(["outChildCode"=>$item['outChildCode']])->findOrEmpty();
- if($isT->isEmpty()){
- $Insert[]=$item;
- }
- if(count($Insert)>500){
- FhdChild::strict(false)->insertAll($Insert);
- $Insert=[];
- }
- }
- if(!empty($Insert))FhdChild::strict(false)->insertAll($Insert);
- }
-
- $output->writeln('outchildsend');
- }
- }
|